diff --git a/client/methods/pinMessage.coffee b/client/methods/pinMessage.coffee deleted file mode 100644 index a46e6bdde71..00000000000 --- a/client/methods/pinMessage.coffee +++ /dev/null @@ -1,21 +0,0 @@ -Meteor.methods - pinMessage: (message) -> - if not Meteor.userId() - throw new Meteor.Error 203, t('User_logged_out') - - if not RocketChat.settings.get 'Message_AllowPinning' - throw new Meteor.Error 'message-pinning-not-allowed', t('Message_pinning_not_allowed') - - Tracker.nonreactive -> - - message.pts = new Date(Date.now() + TimeSync.serverOffset()) - message.pinned = true - message = RocketChat.callbacks.run 'beforeSaveMessage', message - - ChatMessage.update - _id: message.id - 'u._id': Meteor.userId() - , - $set: - pinned: message.pinned - pts: message.pts diff --git a/client/methods/unpinMessage.coffee b/client/methods/unpinMessage.coffee deleted file mode 100644 index a60e28960e3..00000000000 --- a/client/methods/unpinMessage.coffee +++ /dev/null @@ -1,21 +0,0 @@ -Meteor.methods - unpinMessage: (message) -> - if not Meteor.userId() - throw new Meteor.Error 203, t('User_logged_out') - - if not RocketChat.settings.get 'Message_AllowPinning' - throw new Meteor.Error 'message-pinning-not-allowed', t('Message_pinning_not_allowed') - - Tracker.nonreactive -> - - message.pts = new Date(Date.now() + TimeSync.serverOffset()) - message.pinned = false - message = RocketChat.callbacks.run 'beforeSaveMessage', message - - ChatMessage.update - _id: message.id - 'u._id': Meteor.userId() - , - $set: - pinned: message.pinned - pts: message.pts diff --git a/packages/rocketchat-message-pin/client/actionButton.coffee b/packages/rocketchat-message-pin/client/actionButton.coffee index 82ae2968caf..c7c225c7c6a 100644 --- a/packages/rocketchat-message-pin/client/actionButton.coffee +++ b/packages/rocketchat-message-pin/client/actionButton.coffee @@ -4,8 +4,6 @@ Meteor.startup -> icon: 'icon-pin' i18nLabel: 'Pin_Message' action: (event, instance) -> - event.preventDefault() - event.stopPropagation() message = @_arguments[1] message.pinned = true Meteor.call 'pinMessage', message, (error, result) -> @@ -26,8 +24,6 @@ Meteor.startup -> icon: 'icon-eraser' i18nLabel: 'Unpin_Message' action: (event, instance) -> - event.preventDefault() - event.stopPropagation() message = @_arguments[1] message.pinned = false Meteor.call 'unpinMessage', message, (error, result) -> diff --git a/packages/rocketchat-message-pin/client/pinMessage.coffee b/packages/rocketchat-message-pin/client/pinMessage.coffee new file mode 100644 index 00000000000..7b934880ac4 --- /dev/null +++ b/packages/rocketchat-message-pin/client/pinMessage.coffee @@ -0,0 +1,26 @@ +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' + + + ChatMessage.update + _id: message._id + , + $set: { pinned: true } + + unpinMessage: (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' + + + ChatMessage.update + _id: message._id + , + $set: { pinned: false } diff --git a/packages/rocketchat-message-pin/package.js b/packages/rocketchat-message-pin/package.js index 0d6c5deec59..1bd59584268 100644 --- a/packages/rocketchat-message-pin/package.js +++ b/packages/rocketchat-message-pin/package.js @@ -17,6 +17,7 @@ Package.onUse(function(api) { api.addFiles([ 'client/lib/PinnedMessage.coffee', 'client/actionButton.coffee', + 'client/pinMessage.coffee', 'client/tabBar.coffee', 'client/views/pinnedMessages.html', 'client/views/pinnedMessages.coffee', diff --git a/packages/rocketchat-ui-message/message/message.coffee b/packages/rocketchat-ui-message/message/message.coffee index 144ec4a3223..3e1b3aef099 100644 --- a/packages/rocketchat-ui-message/message/message.coffee +++ b/packages/rocketchat-ui-message/message/message.coffee @@ -39,8 +39,6 @@ Template.message.helpers # otherwise a special "?" character that will be # rendered as a special avatar return @editedBy?.username or "?" - pinned: -> - return this.pinned canEdit: -> hasPermission = RocketChat.authz.hasAtLeastOnePermission('edit-message', this.rid) isEditAllowed = RocketChat.settings.get 'Message_AllowEditing' @@ -61,10 +59,6 @@ Template.message.helpers return true return RocketChat.settings.get('Message_AllowDeleting') and this.u?._id is Meteor.userId() - canPin: -> - return RocketChat.settings.get 'Message_AllowPinning' - canStar: -> - return RocketChat.settings.get 'Message_AllowStarring' showEditedStatus: -> return RocketChat.settings.get 'Message_ShowEditedStatus' label: -> diff --git a/packages/rocketchat-ui/views/app/room.coffee b/packages/rocketchat-ui/views/app/room.coffee index 88bc0282ed7..f7ea605894a 100644 --- a/packages/rocketchat-ui/views/app/room.coffee +++ b/packages/rocketchat-ui/views/app/room.coffee @@ -377,14 +377,6 @@ Template.room.events ChatMessage.update {_id: this._arguments[1]._id, 'urls.url': $(event.currentTarget).data('url')}, {$set: {'urls.$.downloadImages': true}} ChatMessage.update {_id: this._arguments[1]._id, 'attachments.image_url': $(event.currentTarget).data('url')}, {$set: {'attachments.$.downloadImages': true}} - 'click .pin-message': (event) -> - message = @_arguments[1] - instance = Template.instance() - if message.pinned - chatMessages[Session.get('openedRoom')].unpinMsg(message) - else - chatMessages[Session.get('openedRoom')].pinMsg(message) - 'dragenter .dropzone': (e) -> e.currentTarget.classList.add 'over'