Make modlog actions an enum, change actions and editing to use them, and map them into localised/translated in the templates

merge-requests/341/head
Thomas Lynch 1 year ago
parent 8476c260b9
commit 14a8d8cbee
  1. 30
      lib/input/modlogactions.js
  2. 14
      locales/en-GB.json
  3. 14
      locales/pt-PT.json
  4. 14
      locales/ru-RU.json
  5. 45
      models/forms/actionhandler.js
  6. 5
      models/forms/editpost.js
  7. 2
      views/pages/globalmanagelogs.pug
  8. 2
      views/pages/managelogs.pug
  9. 2
      views/pages/modlog.pug

@ -0,0 +1,30 @@
'use strict';
module.exports = Object.seal(Object.freeze(Object.preventExtensions({
BAN: 'Ban',
GLOBAL_BAN: 'Global ban',
BAN_REPORTER: 'Ban reporter',
GLOBAL_BAN_REPORTER: 'Global ban reporter',
DISMISS: 'Dismiss reports',
GLOBAL_DISMISS: 'Dismiss global reports',
DELETE: 'Delete',
DELETE_BY_IP: 'Delete by IP',
GLOBAL_DELETE_BY_IP: 'Global delete by IP',
UNLINK_FILES: 'Unlink files',
DELETE_FILES: 'Delete files',
SPOILER_FILES: 'Spoiler files',
EDIT: 'Edit',
MOVE: 'Move',
BUMPLOCK: 'Bumplock',
LOCK: 'Lock',
STICKY: 'Sticky',
CYCLE: 'Cycle',
})));

