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-emoji-custom/server/methods/deleteEmojiCustom.js

22 lines
739 B

/* globals isSetNotNull, RocketChatFileEmojiCustomInstance */
Meteor.methods({
deleteEmojiCustom(emojiID) {
let emoji = null;
if (RocketChat.authz.hasPermission(this.userId, 'manage-emoji')) {
emoji = RocketChat.models.EmojiCustom.findOneByID(emojiID);
} else {
throw new Meteor.Error('not_authorized');
}
if (!isSetNotNull(() => emoji)) {
throw new Meteor.Error('Custom_Emoji_Error_Invalid_Emoji', 'Invalid emoji', { method: 'deleteEmojiCustom' });
}
RocketChatFileEmojiCustomInstance.deleteFile(encodeURIComponent(`${emoji.name}.${emoji.extension}`));
RocketChat.models.EmojiCustom.removeByID(emojiID);
RocketChat.Notifications.notifyLogged('deleteEmojiCustom', {emojiData: emoji});
return true;
}
});