Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMario de la Ossa <mariodelaossa@gmail.com>2019-07-24 06:36:07 +0300
committerMario de la Ossa <mariodelaossa@gmail.com>2019-07-26 06:09:25 +0300
commit10a42a8a76c281fad735f89cb3c37caf2acd6e04 (patch)
tree2329ccd5fcdf6920fd282d21d8706ea846a37110 /app/mailers/notify.rb
parenta1d1b3aa89850844f824205eb75c56af3b5228f3 (diff)
Respect alt email when sending group access notifications
When sending access granted/rejected emails we should also respect custom emails set for groups/sub-groups
Diffstat (limited to 'app/mailers/notify.rb')
-rw-r--r--app/mailers/notify.rb12
1 files changed, 8 insertions, 4 deletions
diff --git a/app/mailers/notify.rb b/app/mailers/notify.rb
index 8ef20a03541..5d292094a05 100644
--- a/app/mailers/notify.rb
+++ b/app/mailers/notify.rb
@@ -71,14 +71,18 @@ class Notify < BaseMailer
address.format
end
- # Look up a User by their ID and return their email address
+ # Look up a User's notification email for a particular context.
+ # Can look up by their ID or can accept a User object.
#
- # recipient_id - User ID
+ # recipient - User object OR a User ID
# notification_group - The parent group of the notification
#
# Returns a String containing the User's email address.
- def recipient(recipient_id, notification_group = nil)
- User.find(recipient_id).notification_email_for(notification_group)
+ def recipient(recipient, notification_group = nil)
+ user = recipient if recipient.is_a?(User)
+ user ||= User.find(recipient)
+
+ user.notification_email_for(notification_group)
end
# Formats arguments into a String suitable for use as an email subject