From d1550dc71f30ac7d5c99d71cfb7a85e2f1dc7dec Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Wed, 8 Nov 2023 20:10:31 +0100 Subject: [PATCH] following --- plugins/chat/lib/chat/channel_fetcher.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/plugins/chat/lib/chat/channel_fetcher.rb b/plugins/chat/lib/chat/channel_fetcher.rb index 473161efde0..e0fd9986356 100644 --- a/plugins/chat/lib/chat/channel_fetcher.rb +++ b/plugins/chat/lib/chat/channel_fetcher.rb @@ -223,6 +223,15 @@ module Chat ) end + if options.key?(:following) + following_params = { user_id: user_id } + following_params[:following] = options[:following] if options[:following].present? + query = + query.joins(:user_chat_channel_memberships).where( + user_chat_channel_memberships: following_params, + ) + end + query = query.order("last_message.created_at DESC NULLS LAST").group( "chat_channels.id",