From d12e3b020e6710fcd5bd8ef004c45ea6c69d6906 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sat, 27 Jan 2024 20:15:13 +0100 Subject: [PATCH] Use `InboxFilter` in `Moderation::InboxController` --- app/controllers/moderation/inbox_controller.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/controllers/moderation/inbox_controller.rb b/app/controllers/moderation/inbox_controller.rb index 80aa94f5..b906a11c 100644 --- a/app/controllers/moderation/inbox_controller.rb +++ b/app/controllers/moderation/inbox_controller.rb @@ -5,9 +5,11 @@ class Moderation::InboxController < ApplicationController def index @user = User.find_by(screen_name: params[:user]) - @inboxes = @user.cursored_inbox(last_id: params[:last_id]) + filter = InboxFilter.new(@user, filter_params) + + @inboxes = filter.cursored_results(last_id: params[:last_id]) @inbox_last_id = @inboxes.map(&:id).min - @more_data_available = !@user.cursored_inbox(last_id: @inbox_last_id, size: 1).count.zero? + @more_data_available = !filter.cursored_results(last_id: @inbox_last_id, size: 1).count.zero? @inbox_count = @user.inbox_entries.count respond_to do |format| @@ -15,4 +17,10 @@ class Moderation::InboxController < ApplicationController format.turbo_stream { render "index", layout: false, status: :see_other } end end + + private + + def filter_params + params.slice(*InboxFilter::KEYS).permit(*InboxFilter::KEYS) + end end