Merge branch 'develop' into 'nondiscoverable-user-metadata'
[akkoma] / lib / pleroma / web / pleroma_api / controllers / chat_controller.ex
index 1f2e953f761cc4e915263946d13e9ad97a3cf97d..27c9a2e0f77a0022019e21caa4b224ca9e81b6ae 100644 (file)
@@ -146,13 +146,8 @@ defmodule Pleroma.Web.PleromaAPI.ChatController do
     blocked_ap_ids = User.blocked_users_ap_ids(user)
 
     chats =
-      from(c in Chat,
-        where: c.user_id == ^user_id,
-        where: c.recipient not in ^blocked_ap_ids,
-        order_by: [desc: c.updated_at],
-        inner_join: u in User,
-        on: u.ap_id == c.recipient
-      )
+      Chat.for_user_query(user_id)
+      |> where([c], c.recipient not in ^blocked_ap_ids)
       |> Repo.all()
 
     conn