Skip to content
Snippets Groups Projects
Commit 007390a4 authored by Rodrigo Nascimento's avatar Rodrigo Nascimento
Browse files

Move code to use originalMessage instead message

parent e9fbad71
No related merge requests found
......@@ -3,13 +3,14 @@ Meteor.methods
if not Meteor.userId()
throw new Meteor.Error('invalid-user', "[methods] deleteMessage -> Invalid user")
hasPermission = RocketChat.authz.hasPermission(Meteor.userId(), 'delete-message', message.rid)
deleteAllowed = RocketChat.settings.get 'Message_AllowDeleting'
originalMessage = ChatMessage.findOne message._id, {fields: {u: 1, rid: 1}}
if not originalMessage?
throw new Meteor.Error 'message-deleting-not-allowed', "[methods] deleteMessage -> Message with id [#{message._id} dos not exists]"
hasPermission = RocketChat.authz.hasPermission(Meteor.userId(), 'delete-message', originalMessage.rid)
deleteAllowed = RocketChat.settings.get 'Message_AllowDeleting'
deleteOwn = originalMessage?.u?._id is Meteor.userId()
unless hasPermission or (deleteAllowed and deleteOwn)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment