\
#{truncate(message.strip, length: len)} \
@@ -95,6 +98,7 @@ module ApplicationHelper
annotated_users.uniq.each do |user_id|
target_user = User.find_by_id(user_id)
next unless target_user
+
generate_annotation_notification(target_user, title, message)
end
end
@@ -105,9 +109,7 @@ module ApplicationHelper
title: sanitize_input(title),
message: sanitize_input(message)
)
- if target_user.assignments_notification
- UserNotification.create(notification: notification, user: target_user)
- end
+ UserNotification.create(notification: notification, user: target_user) if target_user.assignments_notification
end
def smart_annotation_parser(text, team = nil)
@@ -133,6 +135,7 @@ module ApplicationHelper
match = el.match(sa_user)
user = User.find_by_id(match[2].base62_decode)
next unless user
+
popover_for_user_name(user, team)
end
new_text
@@ -172,9 +175,9 @@ module ApplicationHelper
html = if skip_avatar
''
else
- raw("
")
+ " ref='#{'missing-img' if missing_avatar(user, :icon_small)}'>")
end
html =
@@ -185,36 +188,28 @@ module ApplicationHelper
'data-placement="top" data-toggle="popover" data-content="') +
raw(user_description) + raw('" >') + user_name + raw('')
- unless skip_user_status || user_still_in_team
- html << " #{I18n.t('atwho.res.removed')}"
- end
+ html << " #{I18n.t('atwho.res.removed')}" unless skip_user_status || user_still_in_team
+ html = '
' + html + ''
html
end
- # Dirty, dirty hack for displaying images in reports
+ # No more dirty hack
def user_avatar_absolute_url(user, style)
- prefix = ''
- if ENV['PAPERCLIP_STORAGE'].present? &&
- ENV['MAIL_SERVER_URL'].present? &&
- ENV['PAPERCLIP_STORAGE'] != 'filesystem'
- prefix = ENV['MAIL_SERVER_URL']
+ begin
+ unless missing_avatar(user, style)
+ image = if user.avatar.options[:storage].to_sym == :s3
+ URI.parse(user.avatar.url(style)).open.to_a.join
+ else
+ File.open(user.avatar.path(style)).to_a.join
+ end
+ encoded_data = Base64.strict_encode64(image)
+ avatar_base64 = "data:#{user.avatar_content_type};base64,#{encoded_data}"
+ return avatar_base64
+ end
+ rescue StandardError => e
+ Rails.logger.error e.message
end
- # for development
- prefix = 'localhost:3000' if ENV['MAIL_SERVER_URL'] == 'localhost'
- if !prefix.empty? &&
- !prefix.include?('http://') &&
- !prefix.include?('https://')
- prefix = if respond_to?(:request) && request.ssl?
- "https://#{prefix}"
- else
- "http://#{prefix}"
- end
- end
-
- unless missing_avatar(user, style)
- return user.avatar(style, timeout: Constants::URL_LONG_EXPIRE_TIME)
- end
- url_for(prefix + "/images/#{style}/missing.png")
+ url_for("/images/#{style}/missing.png")
end
def missing_avatar(user, style)
diff --git a/app/views/shared/_navigation.html.erb b/app/views/shared/_navigation.html.erb
index b526f230e..3d42fb328 100644
--- a/app/views/shared/_navigation.html.erb
+++ b/app/views/shared/_navigation.html.erb
@@ -135,8 +135,10 @@
<%= t('nav.user_greeting', full_name: current_user.full_name) %>
- <%= image_tag avatar_path(current_user, :icon_small),
+
+ <%= image_tag avatar_path(current_user, :icon_small),
class: "avatar" %>
+