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

28 lines
829 B

Meteor.methods
setAvatarFromService: (dataURI, service) ->
if not Meteor.userId()
throw new Meteor.Error 203, '[methods] typingStatus -> Usuário não logado'
user = Meteor.user()
{image, contentType} = RocketFile.dataURIParse dataURI
rs = RocketFile.bufferToStream new Buffer(image, 'base64')
ws = RocketFileAvatarInstance.createWriteStream "#{user.username}.jpg", contentType
ws.on 'end', Meteor.bindEnvironment ->
Meteor.users.update {_id: user._id}, {$set: {avatarOrigin: service}}
rs.pipe(ws)
return
resetAvatar: (image, service) ->
if not Meteor.userId()
throw new Meteor.Error 203, '[methods] typingStatus -> Usuário não logado'
user = Meteor.user()
RocketFileAvatarInstance.deleteFile "#{user.username}.jpg"
Meteor.users.update user._id, {$unset: {avatarOrigin: 1}}
return