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
403b7271
Commit
403b7271
authored
Mar 27, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Slightly refactor getting note notification recipients.
parent
d2bd6067
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
15 deletions
+24
-15
app/models/concerns/mentionable.rb
app/models/concerns/mentionable.rb
+1
-1
app/services/notification_service.rb
app/services/notification_service.rb
+23
-14
No files found.
app/models/concerns/mentionable.rb
View file @
403b7271
...
...
@@ -53,7 +53,7 @@ module Mentionable
# Extract GFM references to other Mentionables from this Mentionable. Always excludes its #local_reference.
def
references
(
p
=
project
,
text
=
mentionable_text
)
return
[]
if
text
.
blank?
ext
=
Gitlab
::
ReferenceExtractor
.
new
(
p
)
ext
.
analyze
(
text
)
...
...
app/services/notification_service.rb
View file @
403b7271
...
...
@@ -123,32 +123,29 @@ class NotificationService
return
true
if
note
.
note
.
start_with?
(
'Status changed to closed'
)
return
true
if
note
.
cross_reference?
&&
note
.
system
==
true
opts
=
{
noteable_type:
note
.
noteable_type
,
project_id:
note
.
project_id
}
target
=
note
.
noteable
if
target
.
respond_to?
(
:participants
)
recipients
=
target
.
participants
else
recipients
=
note
.
mentioned_users
end
recipients
=
[]
if
note
.
commit_id
.
present?
opts
.
merge!
(
commit_id:
note
.
commit_id
)
recipients
<<
note
.
commit_author
else
opts
.
merge!
(
noteable_id:
note
.
noteable_id
)
end
# Get users who left comment in thread
recipients
=
recipients
.
concat
(
User
.
where
(
id:
Note
.
where
(
opts
).
pluck
(
:author_id
)
))
recipients
=
recipients
.
concat
(
noteable_commenters
(
note
))
# Merge project watchers
recipients
=
recipients
.
concat
(
project_watchers
(
note
.
project
)).
compact
.
uniq
# Reject mention users unless mentioned in comment
recipients
=
reject_mention_users
(
recipients
-
note
.
mentioned_users
,
note
.
project
)
recipients
=
recipients
+
note
.
mentioned_users
# Reject users with Mention notification level
recipients
=
reject_mention_users
(
recipients
,
note
.
project
)
# Add explicitly mentioned users
if
target
.
respond_to?
(
:participants
)
recipients
=
recipients
.
concat
(
target
.
participants
)
else
recipients
=
recipients
.
concat
(
note
.
mentioned_users
)
end
# Reject mutes users
recipients
=
reject_muted_users
(
recipients
,
note
.
project
)
...
...
@@ -195,6 +192,18 @@ class NotificationService
protected
def
noteable_commenters
(
note
)
opts
=
{
noteable_type:
note
.
noteable_type
,
project_id:
note
.
project_id
}
if
note
.
commit_id
.
present?
opts
.
merge!
(
commit_id:
note
.
commit_id
)
else
opts
.
merge!
(
noteable_id:
note
.
noteable_id
)
end
User
.
where
(
id:
Note
.
where
(
opts
).
pluck
(
:author_id
))
end
# Get project users with WATCH notification level
def
project_watchers
(
project
)
project_members
=
project_member_notification
(
project
)
...
...
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