summaryrefslogtreecommitdiff
path: root/app/models/notification_recipient.rb
diff options
context:
space:
mode:
authorhttp://jneen.net/ <jneen@jneen.net>2017-08-10 10:41:25 -0700
committerhttp://jneen.net/ <jneen@jneen.net>2017-08-11 16:02:08 -0700
commit38737345abdf91ac2cb0b1cdff4eb7132b4104ee (patch)
tree74717a181142a5988c47b8b7a91d0454c5afccd5 /app/models/notification_recipient.rb
parent4a3b18cbd87a49464d2a7619113a7b192f08a98b (diff)
downloadgitlab-ce-38737345abdf91ac2cb0b1cdff4eb7132b4104ee.tar.gz
skip the :read_project check for new_project_member
since we're just adding them as a member, the permission may still return false.
Diffstat (limited to 'app/models/notification_recipient.rb')
-rw-r--r--app/models/notification_recipient.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/app/models/notification_recipient.rb b/app/models/notification_recipient.rb
index 30fab33e5e0..dc862565a71 100644
--- a/app/models/notification_recipient.rb
+++ b/app/models/notification_recipient.rb
@@ -6,7 +6,8 @@ class NotificationRecipient
target: nil,
acting_user: nil,
project: nil,
- group: nil
+ group: nil,
+ skip_read_ability: false
)
unless NotificationSetting.levels.key?(type) || type == :subscription
raise ArgumentError, "invalid type: #{type.inspect}"
@@ -19,6 +20,7 @@ class NotificationRecipient
@group = group || @project&.group
@user = user
@type = type
+ @skip_read_ability = skip_read_ability
end
def notification_setting
@@ -83,6 +85,8 @@ class NotificationRecipient
def has_access?
DeclarativePolicy.subject_scope do
return false unless user.can?(:receive_notifications)
+ return true if @skip_read_ability
+
return false if @project && !user.can?(:read_project, @project)
return true unless read_ability
@@ -102,6 +106,7 @@ class NotificationRecipient
private
def read_ability
+ return nil if @skip_read_ability
return @read_ability if instance_variable_defined?(:@read_ability)
@read_ability =