Class: Notify

Inherits:
BaseMailer show all
Includes:
ActionDispatch::Routing::PolymorphicRoutes, Emails::Builds, Emails::Groups, Emails::Issues, Emails::MergeRequests, Emails::Notes, Emails::Profile, Emails::Projects
Defined in:
app/mailers/notify.rb

Instance Attribute Summary

Attributes inherited from BaseMailer

#current_user

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Emails::Builds

#build_fail_email, #build_success_email

Methods included from Emails::Groups

#group_access_granted_email, #group_invite_accepted_email, #group_invite_declined_email, #group_member_invited_email

Methods included from Emails::Profile

#new_email_email, #new_ssh_key_email, #new_user_email

Methods included from Emails::Projects

#project_access_granted_email, #project_invite_accepted_email, #project_invite_declined_email, #project_member_invited_email, #project_was_moved_email, #repository_push_email

Methods included from Emails::Notes

#note_commit_email, #note_issue_email, #note_merge_request_email, #note_snippet_email

Methods included from Emails::MergeRequests

#closed_merge_request_email, #merge_request_status_email, #merged_merge_request_email, #new_merge_request_email, #reassigned_merge_request_email, #relabeled_merge_request_email

Methods included from Emails::Issues

#closed_issue_email, #issue_moved_email, #issue_status_changed_email, #new_issue_email, #reassigned_issue_email, #relabeled_issue_email

Methods inherited from BaseMailer

#can?

Class Method Details

.allowed_email_domainsObject

Splits “gitlab.corp.company.com” up into “gitlab.corp.company.com”, “corp.company.com” and “company.com”. Respects set tld length so “company.co.uk” won't match “somethingelse.uk”


26
27
28
29
30
31
32
33
34
35
# File 'app/mailers/notify.rb', line 26

def self.allowed_email_domains
  domain_parts = Gitlab.config.gitlab.host.split(".")
  allowed_domains = []
  begin
    allowed_domains << domain_parts.join(".")
    domain_parts.shift
  end while domain_parts.length > ActionDispatch::Http::URL.tld_length

  allowed_domains
end

Instance Method Details

#can_send_from_user_email?(sender) ⇒ Boolean

Returns:

  • (Boolean)

37
38
39
40
# File 'app/mailers/notify.rb', line 37

def can_send_from_user_email?(sender)
  sender_domain = sender.email.split("@").last
  self.class.allowed_email_domains.include?(sender_domain)
end

#test_email(recipient_email, subject, body) ⇒ Object


15
16
17
18
19
20
21
# File 'app/mailers/notify.rb', line 15

def test_email(recipient_email, subject, body)
  mail(to: recipient_email,
       subject: subject,
       body: body.html_safe,
       content_type: 'text/html'
      )
end