From 3d379b071d6b79a57d3e3ad5095c790a7abf356f Mon Sep 17 00:00:00 2001 From: Arman Date: Sun, 4 Oct 2020 16:25:22 +0530 Subject: [PATCH] feat: use gravatar if no avatar image (#1307) Fixes: #1240 --- app/models/user.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/models/user.rb b/app/models/user.rb index 33faa8ee6..45a87dac1 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -110,6 +110,15 @@ class User < ApplicationRecord inboxes.where(account_id: Current.account.id) end + alias avatar_img_url avatar_url + def avatar_url + if avatar_img_url == '' + hash = Digest::MD5.hexdigest(email) + return "https://www.gravatar.com/avatar/#{hash}" + end + avatar_img_url + end + def administrator? current_account_user&.administrator? end