|
|
|
@ -239,7 +239,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assert {:error, {:remote_limit_error, _}} = ActivityPub.insert(data)
|
|
|
|
|
assert {:error, :remote_limit} = ActivityPub.insert(data)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test "doesn't drop activities with content being null" do
|
|
|
|
@ -386,9 +386,11 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe "create activities" do
|
|
|
|
|
test "it reverts create" do
|
|
|
|
|
user = insert(:user)
|
|
|
|
|
setup do
|
|
|
|
|
[user: insert(:user)]
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test "it reverts create", %{user: user} do
|
|
|
|
|
with_mock(Utils, [:passthrough], maybe_federate: fn _ -> {:error, :reverted} end) do
|
|
|
|
|
assert {:error, :reverted} =
|
|
|
|
|
ActivityPub.create(%{
|
|
|
|
@ -407,9 +409,47 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|
|
|
|
assert Repo.aggregate(Object, :count, :id) == 0
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test "removes doubled 'to' recipients" do
|
|
|
|
|
user = insert(:user)
|
|
|
|
|
test "creates activity if expiration is not configured and expires_at is not passed", %{
|
|
|
|
|
user: user
|
|
|
|
|
} do
|
|
|
|
|
clear_config([Pleroma.Workers.PurgeExpiredActivity, :enabled], false)
|
|
|
|
|
|
|
|
|
|
assert {:ok, _} =
|
|
|
|
|
ActivityPub.create(%{
|
|
|
|
|
to: ["user1", "user2"],
|
|
|
|
|
actor: user,
|
|
|
|
|
context: "",
|
|
|
|
|
object: %{
|
|
|
|
|
"to" => ["user1", "user2"],
|
|
|
|
|
"type" => "Note",
|
|
|
|
|
"content" => "testing"
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test "rejects activity if expires_at present but expiration is not configured", %{user: user} do
|
|
|
|
|
clear_config([Pleroma.Workers.PurgeExpiredActivity, :enabled], false)
|
|
|
|
|
|
|
|
|
|
assert {:error, :expired_activities_disabled} =
|
|
|
|
|
ActivityPub.create(%{
|
|
|
|
|
to: ["user1", "user2"],
|
|
|
|
|
actor: user,
|
|
|
|
|
context: "",
|
|
|
|
|
object: %{
|
|
|
|
|
"to" => ["user1", "user2"],
|
|
|
|
|
"type" => "Note",
|
|
|
|
|
"content" => "testing"
|
|
|
|
|
},
|
|
|
|
|
additional: %{
|
|
|
|
|
"expires_at" => DateTime.utc_now()
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
assert Repo.aggregate(Activity, :count, :id) == 0
|
|
|
|
|
assert Repo.aggregate(Object, :count, :id) == 0
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test "removes doubled 'to' recipients", %{user: user} do
|
|
|
|
|
{:ok, activity} =
|
|
|
|
|
ActivityPub.create(%{
|
|
|
|
|
to: ["user1", "user1", "user2"],
|
|
|
|
@ -427,9 +467,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|
|
|
|
assert activity.recipients == ["user1", "user2", user.ap_id]
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test "increases user note count only for public activities" do
|
|
|
|
|
user = insert(:user)
|
|
|
|
|
|
|
|
|
|
test "increases user note count only for public activities", %{user: user} do
|
|
|
|
|
{:ok, _} =
|
|
|
|
|
CommonAPI.post(User.get_cached_by_id(user.id), %{
|
|
|
|
|
status: "1",
|
|
|
|
@ -458,8 +496,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|
|
|
|
assert user.note_count == 2
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test "increases replies count" do
|
|
|
|
|
user = insert(:user)
|
|
|
|
|
test "increases replies count", %{user: user} do
|
|
|
|
|
user2 = insert(:user)
|
|
|
|
|
|
|
|
|
|
{:ok, activity} = CommonAPI.post(user, %{status: "1", visibility: "public"})
|
|
|
|
|