mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-12-22 09:18:18 +00:00
[#1505] Added tests, changelog entry, tweaked config settings related to replies output on outgoing federation.
This commit is contained in:
parent
e84fee5b86
commit
d458f4fdca
|
@ -66,6 +66,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||
- Support for custom Elixir modules (such as MRF policies)
|
||||
- User settings: Add _This account is a_ option.
|
||||
- OAuth: admin scopes support (relevant setting: `[:auth, :enforce_oauth_admin_scope_usage]`).
|
||||
- ActivityPub: support for `replies` collection (output for outgoing federation & fetching on incoming federation).
|
||||
<details>
|
||||
<summary>API Changes</summary>
|
||||
|
||||
|
@ -107,6 +108,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||
- Configuration: `feed.logo` option for tag feed.
|
||||
- Tag feed: `/tags/:tag.rss` - list public statuses by hashtag.
|
||||
- Mastodon API: Add `reacted` property to `emoji_reactions`
|
||||
- ActivityPub: `[:activitypub, :note_replies_output_limit]` setting sets the number of note self-replies to output on outgoing federation.
|
||||
</details>
|
||||
|
||||
### Fixed
|
||||
|
|
|
@ -340,6 +340,7 @@ config :pleroma, :activitypub,
|
|||
unfollow_blocked: true,
|
||||
outgoing_blocks: true,
|
||||
follow_handshake_timeout: 500,
|
||||
note_replies_output_limit: 5,
|
||||
sign_object_fetches: true
|
||||
|
||||
config :pleroma, :streamer,
|
||||
|
@ -624,10 +625,6 @@ config :pleroma, :modules, runtime_dir: "instance/modules"
|
|||
|
||||
config :pleroma, configurable_from_database: false
|
||||
|
||||
config :pleroma, :mastodon_compatibility,
|
||||
# https://git.pleroma.social/pleroma/pleroma/issues/1505
|
||||
federated_note_replies_limit: 5
|
||||
|
||||
config :swarm, node_blacklist: [~r/myhtml_.*$/]
|
||||
# Import environment specific config. This must remain at the bottom
|
||||
# of this file so it overrides the configuration defined above.
|
||||
|
|
|
@ -1790,6 +1790,12 @@ config :pleroma, :config_description, [
|
|||
type: :boolean,
|
||||
description: "Sign object fetches with HTTP signatures"
|
||||
},
|
||||
%{
|
||||
key: :note_replies_output_limit,
|
||||
type: :integer,
|
||||
description:
|
||||
"The number of Note replies' URIs to be included with outgoing federation (`5` to match Mastodon hardcoded value, `0` to disable the output)."
|
||||
},
|
||||
%{
|
||||
key: :follow_handshake_timeout,
|
||||
type: :integer,
|
||||
|
@ -3097,20 +3103,6 @@ config :pleroma, :config_description, [
|
|||
}
|
||||
]
|
||||
},
|
||||
%{
|
||||
group: :pleroma,
|
||||
key: :mastodon_compatibility,
|
||||
type: :group,
|
||||
description: "Mastodon compatibility-related settings.",
|
||||
children: [
|
||||
%{
|
||||
key: :federated_note_replies_limit,
|
||||
type: :integer,
|
||||
description:
|
||||
"The number of Note self-reply URIs to be included with outgoing federation (`5` to mimic Mastodon hardcoded value, `0` to disable)."
|
||||
}
|
||||
]
|
||||
},
|
||||
%{
|
||||
group: :pleroma,
|
||||
type: :group,
|
||||
|
|
|
@ -914,7 +914,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
|
|||
Based on Mastodon's ActivityPub::NoteSerializer#replies.
|
||||
"""
|
||||
def set_replies(obj) do
|
||||
limit = Pleroma.Config.get([:mastodon_compatibility, :federated_note_replies_limit], 0)
|
||||
limit = Pleroma.Config.get([:activitypub, :note_replies_output_limit], 0)
|
||||
|
||||
replies_uris =
|
||||
with true <- limit > 0 || nil,
|
||||
|
@ -953,7 +953,13 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
|
|||
end
|
||||
|
||||
def replies(%{"replies" => replies = %{}}) do
|
||||
replies = with %{} <- replies["first"], do: replies["first"], else: (_ -> replies)
|
||||
replies =
|
||||
if is_map(replies["first"]) do
|
||||
replies["first"]
|
||||
else
|
||||
replies
|
||||
end
|
||||
|
||||
replies["items"] || []
|
||||
end
|
||||
|
||||
|
|
|
@ -15,6 +15,6 @@ defmodule Pleroma.Workers.RemoteFetcherWorker do
|
|||
},
|
||||
_job
|
||||
) do
|
||||
Fetcher.fetch_object_from_id!(id)
|
||||
{:ok, _object} = Fetcher.fetch_object_from_id(id)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1350,7 +1350,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
end
|
||||
end
|
||||
|
||||
describe "handle_incoming:`replies` handling" do
|
||||
describe "`replies` handling in handle_incoming/2" do
|
||||
setup do
|
||||
data =
|
||||
File.read!("test/fixtures/mastodon-post-activity.json")
|
||||
|
@ -1361,7 +1361,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
%{data: data, items: items, collection: collection}
|
||||
end
|
||||
|
||||
test "it schedules background fetching of wrapped `replies` collection items", %{
|
||||
test "with wrapped `replies` collection, it schedules background fetching of items", %{
|
||||
data: data,
|
||||
items: items,
|
||||
collection: collection
|
||||
|
@ -2096,8 +2096,8 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
end
|
||||
|
||||
describe "set_replies/1" do
|
||||
clear_config([:mastodon_compatibility, :federated_note_replies_limit]) do
|
||||
Pleroma.Config.put([:mastodon_compatibility, :federated_note_replies_limit], 2)
|
||||
clear_config([:activitypub, :note_replies_output_limit]) do
|
||||
Pleroma.Config.put([:activitypub, :note_replies_output_limit], 2)
|
||||
end
|
||||
|
||||
test "returns unmodified object if activity doesn't have self-replies" do
|
||||
|
@ -2116,7 +2116,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
{:ok, self_reply2} =
|
||||
CommonAPI.post(user, %{"status" => "self-reply 2", "in_reply_to_status_id" => id1})
|
||||
|
||||
# Assuming to _not_ be present in `replies` due to :federated_note_replies_limit is set to 2
|
||||
# Assuming to _not_ be present in `replies` due to :note_replies_output_limit is set to 2
|
||||
{:ok, _} =
|
||||
CommonAPI.post(user, %{"status" => "self-reply 3", "in_reply_to_status_id" => id1})
|
||||
|
||||
|
|
|
@ -36,6 +36,28 @@ defmodule Pleroma.Web.ActivityPub.ObjectViewTest do
|
|||
assert result["@context"]
|
||||
end
|
||||
|
||||
describe "note activity's `replies` collection rendering" do
|
||||
clear_config([:activitypub, :note_replies_output_limit]) do
|
||||
Pleroma.Config.put([:activitypub, :note_replies_output_limit], 5)
|
||||
end
|
||||
|
||||
test "renders `replies` collection for a note activity" do
|
||||
user = insert(:user)
|
||||
activity = insert(:note_activity, user: user)
|
||||
|
||||
{:ok, self_reply1} =
|
||||
CommonAPI.post(user, %{"status" => "self-reply 1", "in_reply_to_status_id" => activity.id})
|
||||
|
||||
result = ObjectView.render("object.json", %{object: refresh_record(activity)})
|
||||
replies_uris = [self_reply1.data["id"]]
|
||||
|
||||
assert %{
|
||||
"type" => "Collection",
|
||||
"first" => %{"type" => "Collection", "items" => ^replies_uris}
|
||||
} = get_in(result, ["object", "replies"])
|
||||
end
|
||||
end
|
||||
|
||||
test "renders a like activity" do
|
||||
note = insert(:note_activity)
|
||||
object = Object.normalize(note)
|
||||
|
|
Loading…
Reference in a new issue