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.

39 lines
1.2 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 },
2023-03-04 22:38:38 +05:30
{ type: 'snippet', resource: :projects, find_by: :id, feature_category: :source_code_management }
2021-06-08 01:23:25 +05:30
]
end
def self.awardable_id_desc
"The ID of an Issue, Merge Request or Snippet"
end
# rubocop: disable CodeReuse/ActiveRecord
def awardable
@awardable ||=
2023-03-04 22:38:38 +05:30
if params.include?(:note_id)
note_id = params.delete(:note_id)
2021-06-08 01:23:25 +05:30
2023-03-04 22:38:38 +05:30
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])
2021-06-08 01:23:25 +05:30
end
end
# rubocop: enable CodeReuse/ActiveRecord
end
end
end
API::Helpers::AwardEmoji.prepend_mod_with('API::Helpers::AwardEmoji')