Allow filtering by emoji on API

This commit is contained in:
Essem 2024-02-09 20:14:41 -06:00
parent e1e4b734f6
commit da10e39d33
No known key found for this signature in database
GPG key ID: 7D497397CC3A2A8C

View file

@ -41,8 +41,20 @@ class Api::V1::Statuses::ReactionsController < Api::V1::Statuses::BaseController
end end
def ordered_reactions def ordered_reactions
StatusReaction.where(status: @status) filtered_reactions.group(:status_id, :id, :account_id, :name, :custom_emoji_id)
.group(:status_id, :id, :account_id, :name, :custom_emoji_id) end
def filtered_reactions
initial_reactions = StatusReaction.where(status: @status)
if filtered?
initial_reactions.where(name: params[:emoji])
else
initial_reactions
end
end
def filtered?
params[:emoji].present?
end end
def value_for_reaction_me_column(account) def value_for_reaction_me_column(account)
@ -91,6 +103,6 @@ class Api::V1::Statuses::ReactionsController < Api::V1::Statuses::BaseController
end end
def pagination_params(core_params) def pagination_params(core_params)
params_slice(:limit).merge(core_params) params_slice(:limit, :emoji).merge(core_params)
end end
end end