The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/client/methods/deleteMessage.coffee

24 lines
835 B

Meteor.methods
deleteMessage: (message) ->
if not Meteor.userId()
return false
hasPermission = RocketChat.authz.hasAtLeastOnePermission('delete-message', message.rid)
deleteAllowed = RocketChat.settings.get 'Message_AllowDeleting'
deleteOwn = message?.u?._id is Meteor.userId()
unless hasPermission or (deleteAllowed and deleteOwn)
return false
blockDeleteInMinutes = RocketChat.settings.get 'Message_AllowDeleting_BlockDeleteInMinutes'
if blockDeleteInMinutes? and blockDeleteInMinutes isnt 0
msgTs = moment(message.ts) if message.ts?
currentTsDiff = moment().diff(msgTs, 'minutes') if msgTs?
if currentTsDiff > blockDeleteInMinutes
toastr.error t('error-message-deleting-blocked')
return false
Tracker.nonreactive ->
ChatMessage.remove
_id: message._id
'u._id': Meteor.userId()