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/apps/meteor/app/user-status/server/methods/deleteCustomUserStatus.ts

31 lines
1.1 KiB

import { Meteor } from 'meteor/meteor';
import { CustomUserStatus } from '@rocket.chat/models';
import { api } from '@rocket.chat/core-services';
import type { ServerMethods } from '@rocket.chat/ui-contexts';
import { hasPermissionAsync } from '../../../authorization/server/functions/hasPermission';
declare module '@rocket.chat/ui-contexts' {
// eslint-disable-next-line @typescript-eslint/naming-convention
interface ServerMethods {
deleteCustomUserStatus(userStatusID: string): Promise<boolean>;
}
}
Meteor.methods<ServerMethods>({
async deleteCustomUserStatus(userStatusID) {
if (!this.userId || !(await hasPermissionAsync(this.userId, 'manage-user-status'))) {
throw new Meteor.Error('not_authorized');
}
const userStatus = await CustomUserStatus.findOneById(userStatusID);
if (userStatus == null) {
throw new Meteor.Error('Custom_User_Status_Error_Invalid_User_Status', 'Invalid user status', { method: 'deleteCustomUserStatus' });
}
await CustomUserStatus.removeById(userStatusID);
void api.broadcast('user.deleteCustomStatus', userStatus);
return true;
},
});