@ -202,6 +202,7 @@
"Ban reason": "Ban reason",
"Ban Reason": "Ban Reason",
"Ban reason must be %s characters or less": "Ban reason must be %s characters or less",
"Ban reporter": "Ban reporter",
"Ban Reporters": "Ban Reporters",
"Banned!": "Banned!",
"Banner": {
@ -282,6 +283,7 @@
"Bump Limit Min": "Bump Limit Min",
"Bump Limit must be %s-%s": "Bump Limit must be %s-%s",
"Bump Order": "Bump Order",
"Bumplock": "Bumplock",
"Bumplocked": "Bumplocked",
"Bypass": "Bypass",
"Bypass all bans.": "Bypass all bans.",
@ -377,6 +379,7 @@
"Custom pages max must be a number": "Custom pages max must be a number",
"Customisation": "Customisation",
"Customise": "Customise",
"Cycle": "Cycle",
"Cyclic": "Cyclic",
"Date": "Date",
"Date Added": "Date Added",
@ -392,6 +395,8 @@
"Delete Assets": "Delete Assets",
"Delete Banners": "Delete Banners",
"Delete board": "Delete board",
"Delete by IP": "Delete by IP",
"Delete files": "Delete files",
"Delete Files": "Delete Files",
"Delete Flags": "Delete Flags",
"Delete from IP globally": "Delete from IP globally",
@ -439,7 +444,9 @@
"Disable board custom CSS": "Disable board custom CSS",
"Disable Reply Subject": "Disable Reply Subject",
"Disconnected": "Disconnected",
"Dismiss global reports": "Dismiss global reports",
"Dismiss Global Reports": "Dismiss Global Reports",
"Dismiss reports": "Dismiss reports",
"Dismiss Reports": "Dismiss Reports",
"Dismissed reports": "Dismissed reports",
"Distortion Intensity": "Distortion Intensity",
@ -582,13 +589,16 @@
"Global": "Global",
"Global Announcement": "Global Announcement",
"Global announcement must not exceed 10000 characters": "Global announcement must not exceed 10000 characters",
"Global ban": "Global ban",
"Global Ban Poster": "Global Ban Poster",
"Global ban reporter": "Global ban reporter",
"Global Ban Reporters": "Global Ban Reporters",
"Global Bans": "Global Bans",
"Global Board Owner": "Global Board Owner",
"Global Board Staff": "Global Board Staff",
"Global bump limit min must be less than max": "Global bump limit min must be less than max",
"Global bump limit minimum must be a number": "Global bump limit minimum must be a number",
"Global delete by IP": "Global delete by IP",
"global filter hit: \"%s\"": "global filter hit: \"%s\"",
"Global limit ban reason field length must be a number": "Global limit ban reason field length must be a number",
"Global limit board description field length must be a number": "Global limit board description field length must be a number",
@ -755,6 +765,7 @@
"Local Stats": "Local Stats",
"Local time": "Local time",
"Local Time": "Local Time",
"Lock": "Lock",
"Lock board": "Lock board",
"Lock Mode": "Lock Mode",
"Lock thread creation": "Lock thread creation",
@ -962,6 +973,7 @@
"Password": "Password",
"Password and password confirmation must match": "Password and password confirmation must match",
"Password confirmation must be 100 characters or less": "Password confirmation must be 100 characters or less",
"Password did not match any selected posts": "Password did not match any selected posts",
"Password must be %s characters or less": "Password must be %s characters or less",
"Password must be 1-100 characters": "Password must be 1-100 characters",
"Password must be 50 characters or less": "Password must be 50 characters or less",
@ -1125,6 +1137,7 @@
"Space file name replacement must be 1 character": "Space file name replacement must be 1 character",
"Spoiler": "Spoiler",
"Spoiler File": "Spoiler File",
"Spoiler files": "Spoiler files",
"Spoiler Files": "Spoiler Files",
"Spoilered %s posts": {
"one": "Spoilered %s post",
@ -1243,6 +1256,7 @@
"Unknown Types Pass Validation": "Unknown Types Pass Validation",
"Unlimit media height": "Unlimit media height",
"Unlimit Media Height": "Unlimit Media Height",
"Unlink files": "Unlink files",
"Unlink Files": "Unlink Files",
"Unlinked %s files": {
"one": "Unlinked %s file",

@ -202,6 +202,7 @@
"Ban reason": "Motivo do Ban",
"Ban Reason": "Motivo do Ban",
"Ban reason must be %s characters or less": "Ban reason must be %s characters or less",
"Ban reporter": "Ban reporter",
"Ban Reporters": "Banir Denunciantes",
"Banned!": "Banido ;_;",
"Banner": {
@ -282,6 +283,7 @@
"Bump Limit Min": "Limite Mín de Bumps",
"Bump Limit must be %s-%s": "Bump Limit must be %s-%s",
"Bump Order": "Bump",
"Bumplock": "Bumplock",
"Bumplocked": "SAGE",
"Bypass": "Bypass",
"Bypass all bans.": "Bypass todos os bans.",
@ -377,6 +379,7 @@
"Custom pages max must be a number": "Custom pages max must be a number",
"Customisation": "Personalização",
"Customise": "Personalizar",
"Cycle": "Cycle",
"Cyclic": "Reciclar",
"Date": "Data",
"Date Added": "Data Adicionado",
@ -392,6 +395,8 @@
"Delete Assets": "Apagar Assets",
"Delete Banners": "Apagar Banners",
"Delete board": "Apagar tábua",
"Delete by IP": "Delete by IP",
"Delete files": "Delete files",
"Delete Files": "Apagar Ficheiros",
"Delete Flags": "Apagar Especial",
"Delete from IP globally": "Apagar do IP Globalmente",
@ -439,7 +444,9 @@
"Disable board custom CSS": "Desativar CSS das tábuas",
"Disable Reply Subject": "Desativar Assunto nas Respostas",
"Disconnected": "Desligado",
"Dismiss global reports": "Dismiss global reports",
"Dismiss Global Reports": "Ignorar Deúncias Globais",
"Dismiss reports": "Dismiss reports",
"Dismiss Reports": "Ignorar Denúncias",
"Dismissed reports": "Dismissed reports",
"Distortion Intensity": "Intensidade da Distorção",
@ -582,13 +589,16 @@
"Global": "Global",
"Global Announcement": "Anúncio Global",
"Global announcement must not exceed 10000 characters": "Global announcement must not exceed 10000 characters",
"Global ban": "Global ban",
"Global Ban Poster": "Banir Globalmente Utilizador",
"Global ban reporter": "Global ban reporter",
"Global Ban Reporters": "Banir Globalmente Denunciantes",
"Global Bans": "Bans Globais",
"Global Board Owner": "Admin de Tábuas Globais",
"Global Board Staff": "Staff de Tábuas Globais",
"Global bump limit min must be less than max": "Global bump limit min must be less than max",
"Global bump limit minimum must be a number": "Global bump limit minimum must be a number",
"Global delete by IP": "Global delete by IP",
"global filter hit: \"%s\"": "filtro global: \"%s\"",
"Global limit ban reason field length must be a number": "Global limit ban reason field length must be a number",
"Global limit board description field length must be a number": "Global limit board description field length must be a number",
@ -755,6 +765,7 @@
"Local Stats": "Informações",
"Local time": "Hora local",
"Local Time": "Hora Local",
"Lock": "Lock",
"Lock board": "Trancar Tábua",
"Lock Mode": "Modo de Trancar",
"Lock thread creation": "Trancar criação de fios",
@ -962,6 +973,7 @@
"Password": "Password",
"Password and password confirmation must match": "Password and password confirmation must match",
"Password confirmation must be 100 characters or less": "Password confirmation must be 100 characters or less",
"Password did not match any selected posts": "Password did not match any selected posts",
"Password must be %s characters or less": "Password must be %s characters or less",
"Password must be 1-100 characters": "Password must be 1-100 characters",
"Password must be 50 characters or less": "Password must be 50 characters or less",
@ -1125,6 +1137,7 @@
"Space file name replacement must be 1 character": "Space file name replacement must be 1 character",
"Spoiler": "Spoiler",
"Spoiler File": "Spoiler Ficheiro",
"Spoiler files": "Spoiler files",
"Spoiler Files": "Spoiler Ficheiros",
"Spoilered %s posts": {
"one": "Spoilered %s post",
@ -1243,6 +1256,7 @@
"Unknown Types Pass Validation": "Tipos Desconhecidos Passam Validação",
"Unlimit media height": "Não limitar tamanho ficheiros abertos",
"Unlimit Media Height": "Altura Media Ilimitado",
"Unlink files": "Unlink files",
"Unlink Files": "Remover Ficheiros",
"Unlinked %s files": {
"one": "Unlinked %s file",

@ -202,6 +202,7 @@
"Ban reason": "Причина запрета",
"Ban Reason": "Причина запрета",
"Ban reason must be %s characters or less": "Ban reason must be %s characters or less",
"Ban reporter": "Ban reporter",
"Ban Reporters": "Запретить репортеров",
"Banned!": "Запрещено!",
"Banner": {
@ -282,6 +283,7 @@
"Bump Limit Min": "Минимальный предел удара",
"Bump Limit must be %s-%s": "Bump Limit must be %s-%s",
"Bump Order": "Порядок ударов",
"Bumplock": "Bumplock",
"Bumplocked": "Заблокированный",
"Bypass": "Обход",
"Bypass all bans.": "Обойти все запреты.",
@ -377,6 +379,7 @@
"Custom pages max must be a number": "Custom pages max must be a number",
"Customisation": "Настройка",
"Customise": "Настройка.",
"Cycle": "Cycle",
"Cyclic": "Циклический",
"Date": "Дата",
"Date Added": "Дата добавления",
@ -392,6 +395,8 @@
"Delete Assets": "Удалить ресурсы",
"Delete Banners": "Удалить баннеры",
"Delete board": "Удалить доску",
"Delete by IP": "Delete by IP",
"Delete files": "Delete files",
"Delete Files": "Удалить файлы",
"Delete Flags": "Удалить флаги",
"Delete from IP globally": "Удалить с IP глобально",
@ -439,7 +444,9 @@
"Disable board custom CSS": "Отключить пользовательский CSS платы",
"Disable Reply Subject": "Отключить тему ответа",
"Disconnected": "Отключен",
"Dismiss global reports": "Dismiss global reports",
"Dismiss Global Reports": "Отклонить глобальные отчеты",
"Dismiss reports": "Dismiss reports",
"Dismiss Reports": "Отклонять отчеты",
"Dismissed reports": "Dismissed reports",
"Distortion Intensity": "Интенсивность искажения",
@ -582,13 +589,16 @@
"Global": "Глобальный",
"Global Announcement": "Глобальное объявление",
"Global announcement must not exceed 10000 characters": "Global announcement must not exceed 10000 characters",
"Global ban": "Global ban",
"Global Ban Poster": "Плакат глобального запрета",
"Global ban reporter": "Global ban reporter",
"Global Ban Reporters": "Репортеры глобального запрета",
"Global Bans": "Глобальные запреты",
"Global Board Owner": "Владелец глобального совета директоров",
"Global Board Staff": "Персонал Глобального совета директоров",
"Global bump limit min must be less than max": "Global bump limit min must be less than max",
"Global bump limit minimum must be a number": "Global bump limit minimum must be a number",
"Global delete by IP": "Global delete by IP",
"global filter hit: \"%s\"": "попадание в глобальный фильтр: \"%s\"",
"Global limit ban reason field length must be a number": "Global limit ban reason field length must be a number",
"Global limit board description field length must be a number": "Global limit board description field length must be a number",
@ -755,6 +765,7 @@
"Local Stats": "Местная статистика",
"Local time": "Местное время",
"Local Time": "Местное время",
"Lock": "Lock",
"Lock board": "Блокирующая доска",
"Lock Mode": "Режим блокировки",
"Lock thread creation": "Создание потока блокировки",
@ -962,6 +973,7 @@
"Password": "Пароль",
"Password and password confirmation must match": "Password and password confirmation must match",
"Password confirmation must be 100 characters or less": "Password confirmation must be 100 characters or less",
"Password did not match any selected posts": "Password did not match any selected posts",
"Password must be %s characters or less": "Password must be %s characters or less",
"Password must be 1-100 characters": "Password must be 1-100 characters",
"Password must be 50 characters or less": "Password must be 50 characters or less",
@ -1125,6 +1137,7 @@
"Space file name replacement must be 1 character": "Space file name replacement must be 1 character",
"Spoiler": "Спойлер",
"Spoiler File": "Файл спойлера",
"Spoiler files": "Spoiler files",
"Spoiler Files": "Файлы-спойлеры",
"Spoilered %s posts": {
"one": "Испорченный пост %s",
@ -1243,6 +1256,7 @@
"Unknown Types Pass Validation": "Неизвестные типы проходят проверку",
"Unlimit media height": "Неограниченная высота носителя",
"Unlimit Media Height": "Неограниченная высота носителя",
"Unlink files": "Unlink files",
"Unlink Files": "Отменить привязку файлов",
"Unlinked %s files": {
"one": "Unlinked %s file",

@ -15,6 +15,7 @@ const { Posts, Boards, Modlogs } = require(__dirname+'/../../db/')
, movePosts = require(__dirname+'/moveposts.js')
, { remove } = require('fs-extra')
, uploadDirectory = require(__dirname+'/../../lib/file/uploaddirectory.js')
, ModlogActions = require(__dirname+'/../../lib/input/modlogactions.js')
, getAffectedBoards = require(__dirname+'/../../lib/misc/affectedboards.js')
, dynamicResponse = require(__dirname+'/../../lib/misc/dynamic.js')
, { Permissions } = require(__dirname+'/../../lib/permission/permissions.js')
@ -25,6 +26,8 @@ const { Posts, Boards, Modlogs } = require(__dirname+'/../../db/')
module.exports = async (req, res, next) => {
const { __ } = res.locals;
//try to set a good redirect
let redirect = req.headers.referer;
if (!redirect) {
@ -54,8 +57,8 @@ module.exports = async (req, res, next) => {
}
if (passwordPosts.length === 0) {
return dynamicResponse(req, res, 403, 'message', {
'title': 'Forbidden',
'error': 'Password did not match any selected posts',
'title': __('Forbidden'),
'error': __('Password did not match any selected posts'),
redirect,
});
}
@ -89,14 +92,14 @@ module.exports = async (req, res, next) => {
if (req.body.ban || req.body.global_ban || req.body.report_ban || req.body.global_report_ban) {
const { message, action, query } = await banPoster(req, res, next);
if (req.body.ban) {
modlogActions.push('Ban');
modlogActions.push(ModlogActions.BAN);
} else if (req.body.global_ban) {
modlogActions.push('Global Ban');
modlogActions.push(ModlogActions.GLOBAL_BAN);
}
if (req.body.report_ban) {
modlogActions.push('Ban reporter');
modlogActions.push(ModlogActions.BAN_REPORTER);
} else if (req.body.global_report_ban) {
modlogActions.push('Global ban reporter');
modlogActions.push(ModlogActions.GLOBAL_BAN_REPORTER);
}
if (action) {
combinedQuery[action] = { ...combinedQuery[action], ...query};
@ -117,8 +120,8 @@ module.exports = async (req, res, next) => {
});
if (protectedThread === true) {
return dynamicResponse(req, res, 403, 'message', {
'title': 'Forbidden',
'error': 'You cannot delete old threads or threads with too many replies',
'title': __('Forbidden'),
'error': __('You cannot delete old threads or threads with too many replies'),
redirect,
});
}
@ -173,11 +176,11 @@ module.exports = async (req, res, next) => {
messages.push(message);
if (action) {
if (req.body.delete) {
modlogActions.push('Delete');
modlogActions.push(ModlogActions.DELETE);
} else if (req.body.delete_ip_board) {
modlogActions.push('Delete by IP');
modlogActions.push(ModlogActions.DELETE_BY_IP);
} else if (req.body.delete_ip_global) {
modlogActions.push('Global delete by IP');
modlogActions.push(ModlogActions.GLOBAL_DELETE_BY_IP);
}
recalculateThreadMetadata = true;
}
@ -196,7 +199,7 @@ module.exports = async (req, res, next) => {
}
const { message, action } = await movePosts(req, res);
if (action) {
modlogActions.push('Moved');
modlogActions.push(ModlogActions.MOVE);
recalculateThreadMetadata = true;
if (res.locals.destinationBoard && res.locals.destinationThread) {
res.locals.posts.push(res.locals.destinationThread);
@ -213,9 +216,9 @@ module.exports = async (req, res, next) => {
const { message, action, query } = await deletePostsFiles(res.locals, req.body.unlink_file);
if (action) {
if (req.body.unlink_file) {
modlogActions.push('Unlink files');
modlogActions.push(ModlogActions.UNLINK_FILES);
} else if (req.body.delete_file) {
modlogActions.push('Delete files');
modlogActions.push(ModlogActions.DELETE_FILES);
}
recalculateThreadMetadata = true;
combinedQuery[action] = { ...combinedQuery[action], ...query};
@ -224,7 +227,7 @@ module.exports = async (req, res, next) => {
} else if (req.body.spoiler) {
const { message, action, query } = spoilerPosts(res.locals);
if (action) {
modlogActions.push('Spoiler files');
modlogActions.push(ModlogActions.SPOILER_FILES);
combinedQuery[action] = { ...combinedQuery[action], ...query};
}
messages.push(message);
@ -233,7 +236,7 @@ module.exports = async (req, res, next) => {
if (req.body.bumplock) {
const { message, action, query } = bumplockPosts(res.locals);
if (action) {
modlogActions.push('Bumplock');
modlogActions.push(ModlogActions.BUMPLOCK);
combinedQuery[action] = { ...combinedQuery[action], ...query};
}
messages.push(message);
@ -241,7 +244,7 @@ module.exports = async (req, res, next) => {
if (req.body.lock) {
const { message, action, query } = lockPosts(res.locals);
if (action) {
modlogActions.push('Lock');
modlogActions.push(ModlogActions.LOCK);
combinedQuery[action] = { ...combinedQuery[action], ...query};
}
messages.push(message);
@ -249,7 +252,7 @@ module.exports = async (req, res, next) => {
if (req.body.sticky != null) {
const { message, action, query } = stickyPosts(res.locals, req.body.sticky);
if (action) {
modlogActions.push('Sticky');
modlogActions.push(ModlogActions.STICKY);
combinedQuery[action] = { ...combinedQuery[action], ...query};
}
messages.push(message);
@ -257,7 +260,7 @@ module.exports = async (req, res, next) => {
if (req.body.cyclic) {
const { message, action, query } = cyclePosts(res.locals);
if (action) {
modlogActions.push('Cycle');
modlogActions.push(ModlogActions.CYCLE);
combinedQuery[action] = { ...combinedQuery[action], ...query};
}
messages.push(message);
@ -274,9 +277,9 @@ module.exports = async (req, res, next) => {
const { message, action, query } = dismissReports(req, res);
if (action) {
if (req.body.dismiss) {
modlogActions.push('Dismiss reports');
modlogActions.push(ModlogActions.DISMISS);
} else if (req.body.global_dismiss) {
modlogActions.push('Dismiss global reports');
modlogActions.push(ModlogActions.GLOBAL_DISMISS);
}
combinedQuery[action] = { ...combinedQuery[action], ...query};
}

@ -9,6 +9,7 @@ const { Posts, Modlogs } = require(__dirname+'/../../db/')
, nameHandler = require(__dirname+'/../../lib/post/name.js')
, getFilterStrings = require(__dirname+'/../../lib/post/getfilterstrings.js')
, filterActions = require(__dirname+'/../../lib/post/filteractions.js')
, ModlogActions = require(__dirname+'/../../lib/input/modlogactions.js')
, config = require(__dirname+'/../../lib/misc/config.js')
, buildQueue = require(__dirname+'/../../lib/build/queue.js')
, dynamicResponse = require(__dirname+'/../../lib/misc/dynamic.js')
@ -20,8 +21,6 @@ module.exports = async (req, res) => {
todo: handle some more situations
- last activity date
- correct bump date when editing thread or last post in a thread
- allow for regular users (OP ONLY) and option for staff to disable in board settings
- different permission levels for historical posts when remarked up (or not, fuck that)
*/
const { __ } = res.locals;
@ -132,7 +131,7 @@ todo: handle some more situations
postId: post.postId,
thread: post.thread,
}],
actions: 'Edit',
actions: ModlogActions.EDIT,
date: new Date(),
showUser: req.body.hide_name ? false : true,
message: req.body.log_message || null,

@ -57,7 +57,7 @@ block content
a(href=`recent.html?ip=${encodeURIComponent(logIp)}`) #{logIp}
|
a(href=`?ip=${encodeURIComponent(logIp)}`) [+]
td #{log.actions}
td #{log.actions.map(a => __(a))}
td
if log.showLinks
for postLink in log.postLinks

@ -43,7 +43,7 @@ block content
td
- const logIp = viewRawIp === true ? log.ip.raw : log.ip.cloak;
| #{logIp}
td #{log.actions}
td #{log.actions.map(a => __(a))}
td
if log.showLinks
for postLink in log.postLinks

@ -26,7 +26,7 @@ block content
- const logDate = new Date(log.date);
td: time.reltime(datetime=logDate.toISOString()) #{logDate.toLocaleString(undefined, {hourCycle:'h23'})}
td(class=(!log.showUser ? 'em' : '')) #{log.showUser ? log.user : __('Hidden User')}
td #{log.actions}
td #{log.actions.map(a => __(a))}
td
if log.showLinks
for postLink in log.postLinks

Loading…
Cancel
Save