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/server/methods/resetAvatar.js

30 lines
695 B

Meteor.methods({
resetAvatar() {
if (!Meteor.userId()) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', {
method: 'resetAvatar'
});
}
if (!RocketChat.settings.get('Accounts_AllowUserAvatarChange')) {
throw new Meteor.Error('error-not-allowed', 'Not allowed', {
method: 'resetAvatar'
});
}
const user = Meteor.user();
RocketChatFileAvatarInstance.deleteFile(`${ user.username }.jpg`);
RocketChat.models.Users.unsetAvatarOrigin(user._id);
RocketChat.Notifications.notifyLogged('updateAvatar', {
username: user.username
});
}
});
DDPRateLimiter.addRule({
type: 'method',
name: 'resetAvatar',
userId() {
return true;
}
}, 1, 60000);