Skip to content
Snippets Groups Projects
Commit c472555e authored by Marcelo Schmidt's avatar Marcelo Schmidt
Browse files

Fixed #611. Avatar should only show suggestions for enabled services.

parent b97231b4
No related branches found
No related tags found
No related merge requests found
......@@ -21,6 +21,11 @@ Template.avatarPrompt.helpers
suggestions: ->
return Template.instance().suggestions.get()
suggestAvatar: (service) ->
suggestions = Template.instance().suggestions.get()
console.log service, "Accounts_OAuth_#{_.capitalize service}", RocketChat.settings.get("Accounts_OAuth_#{_.capitalize service}"), suggestions
return RocketChat.settings.get("Accounts_OAuth_#{_.capitalize service}") and not suggestions.avatars[service]
upload: ->
return Template.instance().upload.get()
......
......@@ -64,22 +64,30 @@
{{> avatarSuggestion suggestions.avatars.facebook}}
{{> avatarSuggestion suggestions.avatars.google}}
{{> avatarSuggestion suggestions.avatars.github}}
{{> avatarSuggestion suggestions.avatars.gitlab}}
{{> avatarSuggestion suggestions.avatars.linkedin}}
{{> avatarSuggestion suggestions.avatars.twitter}}
{{#unless suggestions.avatars.facebook}}
{{#if suggestAvatar 'facebook'}}
{{> avatarSuggestionLogin 'facebook'}}
{{/unless}}
{{#unless suggestions.avatars.google}}
{{/if}}
{{#if suggestAvatar 'google'}}
{{> avatarSuggestionLogin 'google'}}
{{/unless}}
{{#unless suggestions.avatars.github}}
{{/if}}
{{#if suggestAvatar 'github'}}
{{> avatarSuggestionLogin 'github'}}
{{/unless}}
{{#unless suggestions.avatars.linkedin}}
{{/if}}
{{#if suggestAvatar 'gitlab'}}
{{> avatarSuggestionLogin 'gitlab'}}
{{/if}}
{{#if suggestAvatar 'linkedin'}}
{{> avatarSuggestionLogin 'linkedin'}}
{{/unless}}
{{/if}}
{{#if suggestAvatar 'twitter'}}
{{> avatarSuggestionLogin 'twitter'}}
{{/if}}
{{else}}
{{_ "Loading_suggestion"}}
{{/if}}
......
......@@ -12,25 +12,25 @@ RocketChat.settings.add 'Accounts_AvatarStorePath', '/var/www/rocket.chat/upload
RocketChat.settings.add 'Accounts_AvatarResize', false, { type: 'boolean', group: 'Accounts', section: 'Avatar' }
RocketChat.settings.add 'Accounts_AvatarSize', 200, { type: 'int', group: 'Accounts', section: 'Avatar' }
RocketChat.settings.add 'Accounts_OAuth_Facebook', false, { type: 'boolean', group: 'Accounts', section: 'Facebook' }
RocketChat.settings.add 'Accounts_OAuth_Facebook', false, { type: 'boolean', group: 'Accounts', section: 'Facebook', public: true }
RocketChat.settings.add 'Accounts_OAuth_Facebook_id', '', { type: 'string', group: 'Accounts', section: 'Facebook' }
RocketChat.settings.add 'Accounts_OAuth_Facebook_secret', '', { type: 'string', group: 'Accounts', section: 'Facebook' }
RocketChat.settings.add 'Accounts_OAuth_Google', false, { type: 'boolean', group: 'Accounts', section: 'Google' }
RocketChat.settings.add 'Accounts_OAuth_Google', false, { type: 'boolean', group: 'Accounts', section: 'Google', public: true }
RocketChat.settings.add 'Accounts_OAuth_Google_id', '', { type: 'string', group: 'Accounts', section: 'Google' }
RocketChat.settings.add 'Accounts_OAuth_Google_secret', '', { type: 'string', group: 'Accounts', section: 'Google' }
RocketChat.settings.add 'Accounts_OAuth_Github', false, { type: 'boolean', group: 'Accounts', section: 'Github' }
RocketChat.settings.add 'Accounts_OAuth_Github', false, { type: 'boolean', group: 'Accounts', section: 'Github', public: true }
RocketChat.settings.add 'Accounts_OAuth_Github_id', '', { type: 'string', group: 'Accounts', section: 'Github' }
RocketChat.settings.add 'Accounts_OAuth_Github_secret', '', { type: 'string', group: 'Accounts', section: 'Github' }
RocketChat.settings.add 'Accounts_OAuth_Gitlab', false, { type: 'boolean', group: 'Accounts', section: 'Gitlab' }
RocketChat.settings.add 'Accounts_OAuth_Gitlab', false, { type: 'boolean', group: 'Accounts', section: 'Gitlab', public: true }
RocketChat.settings.add 'Accounts_OAuth_Gitlab_id', '', { type: 'string', group: 'Accounts', section: 'Gitlab' }
RocketChat.settings.add 'Accounts_OAuth_Gitlab_secret', '', { type: 'string', group: 'Accounts', section: 'Gitlab' }
RocketChat.settings.add 'Accounts_OAuth_Linkedin', false, { type: 'boolean', group: 'Accounts', section: 'Linkedin' }
RocketChat.settings.add 'Accounts_OAuth_Linkedin', false, { type: 'boolean', group: 'Accounts', section: 'Linkedin', public: true }
RocketChat.settings.add 'Accounts_OAuth_Linkedin_id', '', { type: 'string', group: 'Accounts', section: 'Linkedin' }
RocketChat.settings.add 'Accounts_OAuth_Linkedin_secret', '', { type: 'string', group: 'Accounts', section: 'Linkedin' }
RocketChat.settings.add 'Accounts_OAuth_Meteor', false, { type: 'boolean', group: 'Accounts', section: 'Meteor' }
RocketChat.settings.add 'Accounts_OAuth_Meteor', false, { type: 'boolean', group: 'Accounts', section: 'Meteor', public: true }
RocketChat.settings.add 'Accounts_OAuth_Meteor_id', '', { type: 'string', group: 'Accounts', section: 'Meteor' }
RocketChat.settings.add 'Accounts_OAuth_Meteor_secret', '', { type: 'string', group: 'Accounts', section: 'Meteor' }
RocketChat.settings.add 'Accounts_OAuth_Twitter', false, { type: 'boolean', group: 'Accounts', section: 'Twitter' }
RocketChat.settings.add 'Accounts_OAuth_Twitter', false, { type: 'boolean', group: 'Accounts', section: 'Twitter', public: true }
RocketChat.settings.add 'Accounts_OAuth_Twitter_id', '', { type: 'string', group: 'Accounts', section: 'Twitter' }
RocketChat.settings.add 'Accounts_OAuth_Twitter_secret', '', { type: 'string', group: 'Accounts', section: 'Twitter' }
......@@ -98,4 +98,4 @@ Meteor.startup ->
if process?.env? and not process.env['MAIL_URL']? and RocketChat.settings.get('SMTP_Host') and RocketChat.settings.get('SMTP_Username') and RocketChat.settings.get('SMTP_Password')
process.env['MAIL_URL'] = "smtp://" + encodeURIComponent(RocketChat.settings.get('SMTP_Username')) + ':' + encodeURIComponent(RocketChat.settings.get('SMTP_Password')) + '@' + encodeURIComponent(RocketChat.settings.get('SMTP_Host'))
if RocketChat.settings.get('SMTP_Port')
process.env['MAIL_URL'] += ':' + parseInt(RocketChat.settings.get('SMTP_Port'))
\ No newline at end of file
process.env['MAIL_URL'] += ':' + parseInt(RocketChat.settings.get('SMTP_Port'))
@getAvatarSuggestionForUser = (user) ->
avatars = []
if user.services.facebook?.id?
if user.services.facebook?.id? and RocketChat.settings.get 'Accounts_OAuth_Facebook'
avatars.push
service: 'facebook'
url: "https://graph.facebook.com/#{user.services.facebook.id}/picture?type=large"
if user.services.google?.picture? and user.services.google.picture isnt "https://lh3.googleusercontent.com/-XdUIqdMkCWA/AAAAAAAAAAI/AAAAAAAAAAA/4252rscbv5M/photo.jpg"
if user.services.google?.picture? and user.services.google.picture isnt "https://lh3.googleusercontent.com/-XdUIqdMkCWA/AAAAAAAAAAI/AAAAAAAAAAA/4252rscbv5M/photo.jpg" and RocketChat.settings.get 'Accounts_OAuth_Google'
avatars.push
service: 'google'
url: user.services.google.picture
if user.services.github?.username?
if user.services.github?.username? and RocketChat.settings.get 'Accounts_OAuth_Github'
avatars.push
service: 'github'
url: "https://avatars.githubusercontent.com/#{user.services.github.username}?s=200"
if user.services.linkedin?.pictureUrl?
if user.services.linkedin?.pictureUrl? and RocketChat.settings.get 'Accounts_OAuth_Linkedin'
avatars.push
service: 'linkedin'
url: user.services.linkedin.pictureUrl
if user.services.twitter?.profile_image_url_https? and RocketChat.settings.get 'Accounts_OAuth_Twitter'
avatars.push
service: 'twitter'
url: user.services.twitter.profile_image_url_https
if user.services.gitlab?.avatar_url? and RocketChat.settings.get 'Accounts_OAuth_Gitlab'
avatars.push
service: 'gitlab'
url: user.services.gitlab.avatar_url
if user.emails?.length > 0
for email in user.emails when email.verified is true
avatars.push
......@@ -37,7 +47,7 @@
try
result = HTTP.get avatar.url, npmRequestOptions: {encoding: 'binary'}
if result.statusCode is 200
blob = "data:#{result.headers['content-type']};base64,"
blob = "data:#{result.headers['content-type']};base64,"
blob += Buffer(result.content, 'binary').toString('base64')
avatar.blob = blob
avatar.contentType = result.headers['content-type']
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment