added messaging hook #1798

v1.18.x
barisusakli 11 years ago
parent 75bf9e62be
commit 0f5c1d1892

@ -94,6 +94,9 @@ Executed when a post or signature needs to be parsed from raw text to HTML (for
``filter:post.parse`` ``filter:post.parse``
^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^
``filter:messaging.save``
^^^^^^^^^^^^^^^^^^^^^^^^
``filter:messaging.parse`` ``filter:messaging.parse``
^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^

@ -28,18 +28,24 @@ var db = require('./database'),
touid: touid touid: touid
}; };
db.setObject('message:' + mid, message, function(err) { plugins.fireHook('filter:messaging.save', message, function(err, message) {
if (err) { if (err) {
return callback(err); return callback(err);
} }
db.listAppend('messages:' + uids[0] + ':' + uids[1], mid); db.setObject('message:' + mid, message, function(err) {
if (err) {
return callback(err);
}
Messaging.updateChatTime(fromuid, touid); db.listAppend('messages:' + uids[0] + ':' + uids[1], mid);
Messaging.updateChatTime(touid, fromuid);
getMessages([mid], fromuid, touid, true, function(err, messages) { Messaging.updateChatTime(fromuid, touid);
callback(err, messages ? messages[0] : null); Messaging.updateChatTime(touid, fromuid);
getMessages([mid], fromuid, touid, true, function(err, messages) {
callback(err, messages ? messages[0] : null);
});
}); });
}); });
}); });

Loading…
Cancel
Save