Skip to content

Commit eaf1f98

Browse files
committed
Refactor invitation email subjects for partner users and simplify invitation due date check
1 parent 5cb2730 commit eaf1f98

3 files changed

Lines changed: 3 additions & 11 deletions

File tree

app/mailers/custom_devise_mailer.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@ def subject_for(key)
77
# Replace the invitation instruction subject for partner users
88
# that were invited by other partner users.
99

10-
if resource.invitation_sent_at.present?
11-
highlighted_role = resource.roles.order(:name).distinct.map(&:itself).first
12-
"You've been re-invited to be a #{highlighted_role.name} in your Human Essentials App Account"
13-
elsif resource.has_role?(Role::PARTNER, :any) && resource.id == resource.partner.primary_user&.id
10+
if resource.has_role?(Role::PARTNER, :any) && resource.id == resource.partner.primary_user&.id && resource.roles.size == 1
1411
"You've been invited to be a partner with #{resource.partner.organization.name}"
1512
elsif resource.has_role?(Role::PARTNER, :any) && resource.id != resource.partner.primary_user&.id
1613
"You've been invited to #{resource.partner.name}'s Human Essentials account"

app/views/users/mailer/invitation_instructions.html.erb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -344,12 +344,7 @@
344344
<% organization = @resource.partner&.organization %>
345345
<% is_primary_partner = @resource.id == @resource.partner&.primary_user&.id %>
346346
<p>Hello <%= @resource.email %></p>
347-
<% if @resource.invitation_sent_at.present? %>
348-
<% highlighted_role = @resource.roles.order(:name).distinct.map(&:itself).first %>
349-
<% email = highlighted_role&.resource&.email.nil? ? @resource.email : highlighted_role.resource.email %>
350-
<p>You've been re-invited to become a <strong><%= highlighted_role.name %></strong> in your Human Essentials App Account</p>
351-
<p><strong> Please contact <%= email %> if you are encountering any issues. </strong></p>
352-
<% elsif @resource.partner.present? && is_primary_partner %>
347+
<% if @resource.partner.present? && is_primary_partner && @resource.roles.size == 1 %>
353348
<p>You've been invited to become a partner with <strong><%= organization.name %>!</strong></p>
354349
<p><%= organization.invitation_text %></p>
355350
<p>Please click the link below to accept your invitation and create an account and you'll be able to begin requesting distributions.</p>

app/views/users/mailer/invitation_instructions.text.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<%= accept_invitation_url(@resource, :invitation_token => @token) %>
66

7-
<% if @resource.invitation_sent_at.present? && @resource.invitation_due_at %>
7+
<% if @resource.invitation_due_at %>
88
<%= t("devise.mailer.invitation_instructions.accept_until", due_date: l(@resource.invitation_due_at, format: :'devise.mailer.invitation_instructions.accept_until_format')) %>
99
<% end %>
1010

0 commit comments

Comments
 (0)