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/app/custom-sounds/server/methods/deleteCustomSound.js

28 lines
856 B

import { Meteor } from 'meteor/meteor';
import { CustomSounds } from '../../../models';
import { hasPermission } from '../../../authorization';
import { Notifications } from '../../../notifications';
import { RocketChatFileCustomSoundsInstance } from '../startup/custom-sounds';
Meteor.methods({
deleteCustomSound(_id) {
let sound = null;
if (hasPermission(this.userId, 'manage-sounds')) {
sound = CustomSounds.findOneById(_id);
} else {
throw new Meteor.Error('not_authorized');
}
if (sound == null) {
throw new Meteor.Error('Custom_Sound_Error_Invalid_Sound', 'Invalid sound', { method: 'deleteCustomSound' });
}
RocketChatFileCustomSoundsInstance.deleteFile(`${ sound._id }.${ sound.extension }`);
CustomSounds.removeById(_id);
Notifications.notifyAll('deleteCustomSound', { soundData: sound });
return true;
},
});