OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Show custom logo in the mail if available
Henriette Darge649a9df97c6f
diff --git a/app/helpers/mail_digest_helper.rb b/app/helpers/mail_digest_helper.rbindex 1dc389bd5ce..9059d7e0ce3 100644--- a/app/helpers/mail_digest_helper.rb+++ b/app/helpers/mail_digest_helper.rb@@ -48,10 +48,10 @@ module MailDigestHelperenddef digest_comment_text(notification)- if notification.journal.notes.match(/<mention.*data-type=\"user\".*>/)- I18n.t(:'mail.digests.work_packages.mentioned').html_safe+ if notification.journal.notes.match(/<mention.*data-type="user".*>/)+ sanitize I18n.t(:'mail.digests.work_packages.mentioned')else- I18n.t(:'mail.digests.work_packages.comment_added').html_safe+ sanitize I18n.t(:'mail.digests.work_packages.comment_added')endend@@ -60,15 +60,15 @@ module MailDigestHelperdef timestamp_text(user, journal, extended)value = journal.initial? ? "created" : "updated"if extended- raw(I18n.t(:"mail.digests.work_packages.#{value}") +- ' ' +- I18n.t(:"mail.digests.work_packages.#{value}_at",- user: user,- timestamp: time_ago_in_words(journal.created_at)))+ sanitize(+ "#{I18n.t(:"mail.digests.work_packages.#{value}")} #{I18n.t(:"mail.digests.work_packages.#{value}_at",+ user: user,+ timestamp: time_ago_in_words(journal.created_at))}"+ )else- raw(I18n.t(:"mail.digests.work_packages.#{value}_at",- user: user,- timestamp: time_ago_in_words(journal.created_at)))+ sanitize(I18n.t(:"mail.digests.work_packages.#{value}_at",+ user: user,+ timestamp: time_ago_in_words(journal.created_at)))endendenddiff --git a/app/helpers/mail_notification_helper.rb b/app/helpers/mail_notification_helper.rbindex cab4f99241b..ca226f83b36 100644--- a/app/helpers/mail_notification_helper.rb+++ b/app/helpers/mail_notification_helper.rb@@ -31,11 +31,25 @@module MailNotificationHelperinclude ::ColorsHelper- def email_image_tag(image, **options)- image_string = Rails.application.assets[image].to_s+ def logo_tag(**options)+ current_logo = CustomStyle.current.logo++ if current_logo.present?+ logo = File.read(current_logo.local_file)+ suffix = MIME::Types.type_for(current_logo.local_file.path).first.content_type+ else+ logo = Rails.application.assets["logo_openproject_narrow.svg"]+ suffix = "svg+xml"+ end++ email_image_tag(logo, suffix, options)+ end++ def email_image_tag(image, suffix, **options)+ image_string = image.to_sbase64_string = Base64.strict_encode64(image_string)- image_tag "data:image/svg+xml;base64," + base64_string, **options+ image_tag "data:image/#{suffix};base64,#{base64_string}", **optionsenddef unique_reasons_of_notifications(notifications)diff --git a/app/views/mailer/_notification_mailer_header.html.erb b/app/views/mailer/_notification_mailer_header.html.erbindex aab70eb6378..f8d743b59b1 100644--- a/app/views/mailer/_notification_mailer_header.html.erb+++ b/app/views/mailer/_notification_mailer_header.html.erb@@ -1,7 +1,7 @@<table width="100%" border="0" cellpadding="0" cellspacing="0" style="border-bottom: 1px solid #cccccc; margin-bottom: 32px;"><tr><td style="width: 82px; height: 82px; vertical-align: top;">- <%= email_image_tag("logo_openproject_narrow.svg", alt: I18n.t(:'mail.logo_alt_text')) %>+ <%= logo_tag({ alt: "#{Setting.app_title} #{I18n.t(:'mail.logo_alt_text')}", style: "height:82px;"}) %></td><td width="100%" style="padding-top: 8px; padding-left: 12px;"><table>diff --git a/spec/features/notifications/digest_mail_spec.rb b/spec/features/notifications/digest_mail_spec.rbindex ef734f21297..3b0b758aea7 100644--- a/spec/features/notifications/digest_mail_spec.rb+++ b/spec/features/notifications/digest_mail_spec.rb@@ -53,6 +53,9 @@ describe "Digest email", type: :feature, js: true dowork_packageinvolved_work_package+ allow(CustomStyle.current)+ .to receive(:logo).and_return(nil)+ActiveJob::Base.queue_adapter.enqueued_jobs.clearenddiff --git a/spec/mailers/digest_mailer_spec.rb b/spec/mailers/digest_mailer_spec.rbindex 151af2d60d3..357ceef6f91 100644--- a/spec/mailers/digest_mailer_spec.rb+++ b/spec/mailers/digest_mailer_spec.rb@@ -76,7 +76,12 @@ describe DigestMailer, type: :mailer dodescribe '#work_packages' dosubject(:mail) { described_class.work_packages(recipient.id, notifications.map(&:id)) }- let(:mail_body) { mail.body.parts.detect { |part| part['Content-Type'].value == 'text/html' }.body.to_s }+ let(:mail_body) { mail.body.parts.detect { |part| part['Content-Type'].value == 'text/html' }.body.to_s }++ before do+ allow(CustomStyle.current)+ .to receive(:logo).and_return(nil)+ endit 'notes the day and the number of notifications in the subject' doexpect(mail.subject)