summaryrefslogtreecommitdiff
path: root/app/mailers/emails/members.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-08-05 21:09:40 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-08-05 21:09:40 +0000
commitad9eb72915f1be40da3ebe287274fe2bae62e46b (patch)
treee5a029b2edbce0e84a54b6ff4d18e8240680c4c4 /app/mailers/emails/members.rb
parentf8d20b20be74c283fe8bfe81abfd2d132a500968 (diff)
downloadgitlab-ce-ad9eb72915f1be40da3ebe287274fe2bae62e46b.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/mailers/emails/members.rb')
-rw-r--r--app/mailers/emails/members.rb17
1 files changed, 16 insertions, 1 deletions
diff --git a/app/mailers/emails/members.rb b/app/mailers/emails/members.rb
index 06d2219d6a9..07ce9bba784 100644
--- a/app/mailers/emails/members.rb
+++ b/app/mailers/emails/members.rb
@@ -13,6 +13,8 @@ module Emails
@member_source_type = member_source_type
@member_id = member_id
+ return unless member_exists?
+
user = User.find(recipient_id)
member_email_with_layout(
@@ -24,6 +26,8 @@ module Emails
@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"))
@@ -45,6 +49,8 @@ module Emails
@member_id = member_id
@token = token
+ return unless member_exists?
+
member_email_with_layout(
to: member.invite_email,
subject: subject("Invitation to join the #{member_source.human_name} #{member_source.model_name.singular}"))
@@ -53,6 +59,8 @@ module Emails
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(
@@ -74,9 +82,11 @@ module Emails
subject: subject('Invitation declined'))
end
+ # rubocop: disable CodeReuse/ActiveRecord
def member
- @member ||= Member.find(@member_id)
+ @member ||= Member.find_by(id: @member_id)
end
+ # rubocop: enable CodeReuse/ActiveRecord
def member_source
@member_source ||= member.source
@@ -88,6 +98,11 @@ module Emails
private
+ def member_exists?
+ Gitlab::AppLogger.info("Tried to send an email invitation for a deleted group. Member id: #{@member_id}") if member.blank?
+ member.present?
+ end
+
def member_source_class
@member_source_type.classify.constantize
end