diff --git a/src/flags.js b/src/flags.js index 211496ce50..2522880760 100644 --- a/src/flags.js +++ b/src/flags.js @@ -807,9 +807,10 @@ Flags.notify = async function (flagObj, uid, notifySelf = false) { }); uids = uids.concat(modUids[0]); } else if (flagObj.type === 'user') { + const targetDisplayname = flagObj.target && flagObj.target.user ? flagObj.target.user.displayname : '[[global:guest]]'; notifObj = await notifications.create({ type: 'new-user-flag', - bodyShort: `[[notifications:user_flagged_user, ${displayname}, ${flagObj.target.user.displayname}]]`, + bodyShort: `[[notifications:user_flagged_user, ${displayname}, ${targetDisplayname}]]`, bodyLong: await plugins.hooks.fire('filter:parse.raw', String(flagObj.description || '')), path: `/flags/${flagObj.flagId}`, nid: `flag:user:${flagObj.targetId}`,