Skip to content

Commit

Permalink
[webui] make gravatar usage optional since it is a potential privacy …
Browse files Browse the repository at this point in the history
…issue.
  • Loading branch information
adrianschroeter committed Oct 24, 2012
1 parent f31f52e commit b454f73
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/webui/app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,22 @@ def icon
Rails.cache.delete(key) if discard_cache?
content = Rails.cache.fetch(key, :expires_in => 5.hour) do

email = Person.email_for_login(user)
hash = Digest::MD5.hexdigest(email.downcase)
http = Net::HTTP.new("www.gravatar.com")
begin
http.start
response = http.get "/avatar/#{hash}?s=#{size}&d=wavatar" unless Rails.env.test?
if response.is_a?(Net::HTTPSuccess)
content = response.body
unless CONFIG['enable_gravatar'] == :off
email = Person.email_for_login(user)
hash = Digest::MD5.hexdigest(email.downcase)
http = Net::HTTP.new("www.gravatar.com")
begin
http.start
response = http.get "/avatar/#{hash}?s=#{size}&d=wavatar" unless Rails.env.test?
if response.is_a?(Net::HTTPSuccess)
content = response.body
end
rescue SocketError, Errno::EINTR, Errno::EPIPE, EOFError, Net::HTTPBadResponse, IOError, Errno::ETIMEDOUT, Errno::ECONNREFUSED => err
logger.debug "#{err} when fetching http://www.gravatar.com/avatar/#{hash}?s=#{size}"
http = nil
end
rescue SocketError, Errno::EINTR, Errno::EPIPE, EOFError, Net::HTTPBadResponse, IOError, Errno::ETIMEDOUT, Errno::ECONNREFUSED => err
logger.debug "#{err} when fetching http://www.gravatar.com/avatar/#{hash}?s=#{size}"
http = nil
http.finish if http
end
http.finish if http

unless content
#TODO/FIXME: Looks like an asset...
Expand Down
4 changes: 4 additions & 0 deletions src/webui/config/options.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ exception_recipients: []
# if the api runs against ldap (:on && :off)
#frontend_ldap_mode: :on

# enable gravatar icons in webui. This will tell www.gravatar.com the email adresses
# of your users.
#enable_gravatar: :off

# hostname of API
frontend_host: api.opensuse.org
# port of API
Expand Down

2 comments on commit b454f73

@coolo
Copy link
Member

@coolo coolo commented on b454f73 Oct 26, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you look at options.yml.example you will find that all other options are use_ or no prefix at all. Don't use enable_ as a 3rd option.

@adrianschroeter
Copy link
Member Author

@adrianschroeter adrianschroeter commented on b454f73 Oct 26, 2012 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.