Commit 630e8790 authored by Douwe Maan's avatar Douwe Maan

Clean up code somewhat.

parent 990b476f
...@@ -139,15 +139,14 @@ class Commit ...@@ -139,15 +139,14 @@ class Commit
users << author users << author
users << committer users << committer
mentions = [] users.push *self.mentioned_users(current_user, project)
mentions << self.mentioned_users(current_user, project)
notes(project).each do |note| notes(project).each do |note|
users << note.author users << note.author
mentions << note.mentioned_users(current_user, project) users.push *note.mentioned_users(current_user, project)
end end
users.concat(mentions.reduce([], :|)).uniq users.uniq
end end
def notes(project) def notes(project)
......
...@@ -123,15 +123,14 @@ module Issuable ...@@ -123,15 +123,14 @@ module Issuable
users << author users << author
users << assignee if is_assigned? users << assignee if is_assigned?
mentions = [] users.push *self.mentioned_users(current_user)
mentions << self.mentioned_users(current_user)
notes.each do |note| notes.each do |note|
users << note.author users << note.author
mentions << note.mentioned_users(current_user) users.push *note.mentioned_users(current_user)
end end
users.concat(mentions.reduce([], :|)).uniq users.uniq
end end
def subscribed?(user) def subscribed?(user)
......
...@@ -91,14 +91,12 @@ class Snippet < ActiveRecord::Base ...@@ -91,14 +91,12 @@ class Snippet < ActiveRecord::Base
users = [] users = []
users << author users << author
mentions = []
notes.each do |note| notes.each do |note|
users << note.author users << note.author
mentions << note.mentioned_users(current_user) users.push *note.mentioned_users(current_user)
end end
users.concat(mentions.reduce([], :|)).uniq users.uniq
end end
class << self class << self
......
...@@ -13,19 +13,21 @@ module Projects ...@@ -13,19 +13,21 @@ module Projects
end end
def participants_in(type, id) def participants_in(type, id)
users = case type users =
case type
when "Issue" when "Issue"
issue = project.issues.find_by_iid(id) issue = project.issues.find_by_iid(id)
issue ? issue.participants(current_user) : [] issue.participants(current_user) if issue
when "MergeRequest" when "MergeRequest"
merge_request = project.merge_requests.find_by_iid(id) merge_request = project.merge_requests.find_by_iid(id)
merge_request ? merge_request.participants(current_user) : [] merge_request.participants(current_user) if merge_request
when "Commit" when "Commit"
commit = project.repository.commit(id) commit = project.repository.commit(id)
commit ? commit.participants(project, current_user) : [] commit.participants(project, current_user) if commit
else
[]
end end
return [] unless users
sorted(users) sorted(users)
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