mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 11:05:54 +01:00 
			
		
		
		
	feat: parse moderation notes as markdown
https://github.com/NodeBB/NodeBB/issues/12477
This commit is contained in:
		| @@ -13,20 +13,13 @@ define('forum/account/info', ['forum/account/header', 'alerts', 'forum/account/s | ||||
| 	function handleModerationNote() { | ||||
| 		$('[component="account/save-moderation-note"]').on('click', function () { | ||||
| 			const note = $('[component="account/moderation-note"]').val(); | ||||
| 			socket.emit('user.setModerationNote', { uid: ajaxify.data.uid, note: note }, function (err) { | ||||
| 			socket.emit('user.setModerationNote', { uid: ajaxify.data.uid, note: note }, function (err, notes) { | ||||
| 				if (err) { | ||||
| 					return alerts.error(err); | ||||
| 				} | ||||
| 				$('[component="account/moderation-note"]').val(''); | ||||
| 				alerts.success('[[user:info.moderation-note.success]]'); | ||||
| 				const timestamp = Date.now(); | ||||
| 				const data = [{ | ||||
| 					note: utils.escapeHTML(note), | ||||
| 					user: app.user, | ||||
| 					timestamp: timestamp, | ||||
| 					timestampISO: utils.toISOString(timestamp), | ||||
| 				}]; | ||||
| 				app.parseAndTranslate('account/info', 'moderationNotes', { moderationNotes: data }, function (html) { | ||||
|  | ||||
| 				app.parseAndTranslate('account/info', 'moderationNotes', { moderationNotes: notes }, function (html) { | ||||
| 					$('[component="account/moderation-note/list"]').prepend(html); | ||||
| 					html.find('.timeago').timeago(); | ||||
| 				}); | ||||
|   | ||||
| @@ -152,6 +152,7 @@ SocketUser.setModerationNote = async function (socket, data) { | ||||
| 	} | ||||
|  | ||||
| 	await user.appendModerationNote({ uid: data.uid, noteData }); | ||||
| 	return await user.getModerationNotes(data.uid, 0, 0); | ||||
| }; | ||||
|  | ||||
| SocketUser.deleteUpload = async function (socket, data) { | ||||
|   | ||||
| @@ -7,6 +7,7 @@ const db = require('../database'); | ||||
| const posts = require('../posts'); | ||||
| const topics = require('../topics'); | ||||
| const utils = require('../utils'); | ||||
| const plugins = require('../plugins'); | ||||
| const Flags = require('../flags'); | ||||
|  | ||||
| module.exports = function (User) { | ||||
| @@ -114,22 +115,20 @@ module.exports = function (User) { | ||||
| 		const notes = await db.getObjects(keys); | ||||
| 		const uids = []; | ||||
|  | ||||
| 		const noteData = notes.map((note) => { | ||||
| 		notes.forEach((note) => { | ||||
| 			if (note) { | ||||
| 				uids.push(note.uid); | ||||
| 				note.timestampISO = utils.toISOString(note.timestamp); | ||||
| 				note.note = validator.escape(String(note.note)); | ||||
| 			} | ||||
| 			return note; | ||||
| 		}); | ||||
|  | ||||
| 		const userData = await User.getUsersFields(uids, ['uid', 'username', 'userslug', 'picture']); | ||||
| 		noteData.forEach((note, index) => { | ||||
| 		await Promise.all(notes.map(async (note, index) => { | ||||
| 			if (note) { | ||||
| 				note.note = await plugins.hooks.fire('filter:parse.raw', String(note.note)); | ||||
| 				note.user = userData[index]; | ||||
| 			} | ||||
| 		}); | ||||
| 		return noteData; | ||||
| 		})); | ||||
| 		return notes; | ||||
| 	}; | ||||
|  | ||||
| 	User.appendModerationNote = async ({ uid, noteData }) => { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user