Skip to content

Commit

Permalink
Allow filtering by emoji on API
Browse files Browse the repository at this point in the history
  • Loading branch information
TheEssem committed Feb 10, 2024
1 parent 9aab460 commit 5d963d5
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions app/controllers/api/v1/statuses/reactions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,20 @@ def set_reactions
end

def ordered_reactions
StatusReaction.where(status: @status)
.group(:status_id, :id, :account_id, :name, :custom_emoji_id)
filtered_reactions.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

def value_for_reaction_me_column(account)
Expand Down Expand Up @@ -91,6 +103,6 @@ def records_continue?
end

def pagination_params(core_params)
params_slice(:limit).merge(core_params)
params_slice(:limit, :emoji).merge(core_params)
end
end

0 comments on commit 5d963d5

Please sign in to comment.