Commit 38737345 authored by http://jneen.net/'s avatar http://jneen.net/

skip the :read_project check for new_project_member

since we're just adding them as a member, the permission may still
return false.
parent 4a3b18cb
...@@ -6,7 +6,8 @@ class NotificationRecipient ...@@ -6,7 +6,8 @@ class NotificationRecipient
target: nil, target: nil,
acting_user: nil, acting_user: nil,
project: nil, project: nil,
group: nil group: nil,
skip_read_ability: false
) )
unless NotificationSetting.levels.key?(type) || type == :subscription unless NotificationSetting.levels.key?(type) || type == :subscription
raise ArgumentError, "invalid type: #{type.inspect}" raise ArgumentError, "invalid type: #{type.inspect}"
...@@ -19,6 +20,7 @@ class NotificationRecipient ...@@ -19,6 +20,7 @@ class NotificationRecipient
@group = group || @project&.group @group = group || @project&.group
@user = user @user = user
@type = type @type = type
@skip_read_ability = skip_read_ability
end end
def notification_setting def notification_setting
...@@ -83,6 +85,8 @@ class NotificationRecipient ...@@ -83,6 +85,8 @@ class NotificationRecipient
def has_access? def has_access?
DeclarativePolicy.subject_scope do DeclarativePolicy.subject_scope do
return false unless user.can?(:receive_notifications) return false unless user.can?(:receive_notifications)
return true if @skip_read_ability
return false if @project && !user.can?(:read_project, @project) return false if @project && !user.can?(:read_project, @project)
return true unless read_ability return true unless read_ability
...@@ -102,6 +106,7 @@ class NotificationRecipient ...@@ -102,6 +106,7 @@ class NotificationRecipient
private private
def read_ability def read_ability
return nil if @skip_read_ability
return @read_ability if instance_variable_defined?(:@read_ability) return @read_ability if instance_variable_defined?(:@read_ability)
@read_ability = @read_ability =
......
...@@ -244,7 +244,7 @@ class NotificationService ...@@ -244,7 +244,7 @@ class NotificationService
end end
def new_project_member(project_member) def new_project_member(project_member)
return true unless project_member.notifiable?(:mention) return true unless project_member.notifiable?(:mention, skip_read_ability: true)
mailer.member_access_granted_email(project_member.real_source_type, project_member.id).deliver_later mailer.member_access_granted_email(project_member.real_source_type, project_member.id).deliver_later
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment