module MnoEnterprise::Concerns::Mailers::SystemNotificationMailer
Constants
- DEFAULT_SENDER
Public Instance Methods
confirmation_instructions(record, token, opts={})
click to toggle source
> Devise Email¶ ↑
Description:
New user: Email asking users to confirm their email OR Existing user: - Email asking users (on their new email) to confirm their email change - Email notifying users (on their old email) of an email change
Mandrill vars:
:first_name :last_name :full_name :confirmation_link
# File lib/mno_enterprise/concerns/mailers/system_notification_mailer.rb, line 38 def confirmation_instructions(record, token, opts={}) update_email = record.confirmed? && record.unconfirmed_email? template = update_email ? 'reconfirmation-instructions' : 'confirmation-instructions' email = update_email ? record.unconfirmed_email : record.email MnoEnterprise::MailClient.deliver(template, default_sender, recipient(record).merge(email: email), user_vars(record).merge(confirmation_link: user_confirmation_url(confirmation_token: token)) ) if update_email MnoEnterprise::MailClient.deliver('email-change', default_sender, recipient(record), user_vars(record).merge(unconfirmed_email: record.unconfirmed_email) ) end end
default_sender()
click to toggle source
Default email sender Override to allow dynamic sender
# File lib/mno_enterprise/concerns/mailers/system_notification_mailer.rb, line 20 def default_sender DEFAULT_SENDER end
deletion_request_instructions(record, deletion_request)
click to toggle source
Description:
Email providing instructions + link to initiate the account termination process.
Mandrill vars:
:first_name :last_name :full_name :terminate_account_link
# File lib/mno_enterprise/concerns/mailers/system_notification_mailer.rb, line 144 def deletion_request_instructions(record, deletion_request) MnoEnterprise::MailClient.deliver('deletion-request-instructions', default_sender, recipient(record), user_vars(record).merge(terminate_account_link: deletion_request_url(deletion_request)) ) end
organization_invite(org_invite)
click to toggle source
Description:
Send an email inviting the user to join an existing organization. If the user is already confirmed it is directed to the organization invite page where he can accept or decline the invite If the user is not confirmed yet then it is considered a new user and will be directed to the confirmation page
Mandrill vars:
:organization :team :ref_first_name :ref_last_name :ref_full_name :ref_email :invitee_first_name :invitee_last_name :invitee_full_name :invitee_email :confirmation_link
# File lib/mno_enterprise/concerns/mailers/system_notification_mailer.rb, line 123 def organization_invite(org_invite) new_user = !org_invite.user.confirmed? confirmation_link = new_user ? user_confirmation_url(confirmation_token: org_invite.user.confirmation_token) : org_invite_url(org_invite, token: org_invite.token) email_template = new_user ? 'organization-invite-new-user' : existing_user_template(org_invite) MnoEnterprise::MailClient.deliver(email_template, default_sender, recipient(org_invite.user,new_user), invite_vars(org_invite,new_user).merge(confirmation_link: confirmation_link) ) end
password_change(record, opts={})
click to toggle source
Description:
Email notifying a change of password
# File lib/mno_enterprise/concerns/mailers/system_notification_mailer.rb, line 95 def password_change(record, opts={}) MnoEnterprise::MailClient.deliver('password-change', default_sender, recipient(record), user_vars(record) ) end
registration_instructions(email)
click to toggle source
Description:
Email providing registration instructions
Variables:
:registration_link
# File lib/mno_enterprise/concerns/mailers/system_notification_mailer.rb, line 157 def registration_instructions(email) MnoEnterprise::MailClient.deliver( 'registration-instructions', default_sender, {email: email}, {registration_link: new_user_registration_url} ) end
reset_password_instructions(record, token, opts={})
click to toggle source
> Devise Email¶ ↑
Description:
Email providing instructions + link to reset password
Mandrill vars:
:first_name :last_name :full_name :reset_password_link
# File lib/mno_enterprise/concerns/mailers/system_notification_mailer.rb, line 66 def reset_password_instructions(record, token, opts={}) MnoEnterprise::MailClient.deliver('reset-password-instructions', default_sender, recipient(record), user_vars(record).merge(reset_password_link: edit_user_password_url(reset_password_token: token)) ) end
unlock_instructions(record, token, opts={})
click to toggle source
> Devise Email¶ ↑
Description:
Email providing instructions + link to unlock a user account after too many failed attempts
Mandrill vars:
:first_name :last_name :full_name :unlock_link
# File lib/mno_enterprise/concerns/mailers/system_notification_mailer.rb, line 84 def unlock_instructions(record, token, opts={}) MnoEnterprise::MailClient.deliver('unlock-instructions', default_sender, recipient(record), user_vars(record).merge(unlock_link: user_unlock_url(unlock_token: token)) ) end
Protected Instance Methods
existing_user_template(invite)
click to toggle source
# File lib/mno_enterprise/concerns/mailers/system_notification_mailer.rb, line 198 def existing_user_template(invite) invite.status == 'accepted' ? 'organization-invite-notification' : 'organization-invite-existing-user' end
invite_vars(org_invite, new_user = true)
click to toggle source
# File lib/mno_enterprise/concerns/mailers/system_notification_mailer.rb, line 183 def invite_vars(org_invite, new_user = true) { organization: org_invite.organization.name, team: org_invite.team.present? ? org_invite.team.name : nil, ref_first_name: org_invite.referrer.name, ref_last_name: org_invite.referrer.surname, ref_full_name: "#{org_invite.referrer.name} #{org_invite.referrer.surname}".strip, ref_email: org_invite.referrer.email, invitee_first_name: new_user ? nil : org_invite.user.name, invitee_last_name: new_user ? nil : org_invite.user.surname, invitee_full_name: new_user ? nil : "#{org_invite.user.name} #{org_invite.user.surname}".strip, invitee_email: org_invite.user.email, } end
recipient(record, new_user = false)
click to toggle source
# File lib/mno_enterprise/concerns/mailers/system_notification_mailer.rb, line 168 def recipient(record, new_user = false) # Org Invite for unconfirmed users will have the email in #unconfirmed_email hash = { email: record.email || record.unconfirmed_email } hash[:name] = "#{record.name} #{record.surname}".strip unless new_user hash end
user_vars(record)
click to toggle source
# File lib/mno_enterprise/concerns/mailers/system_notification_mailer.rb, line 175 def user_vars(record) { first_name: record.name, last_name: record.surname, full_name: "#{record.name} #{record.surname}".strip } end