SideEffects / ChatView: Add an unread cache.
This is to prevent wrong values in the stream.
This commit is contained in:
parent
aa2ac76510
commit
cc8a7dc205
5 changed files with 30 additions and 22 deletions
|
|
@ -142,6 +142,11 @@ defmodule Pleroma.Web.ActivityPub.SideEffects do
|
|||
{:ok, chat} = Chat.bump_or_create(user.id, other_user.ap_id)
|
||||
{:ok, cm_ref} = ChatMessageReference.create(chat, object, user.ap_id != actor.ap_id)
|
||||
|
||||
# We add a cache of the unread value here so that it doesn't change when being streamed out
|
||||
chat =
|
||||
chat
|
||||
|> Map.put(:unread, ChatMessageReference.unread_count_for_chat(chat))
|
||||
|
||||
Streamer.stream(
|
||||
["user", "user:pleroma_chat"],
|
||||
{user, %{cm_ref | chat: chat, object: object}}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue