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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
4caa5a7e
Commit
4caa5a7e
authored
Jul 26, 2017
by
http://jneen.net/
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
factor out .notifiable_users
parent
a4932d2d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
41 deletions
+8
-41
app/services/notification_recipient_service.rb
app/services/notification_recipient_service.rb
+4
-36
app/services/notification_service.rb
app/services/notification_service.rb
+4
-5
No files found.
app/services/notification_recipient_service.rb
View file @
4caa5a7e
...
@@ -378,38 +378,6 @@ class NotificationRecipientService
...
@@ -378,38 +378,6 @@ class NotificationRecipientService
end
end
end
end
class
Pipeline
<
Base
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
acting_user
nil
end
def
custom_action
case
action
.
to_s
when
'failed'
:failed_pipeline
when
'success'
:success_pipeline
end
end
def
build!
return
[]
unless
current_user
self
<<
[
current_user
,
:watch
]
end
end
class
Relabeled
<
Base
class
Relabeled
<
Base
attr_reader
:project
attr_reader
:project
attr_reader
:target
attr_reader
:target
...
@@ -475,12 +443,12 @@ class NotificationRecipientService
...
@@ -475,12 +443,12 @@ class NotificationRecipientService
end
end
end
end
def
build_recipient
s
(
*
a
)
def
self
.
notifiable_user
s
(
*
a
)
Builder
::
Default
.
new
(
@project
,
*
a
).
recipient_users
Recipient
.
notifiable_users
(
*
a
)
end
end
def
build_
pipeline_
recipients
(
*
a
)
def
build_recipients
(
*
a
)
Builder
::
Pipeline
.
new
(
@project
,
*
a
).
recipient_users
Builder
::
Default
.
new
(
@project
,
*
a
).
recipient_users
end
end
def
build_relabeled_recipients
(
*
a
)
def
build_relabeled_recipients
(
*
a
)
...
...
app/services/notification_service.rb
View file @
4caa5a7e
...
@@ -270,7 +270,7 @@ class NotificationService
...
@@ -270,7 +270,7 @@ class NotificationService
end
end
def
project_was_moved
(
project
,
old_path_with_namespace
)
def
project_was_moved
(
project
,
old_path_with_namespace
)
recipients
=
NotificationRecipientService
::
Recipient
.
notifiable_users
(
project
.
team
.
members
,
project
,
:watch
)
recipients
=
NotificationRecipientService
.
notifiable_users
(
project
.
team
.
members
,
project
,
:mention
)
recipients
.
each
do
|
recipient
|
recipients
.
each
do
|
recipient
|
mailer
.
project_was_moved_email
(
mailer
.
project_was_moved_email
(
...
@@ -304,10 +304,9 @@ class NotificationService
...
@@ -304,10 +304,9 @@ class NotificationService
return
unless
mailer
.
respond_to?
(
email_template
)
return
unless
mailer
.
respond_to?
(
email_template
)
recipients
||=
NotificationRecipientService
.
new
(
pipeline
.
project
).
build_pipeline_recipients
(
recipients
||=
NotificationRecipientService
.
notifiable_users
(
pipeline
,
[
pipeline
.
user
],
pipeline
.
project
,
:watch
,
pipeline
.
user
,
custom_action: :"
#{
pipeline
.
status
}
_pipeline"
action:
pipeline
.
status
).
map
(
&
:notification_email
)
).
map
(
&
:notification_email
)
if
recipients
.
any?
if
recipients
.
any?
...
...
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