From 0e07d74afa0d3f180d716aacad6ad64e69e6d7c7 Mon Sep 17 00:00:00 2001 From: HF Date: Sat, 25 Jun 2022 14:49:04 +0200 Subject: [PATCH] print moderation actions also in en chat --- src/core/adminfunctions.js | 10 +++++----- src/routes/api/modtools.js | 10 +++++++++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/core/adminfunctions.js b/src/core/adminfunctions.js index 8137cb2..069ff52 100644 --- a/src/core/adminfunctions.js +++ b/src/core/adminfunctions.js @@ -155,7 +155,7 @@ export async function executeImageAction( ); // eslint-disable-next-line max-len - if (logger) logger(`Loaded image wth ${pxlCount} pixels to #${canvas.ident},${x},${y} (${x}_${y} - ${x + info.width - 1}_${y + info.height - 1}`); + if (logger) logger(`loaded image wth ${pxlCount} pixels to #${canvas.ident},${x},${y} (${x}_${y} - ${x + info.width - 1}_${y + info.height - 1})`); return [ 200, `Successfully loaded image wth ${pxlCount} pixels to ${x}/${y}`, @@ -207,7 +207,7 @@ export async function executeCleanerAction( return [403, error]; } // eslint-disable-next-line max-len - const report = `Set Canvas Cleaner to ${action} canvas ${canvas.ident} from ${ulcoor} to ${brcoor}`; + const report = `set Canvas Cleaner to ${action} from #${canvasid},${x},${y} to #${canvasid},${u},${v}`; if (logger) logger(report); return [200, report]; } @@ -269,9 +269,9 @@ export async function executeProtAction( logger( (protect) // eslint-disable-next-line max-len - ? `Protect ${width}x${height} area at #${canvasid},${x},${y} with ${pxlCount}pxls (${ulcoor} - ${brcoor})` + ? `protected ${width}x${height} area at #${canvasid},${x},${y} with ${pxlCount}pxls (${ulcoor} - ${brcoor})` // eslint-disable-next-line max-len - : `Unprotect ${width}x${height} area at #${canvasid},${x},${y} with ${pxlCount}pxls (${ulcoor} - ${brcoor})`, + : `unprotect ${width}x${height} area at #${canvasid},${x},${y} with ${pxlCount}pxls (${ulcoor} - ${brcoor})`, ); } return [ @@ -342,7 +342,7 @@ export async function executeRollback( if (logger) { logger( // eslint-disable-next-line max-len - `Rollback to ${date} for ${width}x${height} area at #${canvas.ident},${x},${y} with ${pxlCount}pxls (${ulcoor} - ${brcoor})`, + `rolled back to ${date} for ${width}x${height} area at #${canvas.ident},${x},${y} with ${pxlCount}pxls (${ulcoor} - ${brcoor})`, ); } return [ diff --git a/src/routes/api/modtools.js b/src/routes/api/modtools.js index f62647a..7000970 100644 --- a/src/routes/api/modtools.js +++ b/src/routes/api/modtools.js @@ -11,6 +11,7 @@ import type { Request, Response } from 'express'; import multer from 'multer'; import CanvasCleaner from '../../core/CanvasCleaner'; +import chatProvider from '../../core/ChatProvider'; import { getIPFromRequest } from '../../utils/ip'; import logger, { modtoolsLogger } from '../../core/logger'; import { @@ -75,9 +76,16 @@ router.use(async (req, res, next) => { router.post('/', upload.single('image'), async (req, res, next) => { const aLogger = (text) => { const timeString = new Date().toLocaleTimeString(); + const logText = `@${req.user.regUser.name}[${req.user.id}] ${text}`; modtoolsLogger.info( // eslint-disable-next-line max-len - `${timeString} | MODTOOLS> ${req.user.regUser.name}[${req.user.id}]> ${text}`, + `${timeString} | MODTOOLS> ${logText}`, + ); + chatProvider.broadcastChatMessage( + 'info', + logText, + chatProvider.enChannelId, + chatProvider.infoUserId, ); };