Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
947bff88
Commit
947bff88
authored
Jul 20, 2017
by
http://jneen.net/
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move the build arguments to the initializers
parent
b1334ed9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
14 deletions
+60
-14
app/services/notification_recipient_service.rb
app/services/notification_recipient_service.rb
+60
-14
No files found.
app/services/notification_recipient_service.rb
View file @
947bff88
...
@@ -21,11 +21,13 @@ class NotificationRecipientService
...
@@ -21,11 +21,13 @@ class NotificationRecipientService
end
end
module
Builder
module
Builder
class
Base
class
Base
attr_reader
:project
def
initialize
(
*
)
def
initialize
(
project
)
raise
'abstract'
@project
=
project
end
def
build
raise
'abstract'
end
end
def
build
(
*
)
def
build
(
*
)
...
@@ -226,7 +228,22 @@ class NotificationRecipientService
...
@@ -226,7 +228,22 @@ class NotificationRecipientService
end
end
class
Default
<
Base
class
Default
<
Base
def
build
(
target
,
current_user
,
action
:,
previous_assignee:
nil
,
skip_current_user:
true
)
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
@target
=
target
@current_user
=
current_user
@action
=
action
@previous_assignee
=
previous_assignee
@skip_current_user
=
skip_current_user
end
def
build
custom_action
=
build_custom_key
(
action
,
target
)
custom_action
=
build_custom_key
(
action
,
target
)
recipients
=
participants
(
target
,
current_user
)
recipients
=
participants
(
target
,
current_user
)
...
@@ -264,7 +281,18 @@ class NotificationRecipientService
...
@@ -264,7 +281,18 @@ class NotificationRecipientService
end
end
class
Pipeline
<
Base
class
Pipeline
<
Base
def
build
(
target
,
current_user
,
action
:)
attr_reader
:project
attr_reader
:target
attr_reader
:current_user
attr_reader
:action
def
initialize
(
project
,
target
,
current_user
,
action
:)
@project
=
project
@target
=
target
@current_user
=
current_user
@action
=
action
end
def
build
return
[]
unless
current_user
return
[]
unless
current_user
custom_action
=
custom_action
=
...
@@ -288,7 +316,18 @@ class NotificationRecipientService
...
@@ -288,7 +316,18 @@ class NotificationRecipientService
end
end
class
Relabeled
<
Base
class
Relabeled
<
Base
def
build
(
target
,
current_user
,
labels
:)
attr_reader
:project
attr_reader
:target
attr_reader
:current_user
attr_reader
:labels
def
initialize
(
project
,
target
,
current_user
,
labels
:)
@project
=
project
@target
=
target
@current_user
=
current_user
@labels
=
labels
end
def
build
recipients
=
add_labels_subscribers
([],
target
,
labels:
labels
)
recipients
=
add_labels_subscribers
([],
target
,
labels:
labels
)
recipients
=
reject_unsubscribed_users
(
recipients
,
target
)
recipients
=
reject_unsubscribed_users
(
recipients
,
target
)
recipients
=
reject_users_without_access
(
recipients
,
target
)
recipients
=
reject_users_without_access
(
recipients
,
target
)
...
@@ -298,9 +337,16 @@ class NotificationRecipientService
...
@@ -298,9 +337,16 @@ class NotificationRecipientService
end
end
class
NewNote
<
Base
class
NewNote
<
Base
def
build
(
note
)
attr_reader
:project
target
=
note
.
noteable
attr_reader
:note
attr_reader
:target
def
initialize
(
project
,
note
)
@project
=
project
@note
=
note
@target
=
note
.
noteable
end
def
build
(
note
)
ability
,
subject
=
if
note
.
for_personal_snippet?
ability
,
subject
=
if
note
.
for_personal_snippet?
[
:read_personal_snippet
,
note
.
noteable
]
[
:read_personal_snippet
,
note
.
noteable
]
else
else
...
@@ -337,18 +383,18 @@ class NotificationRecipientService
...
@@ -337,18 +383,18 @@ class NotificationRecipientService
end
end
def
build_recipients
(
*
a
)
def
build_recipients
(
*
a
)
Builder
::
Default
.
new
(
@project
).
build
(
*
a
)
Builder
::
Default
.
new
(
@project
,
*
a
).
build
end
end
def
build_pipeline_recipients
(
*
a
)
def
build_pipeline_recipients
(
*
a
)
Builder
::
Pipeline
.
new
(
@project
).
build
(
*
a
)
Builder
::
Pipeline
.
new
(
@project
,
*
a
).
build
end
end
def
build_relabeled_recipients
(
*
a
)
def
build_relabeled_recipients
(
*
a
)
Builder
::
Relabeled
.
new
(
@project
).
build
(
*
a
)
Builder
::
Relabeled
.
new
(
@project
,
*
a
).
build
end
end
def
build_new_note_recipients
(
note
)
def
build_new_note_recipients
(
*
a
)
Builder
::
NewNote
.
new
(
@project
).
build
(
note
)
Builder
::
NewNote
.
new
(
@project
,
*
a
).
build
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment