2018-11-20 20:47:30 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-11-18 11:00:15 +05:30
|
|
|
module Todos
|
|
|
|
module Destroy
|
|
|
|
class ConfidentialIssueService < ::Todos::Destroy::BaseService
|
|
|
|
extend ::Gitlab::Utils::Override
|
|
|
|
|
|
|
|
attr_reader :issue
|
|
|
|
|
2018-12-05 23:21:45 +05:30
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2018-11-18 11:00:15 +05:30
|
|
|
def initialize(issue_id)
|
|
|
|
@issue = Issue.find_by(id: issue_id)
|
|
|
|
end
|
2018-12-05 23:21:45 +05:30
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2018-11-18 11:00:15 +05:30
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
override :todos
|
2018-12-05 23:21:45 +05:30
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2018-11-18 11:00:15 +05:30
|
|
|
def todos
|
|
|
|
Todo.where(target: issue)
|
|
|
|
.where('user_id != ?', issue.author_id)
|
|
|
|
.where('user_id NOT IN (?)', issue.assignees.select(:id))
|
|
|
|
end
|
2018-12-05 23:21:45 +05:30
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2018-11-18 11:00:15 +05:30
|
|
|
|
|
|
|
override :todos_to_remove?
|
|
|
|
def todos_to_remove?
|
|
|
|
issue&.confidential?
|
|
|
|
end
|
|
|
|
|
|
|
|
override :project_ids
|
|
|
|
def project_ids
|
|
|
|
issue.project_id
|
|
|
|
end
|
|
|
|
|
|
|
|
override :authorized_users
|
2018-12-05 23:21:45 +05:30
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2018-11-18 11:00:15 +05:30
|
|
|
def authorized_users
|
|
|
|
ProjectAuthorization.select(:user_id)
|
|
|
|
.where(project_id: project_ids)
|
|
|
|
.where('access_level >= ?', Gitlab::Access::REPORTER)
|
|
|
|
end
|
2018-12-05 23:21:45 +05:30
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2018-11-18 11:00:15 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|