Node.js based forum software built for the modern web
fix: #9398, crash on post flag
Barış Soner Uşaklı90d64fe1df5c
diff --git a/src/flags.js b/src/flags.jsindex 46674bff02..dce9656713 100644--- a/src/flags.js+++ b/src/flags.js@@ -440,7 +440,7 @@ Flags.create = async function (type, id, uid, reason, timestamp) {await Promise.all(batched);if (doHistoryAppend) {- Flags.update(flagId, uid, { state: 'open' });+ await Flags.update(flagId, uid, { state: 'open' });}const flagObj = await Flags.get(flagId);@@ -725,7 +725,7 @@ Flags.notify = async function (flagObj, uid) {notifObj = await notifications.create({type: 'new-post-flag',bodyShort: `[[notifications:user_flagged_post_in, ${flagObj.reports[flagObj.reports.length - 1].reporter.username}, ${titleEscaped}]]`,- bodyLong: await plugins.hooks.fire('filter:parse.raw', flagObj.description),+ bodyLong: await plugins.hooks.fire('filter:parse.raw', String(flagObj.description || '')),pid: flagObj.targetId,path: `/flags/${flagObj.flagId}`,nid: `flag:post:${flagObj.targetId}`,@@ -738,7 +738,7 @@ Flags.notify = async function (flagObj, uid) {notifObj = await notifications.create({type: 'new-user-flag',bodyShort: `[[notifications:user_flagged_user, ${flagObj.reports[flagObj.reports.length - 1].reporter.username}, ${flagObj.target.username}]]`,- bodyLong: await plugins.hooks.fire('filter:parse.raw', flagObj.description),+ bodyLong: await plugins.hooks.fire('filter:parse.raw', String(flagObj.description || '')),path: `/flags/${flagObj.flagId}`,nid: `flag:user:${flagObj.targetId}`,from: uid,diff --git a/src/groups/index.js b/src/groups/index.jsindex 0e3408ad1f..1f28e5f61f 100644--- a/src/groups/index.js+++ b/src/groups/index.js@@ -134,7 +134,7 @@ Groups.get = async function (groupName, options) {if (!groupData) {return null;}- const descriptionParsed = await plugins.hooks.fire('filter:parse.raw', groupData.description);+ const descriptionParsed = await plugins.hooks.fire('filter:parse.raw', String(groupData.description || ''));groupData.descriptionParsed = descriptionParsed;groupData.members = members;groupData.membersNextStart = stop + 1;diff --git a/src/messaging/index.js b/src/messaging/index.jsindex eaedcc3a11..2f90270b60 100644--- a/src/messaging/index.js+++ b/src/messaging/index.js@@ -64,7 +64,7 @@ async function canGet(hook, callerUid, uid) {}Messaging.parse = async (message, fromuid, uid, roomId, isNew) => {- const parsed = await plugins.hooks.fire('filter:parse.raw', message);+ const parsed = await plugins.hooks.fire('filter:parse.raw', String(message || ''));let messageData = {message: message,parsed: parsed,