Module: Emails::Members
- Extended by:
- ActiveSupport::Concern
- Includes:
- Gitlab::Experiment::Dsl, MembersHelper
- Included in:
- Notify
- Defined in:
- app/mailers/emails/members.rb
Constant Summary
collapse
- INITIAL_INVITE =
'initial_email'
Instance Method Summary
collapse
-
#member ⇒ Object
rubocop: disable CodeReuse/ActiveRecord.
-
#member_about_to_expire_email(member_source_type, member_id) ⇒ Object
-
#member_access_denied_email(member_source_type, source_id, user_id) ⇒ Object
-
#member_access_granted_email(member_source_type, member_id) ⇒ Object
-
#member_access_requested_email(member_source_type, member_id, recipient_id) ⇒ Object
-
#member_expiration_date_updated_email(member_source_type, member_id) ⇒ Object
-
#member_invite_accepted_email(member_source_type, member_id) ⇒ Object
-
#member_invite_declined_email(member_source_type, source_id, invite_email, created_by_id) ⇒ Object
-
#member_invited_email(member_source_type, member_id, token) ⇒ Object
-
#member_invited_reminder_email(member_source_type, member_id, token, reminder_index) ⇒ Object
-
#member_source ⇒ Object
rubocop: enable CodeReuse/ActiveRecord.
-
#notification_group ⇒ Object
#filter_group_project_member_path, #leave_confirmation_message, #member_path, #remove_member_message, #remove_member_title
Instance Method Details
#member ⇒ Object
rubocop: disable CodeReuse/ActiveRecord
153
154
155
|
# File 'app/mailers/emails/members.rb', line 153
def member
@member ||= Member.find_by(id: @member_id)
end
|
#member_about_to_expire_email(member_source_type, member_id) ⇒ Object
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
# File 'app/mailers/emails/members.rb', line 136
def member_about_to_expire_email(member_source_type, member_id)
@member_source_type = member_source_type
@member_id = member_id
return unless member_exists?
return unless member.expires_at
@days_to_expire = (member.expires_at - Date.today).to_i
return if @days_to_expire <= 0
email_with_layout(
to: member.user.notification_email_for(notification_group),
subject: subject(s_("Your membership will expire in %{days_to_expire} days") % { days_to_expire: @days_to_expire }))
end
|
#member_access_denied_email(member_source_type, source_id, user_id) ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'app/mailers/emails/members.rb', line 40
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)
@source_hidden = !member_source.readable_by?(user)
human_name = @source_hidden ? 'Hidden' : member_source.human_name
email_with_layout(
to: user.notification_email_for(notification_group),
subject: subject("Access to the #{human_name} #{member_source.model_name.singular} was denied"))
end
|
#member_access_granted_email(member_source_type, member_id) ⇒ Object
29
30
31
32
33
34
35
36
37
38
|
# File 'app/mailers/emails/members.rb', line 29
def member_access_granted_email(member_source_type, member_id)
@member_source_type = member_source_type
@member_id = member_id
return unless member_exists?
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
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'app/mailers/emails/members.rb', line 16
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)
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_expiration_date_updated_email(member_source_type, member_id) ⇒ Object
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
# File 'app/mailers/emails/members.rb', line 119
def member_expiration_date_updated_email(member_source_type, member_id)
@member_source_type = member_source_type
@member_id = member_id
return unless member_exists?
subject = if member.expires?
_('Group membership expiration date changed')
else
_('Group membership expiration date removed')
end
email_with_layout(
to: member.user.notification_email_for(notification_group),
subject: subject(subject))
end
|
#member_invite_accepted_email(member_source_type, member_id) ⇒ Object
93
94
95
96
97
98
99
100
101
102
103
|
# File 'app/mailers/emails/members.rb', line 93
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
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
105
106
107
108
109
110
111
112
113
114
115
116
117
|
# File 'app/mailers/emails/members.rb', line 105
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)
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'app/mailers/emails/members.rb', line 55
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?
Gitlab::Tracking.event(self.class.name, 'invite_email_sent', label: 'invite_email', property: member_id.to_s)
mail_with_locale(to: member.invite_email, subject: invite_email_subject, **) do |format|
format.html { render layout: 'unknown_user_mailer' }
format.text { render layout: 'unknown_user_mailer' }
end
end
|
#member_invited_reminder_email(member_source_type, member_id, token, reminder_index) ⇒ Object
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
# File 'app/mailers/emails/members.rb', line 70
def member_invited_reminder_email(member_source_type, member_id, token, reminder_index)
@member_source_type = member_source_type
@member_id = member_id
@token = token
@reminder_index = reminder_index
return unless member_exists? && member.created_by && member.invite_to_unknown_user?
subjects = {
0 => s_("InviteReminderEmail|%{inviter}'s invitation to GitLab is pending"),
1 => s_('InviteReminderEmail|%{inviter} is waiting for you to join GitLab'),
2 => s_('InviteReminderEmail|%{inviter} is still waiting for you to join GitLab')
}
subject_line = subjects[reminder_index] % { inviter: member.created_by.name }
email_with_layout(
layout: 'unknown_user_mailer',
to: member.invite_email,
subject: subject(subject_line)
)
end
|
#member_source ⇒ Object
rubocop: enable CodeReuse/ActiveRecord
158
159
160
|
# File 'app/mailers/emails/members.rb', line 158
def member_source
@member_source ||= member.source
end
|
#notification_group ⇒ Object
162
163
164
|
# File 'app/mailers/emails/members.rb', line 162
def notification_group
@member_source_type.casecmp?('project') ? member_source.group : member_source
end
|