mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-07-05 23:38:54 +02:00
creating notification for flag assignment
This commit is contained in:
@@ -44,6 +44,7 @@
|
||||
"user_started_following_you_multiple": "<strong>%1</strong> and %2 others started following you.",
|
||||
"new_register": "<strong>%1</strong> sent a registration request.",
|
||||
"new_register_multiple": "There are <strong>%1</strong> registration requests awaiting review.",
|
||||
"flag_assigned_to_you": "<strong>Flag %1</strong> has been assigned to you",
|
||||
|
||||
"email-confirmed": "Email Confirmed",
|
||||
"email-confirmed-message": "Thank you for validating your email. Your account is now fully activated.",
|
||||
|
||||
22
src/flags.js
22
src/flags.js
@@ -439,6 +439,27 @@ Flags.update = function (flagId, uid, changeset, callback) {
|
||||
var fields = ['state', 'assignee'];
|
||||
var tasks = [];
|
||||
var now = changeset.datetime || Date.now();
|
||||
var notifyAssignee = function (assigneeId, next) {
|
||||
if (assigneeId === '') {
|
||||
// Do nothing
|
||||
return next();
|
||||
}
|
||||
// Notify assignee of this update
|
||||
notifications.create({
|
||||
type: 'my-flags',
|
||||
bodyShort: '[[notifications:flag_assigned_to_you, ' + flagId + ']]',
|
||||
bodyLong: '',
|
||||
path: '/flags/' + flagId,
|
||||
nid: 'flags:assign:' + flagId + ':uid:' + assigneeId,
|
||||
from: uid,
|
||||
}, function (err, notification) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
notifications.push(notification, [assigneeId], next);
|
||||
});
|
||||
};
|
||||
|
||||
async.waterfall([
|
||||
async.apply(db.getObjectFields.bind(db), 'flag:' + flagId, fields),
|
||||
@@ -457,6 +478,7 @@ Flags.update = function (flagId, uid, changeset, callback) {
|
||||
|
||||
case 'assignee':
|
||||
tasks.push(async.apply(db.sortedSetAdd.bind(db), 'flags:byAssignee:' + changeset[prop], now, flagId));
|
||||
tasks.push(async.apply(notifyAssignee, changeset[prop]));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user