gitlab-org--gitlab-foss/app/services/gravatar_service.rb
Dmitriy Zaporozhets d5b0f29c4a
Move gravatar url compose to separate service
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-06-13 17:11:46 +03:00

28 lines
539 B
Ruby

class GravatarService
def execute(email, size = nil)
if gravatar_config.enabled && email.present?
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