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.coffee

23 lines
675 B

Meteor.methods
resetAvatar:->
unless Meteor.userId()
throw new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'resetAvatar' });
unless RocketChat.settings.get("Accounts_AllowUserAvatarChange")
throw new Meteor.Error('error-not-allowed', 'Not allowed', { method: 'resetAvatar' });
user = Meteor.user()
RocketChatFileAvatarInstance.deleteFile "#{user.username}.jpg"
RocketChat.models.Users.unsetAvatarOrigin user._id
RocketChat.Notifications.notifyAll 'updateAvatar', {username: user.username}
return
# Limit changing avatar once per minute
DDPRateLimiter.addRule
type: 'method'
name: 'resetAvatar'
userId: -> return true
, 1, 60000