mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-10 11:19:19 +00:00
Update note count in ActivityPub.create.
This commit is contained in:
parent
d0b1c498a0
commit
22bfeac256
3 changed files with 15 additions and 16 deletions
|
@ -61,7 +61,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
|
|||
additional
|
||||
),
|
||||
{:ok, activity} <- insert(create_data, local),
|
||||
:ok <- maybe_federate(activity) do
|
||||
:ok <- maybe_federate(activity),
|
||||
{:ok, actor} <- User.increase_note_count(actor) do
|
||||
{:ok, activity}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -138,19 +138,15 @@ defmodule Pleroma.Web.OStatus.NoteHandler do
|
|||
do: note |> Map.put("inReplyTo", inReplyTo),
|
||||
else: note
|
||||
) do
|
||||
res =
|
||||
ActivityPub.create(%{
|
||||
to: to,
|
||||
actor: actor,
|
||||
context: context,
|
||||
object: note,
|
||||
published: date,
|
||||
local: false,
|
||||
additional: %{"cc" => cc}
|
||||
})
|
||||
|
||||
User.increase_note_count(actor)
|
||||
res
|
||||
ActivityPub.create(%{
|
||||
to: to,
|
||||
actor: actor,
|
||||
context: context,
|
||||
object: note,
|
||||
published: date,
|
||||
local: false,
|
||||
additional: %{"cc" => cc}
|
||||
})
|
||||
else
|
||||
%Activity{} = activity -> {:ok, activity}
|
||||
e -> {:error, e}
|
||||
|
|
|
@ -83,16 +83,18 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
|
||||
describe "create activities" do
|
||||
test "removes doubled 'to' recipients" do
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, activity} =
|
||||
ActivityPub.create(%{
|
||||
to: ["user1", "user1", "user2"],
|
||||
actor: %User{ap_id: "1"},
|
||||
actor: user,
|
||||
context: "",
|
||||
object: %{}
|
||||
})
|
||||
|
||||
assert activity.data["to"] == ["user1", "user2"]
|
||||
assert activity.actor == "1"
|
||||
assert activity.actor == user.ap_id
|
||||
assert activity.recipients == ["user1", "user2"]
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue