Chat message soft deletion -- closes #6181

Squashed commit of the following:

commit f84c06bdcc45f24ef7ffde6a8f33b48d8f97fc36
Author: Julian Lam <julian@nodebb.org>
Date:   Mon Dec 18 14:42:47 2017 -0500

    added restore handler for chat messages

commit 725cd370c6ea1e8f4a28298350f3dc024d4e668e
Author: Julian Lam <julian@nodebb.org>
Date:   Mon Dec 18 14:23:52 2017 -0500

    backend logic and testing complete for deletion and restoration of chat messages

commit 072da758319cc93fa4c6f8bc0d672a1b716dc06e
Author: Julian Lam <julian@nodebb.org>
Date:   Mon Dec 18 13:52:35 2017 -0500

    changing message delete logic to not remove mids, but to filter when retrieving

commit 68bf373305ab82737658a7c31dc5549af4d6d69f
Author: Julian Lam <julian@nodebb.org>
Date:   Mon Dec 18 12:37:58 2017 -0500

    logic to handle deletion of a deleted chat message -- added some failing tests

commit 6899d0d234fa752e227188aa69cfcabd0d0500cc
Author: Julian Lam <julian@nodebb.org>
Date:   Mon Dec 18 11:35:36 2017 -0500

    chat message deletion logic
This commit is contained in:
Julian Lam
2017-12-18 14:45:06 -05:00
parent 541aa7fbc6
commit 82a95a03be
9 changed files with 142 additions and 35 deletions

View File

@@ -267,6 +267,21 @@ SocketModules.chats.delete = function (socket, data, callback) {
], callback);
};
SocketModules.chats.restore = function (socket, data, callback) {
if (!data || !data.roomId || !data.messageId) {
return callback(new Error('[[error:invalid-data]]'));
}
async.waterfall([
function (next) {
Messaging.canDelete(data.messageId, socket.uid, next);
},
function (next) {
Messaging.restoreMessage(data.messageId, data.roomId, next);
},
], callback);
};
SocketModules.chats.canMessage = function (socket, roomId, callback) {
Messaging.canMessageRoom(socket.uid, roomId, callback);
};