|
|
|
@ -9,18 +9,17 @@ Meteor.startup(function() { |
|
|
|
|
action() { |
|
|
|
|
const message = this._arguments[1]; |
|
|
|
|
message.pinned = true; |
|
|
|
|
return Meteor.call('pinMessage', message, function(error) { |
|
|
|
|
Meteor.call('pinMessage', message, function(error) { |
|
|
|
|
if (error) { |
|
|
|
|
return handleError(error); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
condition(message) { |
|
|
|
|
if (RocketChat.models.Subscriptions.findOne({ rid: message.rid }) == null) { |
|
|
|
|
return false; |
|
|
|
|
} else if (message.pinned || !RocketChat.settings.get('Message_AllowPinning')) { |
|
|
|
|
if (!RocketChat.settings.get('Message_AllowPinning') || message.pinned || !RocketChat.models.Subscriptions.findOne({ rid: message.rid }, {fields: {_id: 1}})) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return RocketChat.authz.hasAtLeastOnePermission('pin-message', message.rid); |
|
|
|
|
}, |
|
|
|
|
order: 20, |
|
|
|
@ -35,18 +34,18 @@ Meteor.startup(function() { |
|
|
|
|
action() { |
|
|
|
|
const message = this._arguments[1]; |
|
|
|
|
message.pinned = false; |
|
|
|
|
return Meteor.call('unpinMessage', message, function(error) { |
|
|
|
|
Meteor.call('unpinMessage', message, function(error) { |
|
|
|
|
if (error) { |
|
|
|
|
return handleError(error); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
condition(message) { |
|
|
|
|
if ((RocketChat.models.Subscriptions.findOne({ rid: message.rid }) == null) && (!message.pinned || !RocketChat.settings.get('Message_AllowPinning'))) { |
|
|
|
|
if (!RocketChat.settings.get('Message_AllowPinning') || !message.pinned || !RocketChat.models.Subscriptions.findOne({ rid: message.rid }, {fields: {_id: 1}})) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
RocketChat.authz.hasAtLeastOnePermission('pin-message', message.rid); |
|
|
|
|
return RocketChat.authz.hasAtLeastOnePermission('pin-message', message.rid); |
|
|
|
|
}, |
|
|
|
|
order: 21, |
|
|
|
|
group: 'menu' |
|
|
|
@ -54,19 +53,18 @@ Meteor.startup(function() { |
|
|
|
|
|
|
|
|
|
RocketChat.MessageAction.addButton({ |
|
|
|
|
id: 'jump-to-pin-message', |
|
|
|
|
icon: 'right-hand', |
|
|
|
|
icon: 'jump', |
|
|
|
|
label: 'Jump_to_message', |
|
|
|
|
context: ['pinned'], |
|
|
|
|
action() { |
|
|
|
|
const message = this._arguments[1]; |
|
|
|
|
RocketChat.MessageAction.hideDropDown(); |
|
|
|
|
if (window.matchMedia('(max-width: 500px)').matches) { |
|
|
|
|
Template.instance().tabBar.close(); |
|
|
|
|
} |
|
|
|
|
return RoomHistoryManager.getSurroundingMessages(message, 50); |
|
|
|
|
}, |
|
|
|
|
condition(message) { |
|
|
|
|
if (RocketChat.models.Subscriptions.findOne({ rid: message.rid }) == null) { |
|
|
|
|
if (!RocketChat.models.Subscriptions.findOne({ rid: message.rid }, {fields: {_id: 1}})) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
@ -77,18 +75,17 @@ Meteor.startup(function() { |
|
|
|
|
|
|
|
|
|
RocketChat.MessageAction.addButton({ |
|
|
|
|
id: 'permalink-pinned', |
|
|
|
|
icon: 'link', |
|
|
|
|
icon: 'permalink', |
|
|
|
|
label: 'Permalink', |
|
|
|
|
classes: 'clipboard', |
|
|
|
|
context: ['pinned'], |
|
|
|
|
action(event) { |
|
|
|
|
const message = this._arguments[1]; |
|
|
|
|
RocketChat.MessageAction.hideDropDown(); |
|
|
|
|
$(event.currentTarget).attr('data-clipboard-text', RocketChat.MessageAction.getPermaLink(message._id)); |
|
|
|
|
toastr.success(TAPi18n.__('Copied')); |
|
|
|
|
}, |
|
|
|
|
condition(message) { |
|
|
|
|
if (RocketChat.models.Subscriptions.findOne({ rid: message.rid }) == null) { |
|
|
|
|
if (!RocketChat.models.Subscriptions.findOne({ rid: message.rid }, {fields: {_id: 1}})) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|