Module: Emails::Members

Extended by:
ActiveSupport::Concern
Includes:
MembersHelper
Included in:
Notify
Defined in:
app/mailers/emails/members.rb

Instance Method Summary collapse

Methods included from MembersHelper

#filter_group_project_member_path, #leave_confirmation_message, #member_path, #remove_member_message, #remove_member_title

Instance Method Details

#memberObject

rubocop: disable CodeReuse/ActiveRecord


109
110
111
# File 'app/mailers/emails/members.rb', line 109

def member
  @member ||= Member.find_by(id: @member_id)
end

#member_access_denied_email(member_source_type, source_id, user_id) ⇒ Object


36
37
38
39
40
41
42
43
44
45
# File 'app/mailers/emails/members.rb', line 36

def member_access_denied_email(member_source_type, source_id, user_id)
  @member_source_type = member_source_type
  @member_source = member_source_class.find(source_id)

  user = User.find(user_id)

  member_email_with_layout(
    to: user.notification_email_for(notification_group),
    subject: subject("Access to the #{member_source.human_name} #{member_source.model_name.singular} was denied"))
end

#member_access_granted_email(member_source_type, member_id) ⇒ Object


25
26
27
28
29
30
31
32
33
34
# File 'app/mailers/emails/members.rb', line 25

def member_access_granted_email(member_source_type, member_id)
  @member_source_type = member_source_type
  @member_id = member_id

  return unless member_exists?

  member_email_with_layout(
    to: member.user.notification_email_for(notification_group),
    subject: subject("Access to the #{member_source.human_name} #{member_source.model_name.singular} was granted"))
end

#member_access_requested_email(member_source_type, member_id, recipient_id) ⇒ Object


12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/mailers/emails/members.rb', line 12

def member_access_requested_email(member_source_type, member_id, recipient_id)
  @member_source_type = member_source_type
  @member_id = member_id

  return unless member_exists?

  user = User.find(recipient_id)

  member_email_with_layout(
    to: user.notification_email_for(notification_group),
    subject: subject("Request to join the #{member_source.human_name} #{member_source.model_name.singular}"))
end

#member_invite_accepted_email(member_source_type, member_id) ⇒ Object


82
83
84
85
86
87
88
89
90
91
92
# File 'app/mailers/emails/members.rb', line 82

def member_invite_accepted_email(member_source_type, member_id)
  @member_source_type = member_source_type
  @member_id = member_id

  return unless member_exists?
  return unless member.created_by

  member_email_with_layout(
    to: member.created_by.notification_email_for(notification_group),
    subject: subject('Invitation accepted'))
end

#member_invite_declined_email(member_source_type, source_id, invite_email, created_by_id) ⇒ Object


94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'app/mailers/emails/members.rb', line 94

def member_invite_declined_email(member_source_type, source_id, invite_email, created_by_id)
  return unless created_by_id

  @member_source_type = member_source_type
  @member_source = member_source_class.find(source_id)
  @invite_email = invite_email

  user = User.find(created_by_id)

  member_email_with_layout(
    to: user.notification_email_for(notification_group),
    subject: subject('Invitation declined'))
end

#member_invited_email(member_source_type, member_id, token) ⇒ Object


47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'app/mailers/emails/members.rb', line 47

def member_invited_email(member_source_type, member_id, token)
  @member_source_type = member_source_type
  @member_id = member_id
  @token = token

  return unless member_exists?

  subject_line = subject("Invitation to join the #{member_source.human_name} #{member_source.model_name.singular}")

  if member.invite_to_unknown_user? && Feature.enabled?(:invite_email_experiment)
    subject_line = subject("#{member.created_by.name} invited you to join GitLab") if member.created_by
    @invite_url_params = { new_user_invite: 'experiment' }

    member_email_with_layout(
      to: member.invite_email,
      subject: subject_line,
      template: 'member_invited_email_experiment',
      layout: 'experiment_mailer'
    )

    Gitlab::Tracking.event(Gitlab::Experimentation::EXPERIMENTS[:invite_email][:tracking_category], 'sent', property: 'experiment_group')
  else
    @invite_url_params = member.invite_to_unknown_user? ? { new_user_invite: 'control' } : {}

    member_email_with_layout(
      to: member.invite_email,
      subject: subject_line
    )

    if member.invite_to_unknown_user?
      Gitlab::Tracking.event(Gitlab::Experimentation::EXPERIMENTS[:invite_email][:tracking_category], 'sent', property: 'control_group')
    end
  end
end

#member_sourceObject

rubocop: enable CodeReuse/ActiveRecord


114
115
116
# File 'app/mailers/emails/members.rb', line 114

def member_source
  @member_source ||= member.source
end

#notification_groupObject


118
119
120
# File 'app/mailers/emails/members.rb', line 118

def notification_group
  @member_source_type.casecmp?('project') ? member_source.group : member_source
end