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/packages/rocketchat-message-snippet/client/actionButton.js

37 lines
1.0 KiB

Meteor.startup(function() {
RocketChat.MessageAction.addButton({
id: "snippeted-message",
icon: "icon-code",
i18nnLabel: 'Snippet',
context: [
'snippeted',
'message',
'message-mobile'
],
action: function(event, instance) {
let message = this._arguments[1];
message.snippeted = true;
Meteor.call('snippetMessage', message, function(error, result) {
if (error) {
return handleError(error);
}
})
},
validation: function(message) {
let room = RocketChat.models.Rooms.findOne({_id: message.rid});
if (Array.isArray(room.usernames) && (room.usernames.indexOf(Meteor.user().username) == -1)) {
console.log("Nope Array");
return false;
} else {
if (message.snippeted || ((typeof RocketChat.settings.get('Message_AllowSnippeting') == "undefined") ||
(RocketChat.settings.get("Message_AllowSnippeting") == null))) {
return false;
} else {
return RocketChat.authz.hasAtLeastOnePermission('snippet-message', message.rid);
}
}
}
});
});