Skip to content

Commit

Permalink
Add Site's application name into email
Browse files Browse the repository at this point in the history
This commit will add the Site's application name into the email subject
as well as the body.
  • Loading branch information
kirkkwang committed May 6, 2024
1 parent 19a6e4e commit c0d6351
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion app/mailers/hyku_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ def summary_email(user, messages, account)
@messages = messages || []
@account = account
@url = notifications_url_for(@account)
@application_name = account.sites.application_name

mail(to: @user.email,
subject: "You have #{messages.count} new message(s)",
subject: "You have #{@messages.count} new message(s) on #{@application_name}",
from: @account.contact_email,
template_path: 'hyku_mailer',
template_name: 'summary_email')
Expand Down
2 changes: 1 addition & 1 deletion app/views/hyku_mailer/summary_email.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<body>
<h2>Hello, <%= @user.name %></h2>
<p>You have the following notifications:</p>
<p>Click <a href="<%= @url %>">here</a> to view them in Hyku.</p>
<p>Click <a href="<%= @url %>">here</a> to view them on <%= @application_name %>.</p>
<table>
<tr>
<th>Date</th>
Expand Down
5 changes: 4 additions & 1 deletion spec/mailers/previews/hyku_mailer_preview.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ def summary_email

user = Struct.new(:email, :name).new('admin@example.com', 'Admin')

account = Struct.new(:cname, :contact_email).new('local', 'user@example.com')
site = Struct.new(:application_name)
sites = site.new('Hyku Test')

account = Struct.new(:cname, :contact_email, :sites).new('local', 'user@example.com', sites)

HykuMailer.new.summary_email(user, messages, account)
end
Expand Down

0 comments on commit c0d6351

Please sign in to comment.