print moderation actions also in en chat

This commit is contained in:
HF 2022-06-25 14:49:04 +02:00
parent 8a8ac5fc35
commit 0e07d74afa
2 changed files with 14 additions and 6 deletions

View File

@ -155,7 +155,7 @@ export async function executeImageAction(
); );
// eslint-disable-next-line max-len // 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 [ return [
200, 200,
`Successfully loaded image wth ${pxlCount} pixels to ${x}/${y}`, `Successfully loaded image wth ${pxlCount} pixels to ${x}/${y}`,
@ -207,7 +207,7 @@ export async function executeCleanerAction(
return [403, error]; return [403, error];
} }
// eslint-disable-next-line max-len // 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); if (logger) logger(report);
return [200, report]; return [200, report];
} }
@ -269,9 +269,9 @@ export async function executeProtAction(
logger( logger(
(protect) (protect)
// eslint-disable-next-line max-len // 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 // 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 [ return [
@ -342,7 +342,7 @@ export async function executeRollback(
if (logger) { if (logger) {
logger( logger(
// eslint-disable-next-line max-len // 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 [ return [

View File

@ -11,6 +11,7 @@ import type { Request, Response } from 'express';
import multer from 'multer'; import multer from 'multer';
import CanvasCleaner from '../../core/CanvasCleaner'; import CanvasCleaner from '../../core/CanvasCleaner';
import chatProvider from '../../core/ChatProvider';
import { getIPFromRequest } from '../../utils/ip'; import { getIPFromRequest } from '../../utils/ip';
import logger, { modtoolsLogger } from '../../core/logger'; import logger, { modtoolsLogger } from '../../core/logger';
import { import {
@ -75,9 +76,16 @@ router.use(async (req, res, next) => {
router.post('/', upload.single('image'), async (req, res, next) => { router.post('/', upload.single('image'), async (req, res, next) => {
const aLogger = (text) => { const aLogger = (text) => {
const timeString = new Date().toLocaleTimeString(); const timeString = new Date().toLocaleTimeString();
const logText = `@${req.user.regUser.name}[${req.user.id}] ${text}`;
modtoolsLogger.info( modtoolsLogger.info(
// eslint-disable-next-line max-len // 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,
); );
}; };