Skip to content

Commit

Permalink
fix: #9398, crash on post flag
Browse files Browse the repository at this point in the history
  • Loading branch information
barisusakli committed Mar 15, 2021
1 parent 8d3ec23 commit 90d64fe
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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}`,
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/groups/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/messaging/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 90d64fe

Please sign in to comment.