|
|
|
@ -13,6 +13,20 @@ module.exports = function (User) {
|
|
|
|
|
await isReady(uid, cid, 'lastqueuetime');
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
User.checkMuted = async function (uid) {
|
|
|
|
|
const now = Date.now();
|
|
|
|
|
const mutedUntil = await User.getUserField(uid, 'mutedUntil');
|
|
|
|
|
if (mutedUntil > now) {
|
|
|
|
|
let muteLeft = ((mutedUntil - now) / (1000 * 60));
|
|
|
|
|
if (muteLeft > 60) {
|
|
|
|
|
muteLeft = (muteLeft / 60).toFixed(0);
|
|
|
|
|
throw new Error(`[[error:user-muted-for-hours, ${muteLeft}]]`);
|
|
|
|
|
} else {
|
|
|
|
|
throw new Error(`[[error:user-muted-for-minutes, ${muteLeft.toFixed(0)}]]`);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
async function isReady(uid, cid, field) {
|
|
|
|
|
if (parseInt(uid, 10) === 0) {
|
|
|
|
|
return;
|
|
|
|
@ -30,17 +44,9 @@ module.exports = function (User) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const now = Date.now();
|
|
|
|
|
if (userData.mutedUntil > now) {
|
|
|
|
|
let muteLeft = ((userData.mutedUntil - now) / (1000 * 60));
|
|
|
|
|
if (muteLeft > 60) {
|
|
|
|
|
muteLeft = (muteLeft / 60).toFixed(0);
|
|
|
|
|
throw new Error(`[[error:user-muted-for-hours, ${muteLeft}]]`);
|
|
|
|
|
} else {
|
|
|
|
|
throw new Error(`[[error:user-muted-for-minutes, ${muteLeft.toFixed(0)}]]`);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
await User.checkMuted(uid);
|
|
|
|
|
|
|
|
|
|
const now = Date.now();
|
|
|
|
|
if (now - userData.joindate < meta.config.initialPostDelay * 1000) {
|
|
|
|
|
throw new Error(`[[error:user-too-new, ${meta.config.initialPostDelay}]]`);
|
|
|
|
|
}
|
|
|
|
|