human-essentials
human-essentials copied to clipboard
Investigate Custom Devise Mailer
Summary
So we have a custom devise mailer that seems to be responsible for setting the subject line for Partner invitations.. Tests for reference
The code looks something like this:
if resource.has_role?(Role::PARTNER, :any) && resource.id == resource.partner.primary_user&.id
# do something
elsif resource.has_role?(Role::PARTNER, :any) && resource.id != resource.partner.primary_user&.id
# do something else
This code (I think at least) sends one message if the user being invited is the primary user for the Partner and another if they are not.
Criteria for Completion
Figure out if this code is correct:
- [ ] Does it make sense to check for
resource.has_role?(Role::PARTNER, :any)
as opposed to a specific partner - [ ] does it make sense for these invitations to get sent from a Partner vs a Org?
- [ ] Do they even get sent from a Partner and not an Org?
- [ ] If we change the code to check for a specific partner will there be any issues?
- [ ] If it seems reasonable and necessary make the change :slightly_smiling_face:
Historical context:
The mailer was originally added here: https://github.com/rubyforgood/human-essentials/commit/ff961af7f5051ec6e05dd9cdd4d055b5e650431d. It simply changed the invite message for inviting Partners instead of Orgs.
if resource.is_a?(PartnerUser)
"You've been invited to be a partner with #{resource.partner.organization.name}"
https://github.com/rubyforgood/human-essentials/pull/2232 allowed Partners to invite coworkers by checking that the inviter was the primary user for that Partner:
if resource.is_a?(PartnerUser) && resource.id != resource.partner.primary_user&.id
"You've been invited to #{resource.partner.name}'s partnerbase account"
https://github.com/rubyforgood/human-essentials/pull/3050 got rid of PartnerUsers
and instead used partner_id
if resource.try(:partner_id) && resource.id == resource.partner.primary_user&.id
"You've been invited to be a partner with #{resource.partner.organization.name}"
https://github.com/rubyforgood/human-essentials/pull/3117 finally when roles got added we started checking by role instead of partner_id
if resource.has_role?(Role::PARTNER, :any) && resource.id == resource.partner.primary_user&.id
"You've been invited to be a partner with #{resource.partner.organization.name}"