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/server/methods/pinMessage.coffee

23 lines
933 B

Meteor.methods
pinMessage: (message) ->
if not Meteor.userId()
throw new Meteor.Error('invalid-user', "[methods] pinMessage -> Invalid user")
if not RocketChat.settings.get 'Message_AllowPinning'
throw new Meteor.Error 'message-pinning-not-allowed', "[methods] pinMessage -> Message pinning not allowed"
console.log '[methods] pinMessage -> '.green, 'userId:', Meteor.userId(), 'arguments:', arguments
# If we keep history of edits, insert a new message to store history information
if RocketChat.settings.get 'Message_KeepHistory'
RocketChat.models.Messages.cloneAndSaveAsHistoryById message._id
message.pinned = true
message = RocketChat.callbacks.run 'beforeSaveMessage', message
RocketChat.models.Messages.setPinnedByIdAndUserId message._id, Meteor.userId(), message.pinned
# Meteor.defer ->
# RocketChat.callbacks.run 'afterSaveMessage', RocketChat.models.Messages.findOneById(message.id)