summaryrefslogtreecommitdiff
path: root/app/models/member.rb
diff options
context:
space:
mode:
authorJan Provaznik <jprovaznik@gitlab.com>2019-01-14 22:53:37 +0100
committerYorick Peterse <yorickpeterse@gmail.com>2019-01-31 16:52:49 +0100
commit4d7fa59af27409813cc72312b9b2a47da512b5ed (patch)
tree678c7f26b02c6375b0f470473fbffd9237c9e615 /app/models/member.rb
parent1658f5b62e34b6ed6c7b4c6569bc4a849096af23 (diff)
downloadgitlab-ce-4d7fa59af27409813cc72312b9b2a47da512b5ed.tar.gz
Sent notification only to authorized users
When moving a project, it's possible that some users who had access to the project in old path can not access the project in the new path. Because `project_authorizations` records are updated asynchronously, when we send the notification about moved project the list of project team members contains old project members, we want to notify all these members except the old users who can not access the new location.
Diffstat (limited to 'app/models/member.rb')
-rw-r--r--app/models/member.rb2
1 files changed, 2 insertions, 0 deletions
diff --git a/app/models/member.rb b/app/models/member.rb
index b0f049438eb..a0f755f88b5 100644
--- a/app/models/member.rb
+++ b/app/models/member.rb
@@ -84,6 +84,8 @@ class Member < ActiveRecord::Base
scope :order_recent_sign_in, -> { left_join_users.reorder(Gitlab::Database.nulls_last_order('users.last_sign_in_at', 'DESC')) }
scope :order_oldest_sign_in, -> { left_join_users.reorder(Gitlab::Database.nulls_last_order('users.last_sign_in_at', 'ASC')) }
+ scope :on_project_and_ancestors, ->(project) { where(source: [project] + project.ancestors) }
+
before_validation :generate_invite_token, on: :create, if: -> (member) { member.invite_email.present? }
after_create :send_invite, if: :invite?, unless: :importing?