Mastodon API: Mark the conversation as read for the author when they send a new direct message
This commit is contained in:
parent
1bfdf57fc7
commit
359dd1890e
7 changed files with 91 additions and 13 deletions
|
|
@ -7,6 +7,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
|
|||
alias Pleroma.Activity.Ir.Topics
|
||||
alias Pleroma.Config
|
||||
alias Pleroma.Conversation
|
||||
alias Pleroma.Conversation.Participation
|
||||
alias Pleroma.Notification
|
||||
alias Pleroma.Object
|
||||
alias Pleroma.Object.Containment
|
||||
|
|
@ -153,11 +154,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
|
|||
|
||||
Notification.create_notifications(activity)
|
||||
|
||||
participations =
|
||||
activity
|
||||
|> Conversation.create_or_bump_for()
|
||||
|> get_participations()
|
||||
|
||||
conversation = create_or_bump_conversation(activity, map["actor"])
|
||||
participations = get_participations(conversation)
|
||||
stream_out(activity)
|
||||
stream_out_participations(participations)
|
||||
{:ok, activity}
|
||||
|
|
@ -182,7 +180,20 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
|
|||
end
|
||||
end
|
||||
|
||||
defp get_participations({:ok, %{participations: participations}}), do: participations
|
||||
defp create_or_bump_conversation(activity, actor) do
|
||||
with {:ok, conversation} <- Conversation.create_or_bump_for(activity),
|
||||
%User{} = user <- User.get_cached_by_ap_id(actor),
|
||||
Participation.mark_as_read(user, conversation) do
|
||||
{:ok, conversation}
|
||||
end
|
||||
end
|
||||
|
||||
defp get_participations({:ok, conversation}) do
|
||||
conversation
|
||||
|> Repo.preload(:participations, force: true)
|
||||
|> Map.get(:participations)
|
||||
end
|
||||
|
||||
defp get_participations(_), do: []
|
||||
|
||||
def stream_out_participations(participations) do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue