mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-06 22:15:48 +01:00
first pass #1720, updating existing calls to notifications.create, backwards compatibility in case plugins create notifications too.
This commit is contained in:
@@ -85,18 +85,32 @@ var async = require('async'),
|
||||
|
||||
// Add default values to data Object if not already set
|
||||
var defaults = {
|
||||
text: '',
|
||||
body: {
|
||||
short: '',
|
||||
long: ''
|
||||
},
|
||||
path: '',
|
||||
importance: 5,
|
||||
datetime: Date.now(),
|
||||
uniqueId: utils.generateUUID()
|
||||
};
|
||||
|
||||
for(var v in defaults) {
|
||||
if (defaults.hasOwnProperty(v) && !data[v]) {
|
||||
data[v] = defaults[v];
|
||||
}
|
||||
}
|
||||
|
||||
// Backwards compatibility for old notification syntax
|
||||
// Remove this block for NodeBB v0.6.0
|
||||
if (data.hasOwnProperty('text') && !data.hasOwnProperty('body')) {
|
||||
data.body = {
|
||||
short: data.text,
|
||||
long: ''
|
||||
};
|
||||
delete data.text;
|
||||
}
|
||||
|
||||
db.incrObjectField('global', 'nextNid', function(err, nid) {
|
||||
data.nid = nid;
|
||||
db.setAdd('notifications', nid);
|
||||
|
||||
Reference in New Issue
Block a user