debian-mirror-gitlab/lib/api/helpers/award_emoji.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

41 lines
1.3 KiB
Ruby
Raw Normal View History

2021-06-08 01:23:25 +05:30
# frozen_string_literal: true
module API
module Helpers
module AwardEmoji
def self.awardables
[
2021-12-11 22:18:48 +05:30
{ type: 'issue', resource: :projects, find_by: :iid, feature_category: :team_planning },
2021-06-08 01:23:25 +05:30
{ type: 'merge_request', resource: :projects, find_by: :iid, feature_category: :code_review },
{ type: 'snippet', resource: :projects, find_by: :id, feature_category: :snippets }
]
end
def self.awardable_id_desc
"The ID of an Issue, Merge Request or Snippet"
end
# rubocop: disable CodeReuse/ActiveRecord
def awardable
@awardable ||=
begin
if params.include?(:note_id)
note_id = params.delete(:note_id)
awardable.notes.find(note_id)
elsif params.include?(:issue_iid)
user_project.issues.find_by!(iid: params[:issue_iid])
elsif params.include?(:merge_request_iid)
user_project.merge_requests.find_by!(iid: params[:merge_request_iid])
elsif params.include?(:snippet_id)
user_project.snippets.find(params[:snippet_id])
end
end
end
# rubocop: enable CodeReuse/ActiveRecord
end
end
end
API::Helpers::AwardEmoji.prepend_mod_with('API::Helpers::AwardEmoji')