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

30 lines
889 B

import { Meteor } from 'meteor/meteor';
import { CustomSounds } from '../../../models/server/raw';
import { hasPermission } from '../../../authorization';
import { Notifications } from '../../../notifications';
import { RocketChatFileCustomSoundsInstance } from '../startup/custom-sounds';
Meteor.methods({
async deleteCustomSound(_id) {
let sound = null;
if (hasPermission(this.userId, 'manage-sounds')) {
sound = await 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}`);
await CustomSounds.removeById(_id);
Notifications.notifyAll('deleteCustomSound', { soundData: sound });
return true;
},
});