Merge branch 'develop' into fix/federation-reject-instances

This commit is contained in:
lain 2026-10-27 12:37:46 +00:00
commit 9d2c8d384e
8 changed files with 140 additions and 11 deletions

View file

@ -9,6 +9,7 @@ defmodule Pleroma.NotificationTest do
alias Pleroma.FollowingRelationship
alias Pleroma.Notification
alias Pleroma.Object
alias Pleroma.Repo
alias Pleroma.Tests.ObanHelpers
alias Pleroma.User
@ -276,6 +277,22 @@ defmodule Pleroma.NotificationTest do
assert {:ok, []} == Notification.create_notifications(status)
end
test "it creates notifications for objects without content when the user has filters" do
author = insert(:user)
user = insert(:user)
insert(:filter, user: user, phrase: "cofe", hide: true)
{:ok, status} = CommonAPI.post(author, %{status: "hey @#{user.nickname}"})
object = Object.normalize(status, fetch: false)
{:ok, _} =
object
|> Object.change(%{data: Map.delete(object.data, "content")})
|> Object.update_and_set_cache()
assert {:ok, [_]} = Notification.create_notifications(Pleroma.Activity.get_by_id(status.id))
end
test "it creates notifications if content matches with a not irreversible filter" do
user = insert(:user)
subscriber = insert(:user)

View file

@ -8,6 +8,8 @@ defmodule Pleroma.Web.ActivityPub.MRF.ObjectAgePolicyTest do
alias Pleroma.Web.ActivityPub.MRF.ObjectAgePolicy
alias Pleroma.Web.ActivityPub.Visibility
require Pleroma.Constants
setup do:
clear_config(:mrf_object_age,
threshold: 172_800,
@ -79,7 +81,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.ObjectAgePolicyTest do
{:ok, data} = ObjectAgePolicy.filter(data)
assert Visibility.get_visibility(%{data: data}) == "unlisted"
assert Visibility.get_visibility(%{data: data}) == "direct"
end
test "it delists an old post" do
@ -94,6 +96,90 @@ defmodule Pleroma.Web.ActivityPub.MRF.ObjectAgePolicyTest do
assert Visibility.get_visibility(%{data: data}) == "unlisted"
end
test "it keeps an old followers-only post private" do
clear_config([:mrf_object_age, :actions], [:delist])
data = get_old_message()
{:ok, user} = User.get_or_fetch_by_ap_id(data["actor"])
data =
data
|> Map.put("to", [user.follower_address])
|> Map.put("cc", [])
|> put_in(["object", "to"], [user.follower_address])
|> put_in(["object", "cc"], [])
{:ok, data} = ObjectAgePolicy.filter(data)
assert data["to"] == [user.follower_address]
assert data["cc"] == []
assert Visibility.get_visibility(%{data: data}) == "private"
assert data["object"]["to"] == data["to"]
assert data["object"]["cc"] == data["cc"]
end
test "it keeps an old direct message direct" do
clear_config([:mrf_object_age, :actions], [:delist])
data = get_old_message()
{:ok, _user} = User.get_or_fetch_by_ap_id(data["actor"])
recipient = "https://example.com/users/someone"
data =
data
|> Map.put("to", [recipient])
|> Map.put("cc", [])
|> put_in(["object", "to"], [recipient])
|> put_in(["object", "cc"], [])
{:ok, data} = ObjectAgePolicy.filter(data)
assert data["to"] == [recipient]
assert data["cc"] == []
assert Visibility.get_visibility(%{data: data}) == "direct"
end
test "it removes every copy of the follower address" do
clear_config([:mrf_object_age, :actions], [:strip_followers])
data = get_old_message()
{:ok, user} = User.get_or_fetch_by_ap_id(data["actor"])
public = Pleroma.Constants.as_public()
followers = [user.follower_address, user.follower_address]
data =
data
|> Map.put("to", [public])
|> Map.put("cc", followers)
|> put_in(["object", "to"], [public])
|> put_in(["object", "cc"], followers)
{:ok, data} = ObjectAgePolicy.filter(data)
assert data["to"] == [public]
assert data["cc"] == []
end
test "it does not duplicate addresses of an old unlisted post" do
clear_config([:mrf_object_age, :actions], [:delist, :strip_followers])
data = get_old_message()
{:ok, user} = User.get_or_fetch_by_ap_id(data["actor"])
public = Pleroma.Constants.as_public()
data =
data
|> Map.put("to", [user.follower_address])
|> Map.put("cc", [public])
|> put_in(["object", "to"], [user.follower_address])
|> put_in(["object", "cc"], [public])
{:ok, data} = ObjectAgePolicy.filter(data)
assert data["to"] == []
assert data["cc"] == [public]
end
test "it allows a new post" do
clear_config([:mrf_object_age, :actions], [:delist])

View file

@ -50,7 +50,9 @@ defmodule Pleroma.Web.Plugs.RateLimiterTest do
test "it restricts based on config values" do
limiter_name = :test_plug_opts
scale = 80
# Long enough that the bucket cannot expire during the test on slow CI.
# The test expires it explicitly with expire_ttl/2.
scale = 60_000
limit = 5
clear_config([Pleroma.Web.Endpoint, :http, :ip], {127, 0, 0, 1})
@ -184,7 +186,8 @@ defmodule Pleroma.Web.Plugs.RateLimiterTest do
test "can have limits separate from unauthenticated connections" do
limiter_name = :test_authenticated1
scale = 50
# Long enough that the bucket cannot expire during the test on slow CI.
scale = 60_000
limit = 5
clear_config([Pleroma.Web.Endpoint, :http, :ip], {8, 8, 8, 8})
clear_config([:rate_limit, limiter_name], [{1000, 1}, {scale, limit}])