Commit d5b0f29c4a3a9d7da849d91a16f70bd494831da7

Authored by Dmitriy Zaporozhets
1 parent 273093a9

Move gravatar url compose to separate service

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Showing 1 changed file with 28 additions and 0 deletions   Show diff stats
app/services/gravatar_service.rb 0 → 100644
... ... @@ -0,0 +1,28 @@
  1 +class GravatarService
  2 + def execute(email, size = nil)
  3 + if gravatar_config.enabled && email.present?
  4 + size = 40 if size.nil? || size <= 0
  5 +
  6 + sprintf gravatar_url,
  7 + hash: Digest::MD5.hexdigest(email.strip.downcase),
  8 + size: size,
  9 + email: email.strip
  10 + end
  11 + end
  12 +
  13 + def gitlab_config
  14 + Gitlab.config.gitlab
  15 + end
  16 +
  17 + def gravatar_config
  18 + Gitlab.config.gravatar
  19 + end
  20 +
  21 + def gravatar_url
  22 + if gitlab_config.https
  23 + gravatar_config.ssl_url
  24 + else
  25 + gravatar_config.plain_url
  26 + end
  27 + end
  28 +end
... ...