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:
authorhttp://jneen.net/ <jneen@jneen.net>2017-08-01 21:53:43 +0300
committerhttp://jneen.net/ <jneen@jneen.net>2017-08-03 19:07:18 +0300
commit0487009d3707c8180211bfc4b3c5a8a9daec50b8 (patch)
tree8a101b3b3cf0934ca376442f1aa7c1205b0307a8 /app/services/notification_recipient_service.rb
parent246951bba7965f4257aa50377a981f3c85c67f1e (diff)
deparameterize `project`
since 99% of the time it's `target.project` anyways.
Diffstat (limited to 'app/services/notification_recipient_service.rb')
-rw-r--r--app/services/notification_recipient_service.rb30
1 files changed, 17 insertions, 13 deletions
diff --git a/app/services/notification_recipient_service.rb b/app/services/notification_recipient_service.rb
index 97ff1f99f02..b36bc90c884 100644
--- a/app/services/notification_recipient_service.rb
+++ b/app/services/notification_recipient_service.rb
@@ -44,6 +44,10 @@ module NotificationRecipientService
raise 'abstract'
end
+ def project
+ target.project
+ end
+
def recipients
@recipients ||= []
end
@@ -138,7 +142,7 @@ module NotificationRecipientService
user_ids = user_ids_with_global_level_watch((user_ids_with_project_global + user_ids_with_group_global).uniq)
- user_ids_with_project_setting = select_project_members_ids(project, user_ids_with_project_global, user_ids)
+ user_ids_with_project_setting = select_project_members_ids(user_ids_with_project_global, user_ids)
user_ids_with_group_setting = select_group_members_ids(project.group, project_members_ids, user_ids_with_group_global, user_ids)
user_scope.where(id: user_ids_with_project_setting.concat(user_ids_with_group_setting).uniq)
@@ -163,7 +167,7 @@ module NotificationRecipientService
end
# Build a list of user_ids based on project notification settings
- def select_project_members_ids(project, global_setting, user_ids_global_level_watch)
+ def select_project_members_ids(global_setting, user_ids_global_level_watch)
user_ids = user_ids_notifiable_on(project, :watch)
# If project setting is global, add to watch list if global setting is watch
@@ -230,14 +234,12 @@ module NotificationRecipientService
end
class Default < Base
- attr_reader :project
attr_reader :target
attr_reader :current_user
attr_reader :action
attr_reader :previous_assignee
attr_reader :skip_current_user
- def initialize(project, target, current_user, action:, previous_assignee: nil, skip_current_user: true)
- @project = project
+ def initialize(target, current_user, action:, previous_assignee: nil, skip_current_user: true)
@target = target
@current_user = current_user
@action = action
@@ -280,12 +282,10 @@ module NotificationRecipientService
end
class Relabeled < Base
- attr_reader :project
attr_reader :target
attr_reader :current_user
attr_reader :labels
- def initialize(project, target, current_user, labels:)
- @project = project
+ def initialize(target, current_user, labels:)
@target = target
@current_user = current_user
@labels = labels
@@ -297,13 +297,17 @@ module NotificationRecipientService
end
class NewNote < Base
- attr_reader :project
attr_reader :note
- attr_reader :target
- def initialize(project, note)
- @project = project
+ def initialize(note)
@note = note
- @target = note.noteable
+ end
+
+ def target
+ note.noteable
+ end
+
+ def project
+ note.project
end
def read_ability