- def render("chat_update.json", object, user, recipients) do
- chat = Chat.get(user.id, hd(recipients -- [user.ap_id]))
-
- # Explicitly giving the cmr for the object here, so we don't accidentally
- # send a later 'last_message' that was inserted between inserting this and
- # streaming it out
- cm_ref = ChatMessageReference.for_chat_and_object(chat, object)
-
- representation =
- Pleroma.Web.PleromaAPI.ChatView.render(
- "show.json",
- %{last_message: cm_ref, chat: chat}
- )
-
- %{
- event: "pleroma:chat_update",
- payload:
- representation
- |> Jason.encode!()
- }
- |> Jason.encode!()
- end
-