diff --git a/src/posts/queue.js b/src/posts/queue.js index 57e6951f3f..0d97a0046f 100644 --- a/src/posts/queue.js +++ b/src/posts/queue.js @@ -2,6 +2,7 @@ const _ = require('lodash'); const validator = require('validator'); +const nconf = require('nconf'); const db = require('../database'); const user = require('../user'); @@ -149,12 +150,14 @@ module.exports = function (Posts) { const cid = await getCid(type, data); const uids = await getNotificationUids(cid); + const bodyLong = await parseBodyLong(cid, type, data); + const notifObj = await notifications.create({ type: 'post-queue', nid: `post-queue-${id}`, mergeId: 'post-queue', bodyShort: '[[notifications:post_awaiting_review]]', - bodyLong: await plugins.hooks.fire('filter:parse.raw', data.content), + bodyLong: bodyLong, path: '/post-queue', }); await notifications.push(notifObj, uids); @@ -166,6 +169,33 @@ module.exports = function (Posts) { }; }; + async function parseBodyLong(cid, type, data) { + const url = nconf.get('url'); + const [content, category, userData] = await Promise.all([ + plugins.hooks.fire('filter:parse.raw', data.content), + categories.getCategoryFields(cid, ['name', 'slug']), + user.getUserFields(data.uid, ['uid', 'username']), + ]); + + category.url = `${url}/category/${category.slug}`; + if (userData.uid > 0) { + userData.url = `${url}/uid/${userData.uid}`; + } + + const topic = { cid: cid, title: data.title, tid: data.tid }; + if (type === 'reply') { + topic.title = await topics.getTopicField(data.tid, 'title'); + topic.url = `${url}/topic/${data.tid}`; + } + const { app } = require('../webserver'); + return await app.renderAsync('emails/partials/post-queue-body', { + content: content, + category: category, + user: userData, + topic: topic, + }); + } + async function getCid(type, data) { if (type === 'topic') { return data.cid; diff --git a/src/views/emails/partials/post-queue-body.tpl b/src/views/emails/partials/post-queue-body.tpl new file mode 100644 index 0000000000..74eccc3b0f --- /dev/null +++ b/src/views/emails/partials/post-queue-body.tpl @@ -0,0 +1,9 @@ +
[[post-queue:category]]
+ + +{{{ if topic.tid }}}[[post-queue:topic]]{{{ else }}}[[post-queue:title]]{{{ end }}}
+{{{ if topic.url }}}{topic.title}{{{ else }}}{topic.title}{{{ end }}}
+ +[[post-queue:user]]
+{{{ if user.url }}}{user.username}{{{ else }}}{user.username}{{{ end }}}
+{content}