2014-09-02 18:07:02 +05:30
|
|
|
class GravatarService
|
2015-04-26 12:48:37 +05:30
|
|
|
include Gitlab::CurrentSettings
|
|
|
|
|
2014-09-02 18:07:02 +05:30
|
|
|
def execute(email, size = nil)
|
2015-04-26 12:48:37 +05:30
|
|
|
if current_application_settings.gravatar_enabled? && email.present?
|
2014-09-02 18:07:02 +05:30
|
|
|
size = 40 if size.nil? || size <= 0
|
|
|
|
|
|
|
|
sprintf gravatar_url,
|
|
|
|
hash: Digest::MD5.hexdigest(email.strip.downcase),
|
|
|
|
size: size,
|
|
|
|
email: email.strip
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def gitlab_config
|
|
|
|
Gitlab.config.gitlab
|
|
|
|
end
|
|
|
|
|
|
|
|
def gravatar_config
|
|
|
|
Gitlab.config.gravatar
|
|
|
|
end
|
|
|
|
|
|
|
|
def gravatar_url
|
|
|
|
if gitlab_config.https
|
|
|
|
gravatar_config.ssl_url
|
|
|
|
else
|
|
|
|
gravatar_config.plain_url
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|