[#161] Refactoring, documentation.
This commit is contained in:
parent
1a46a13d15
commit
bc6d1f9ed9
|
@ -13,7 +13,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
- Not being able to access the Mastodon FE login page on private instances
|
- Not being able to access the Mastodon FE login page on private instances
|
||||||
- MRF: ensure that subdomain_match calls are case-insensitive
|
- MRF: ensure that subdomain_match calls are case-insensitive
|
||||||
- Fix internal server error when using the healthcheck API.
|
- Fix internal server error when using the healthcheck API.
|
||||||
- `federation_incoming_replies_max_depth` option being ignored in certain cases.
|
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
- **Breaking:** MRF describe API, which adds support for exposing configuration information about MRF policies to NodeInfo.
|
- **Breaking:** MRF describe API, which adds support for exposing configuration information about MRF policies to NodeInfo.
|
||||||
|
@ -24,6 +23,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
- Support for wildcard domains in user domain blocks setting.
|
- Support for wildcard domains in user domain blocks setting.
|
||||||
- Configuration: `quarantined_instances` support wildcard domains.
|
- Configuration: `quarantined_instances` support wildcard domains.
|
||||||
- Mix Tasks: `mix pleroma.database fix_likes_collections`
|
- Mix Tasks: `mix pleroma.database fix_likes_collections`
|
||||||
|
- Federation: Support for restricting max. reply-to depth on fetching
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
- Federation: Remove `likes` from objects.
|
- Federation: Remove `likes` from objects.
|
||||||
|
|
|
@ -220,6 +220,7 @@
|
||||||
},
|
},
|
||||||
registrations_open: true,
|
registrations_open: true,
|
||||||
federating: true,
|
federating: true,
|
||||||
|
federation_incoming_replies_max_depth: 100,
|
||||||
federation_reachability_timeout_days: 7,
|
federation_reachability_timeout_days: 7,
|
||||||
federation_publisher_modules: [
|
federation_publisher_modules: [
|
||||||
Pleroma.Web.ActivityPub.Publisher,
|
Pleroma.Web.ActivityPub.Publisher,
|
||||||
|
|
|
@ -153,8 +153,6 @@ def fix_actor(%{"attributedTo" => actor} = object) do
|
||||||
|
|
||||||
def fix_in_reply_to(object, options \\ [])
|
def fix_in_reply_to(object, options \\ [])
|
||||||
|
|
||||||
def fix_in_reply_to(object, options \\ [])
|
|
||||||
|
|
||||||
def fix_in_reply_to(%{"inReplyTo" => in_reply_to} = object, options)
|
def fix_in_reply_to(%{"inReplyTo" => in_reply_to} = object, options)
|
||||||
when not is_nil(in_reply_to) do
|
when not is_nil(in_reply_to) do
|
||||||
in_reply_to_id =
|
in_reply_to_id =
|
||||||
|
@ -175,7 +173,7 @@ def fix_in_reply_to(%{"inReplyTo" => in_reply_to} = object, options)
|
||||||
|
|
||||||
object = Map.put(object, "inReplyToAtomUri", in_reply_to_id)
|
object = Map.put(object, "inReplyToAtomUri", in_reply_to_id)
|
||||||
|
|
||||||
if (options[:depth] || 1) <= Federator.max_replies_depth() do
|
if Federator.allowed_incoming_reply_depth?(options[:depth]) do
|
||||||
case get_obj_helper(in_reply_to_id, options) do
|
case get_obj_helper(in_reply_to_id, options) do
|
||||||
{:ok, replied_object} ->
|
{:ok, replied_object} ->
|
||||||
with %Activity{} = _activity <-
|
with %Activity{} = _activity <-
|
||||||
|
@ -339,7 +337,7 @@ def fix_type(%{"inReplyTo" => reply_id, "name" => _} = object, options)
|
||||||
when is_binary(reply_id) do
|
when is_binary(reply_id) do
|
||||||
reply =
|
reply =
|
||||||
with true <- Federator.allowed_incoming_reply_depth?(options[:depth]),
|
with true <- Federator.allowed_incoming_reply_depth?(options[:depth]),
|
||||||
{:ok, object} <- get_obj_helper(reply_id) do
|
{:ok, object} <- get_obj_helper(reply_id, options) do
|
||||||
object
|
object
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -22,11 +22,17 @@ def init do
|
||||||
refresh_subscriptions()
|
refresh_subscriptions()
|
||||||
end
|
end
|
||||||
|
|
||||||
@max_replies_depth 100
|
|
||||||
|
|
||||||
@doc "Addresses [memory leaks on recursive replies fetching](https://git.pleroma.social/pleroma/pleroma/issues/161)"
|
@doc "Addresses [memory leaks on recursive replies fetching](https://git.pleroma.social/pleroma/pleroma/issues/161)"
|
||||||
# credo:disable-for-previous-line Credo.Check.Readability.MaxLineLength
|
# credo:disable-for-previous-line Credo.Check.Readability.MaxLineLength
|
||||||
def max_replies_depth, do: @max_replies_depth
|
def allowed_incoming_reply_depth?(depth) do
|
||||||
|
max_replies_depth = Pleroma.Config.get([:instance, :federation_incoming_replies_max_depth])
|
||||||
|
|
||||||
|
if max_replies_depth do
|
||||||
|
(depth || 1) <= max_replies_depth
|
||||||
|
else
|
||||||
|
true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Client API
|
# Client API
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,7 @@ def fetch_replied_to_activity(entry, in_reply_to, options \\ []) do
|
||||||
activity
|
activity
|
||||||
else
|
else
|
||||||
_e ->
|
_e ->
|
||||||
with true <- (options[:depth] || 1) <= Federator.max_replies_depth(),
|
with true <- Federator.allowed_incoming_reply_depth?(options[:depth]),
|
||||||
in_reply_to_href when not is_nil(in_reply_to_href) <-
|
in_reply_to_href when not is_nil(in_reply_to_href) <-
|
||||||
XML.string_from_xpath("//thr:in-reply-to[1]/@href", entry),
|
XML.string_from_xpath("//thr:in-reply-to[1]/@href", entry),
|
||||||
{:ok, [activity | _]} <- OStatus.fetch_activity_from_url(in_reply_to_href, options) do
|
{:ok, [activity | _]} <- OStatus.fetch_activity_from_url(in_reply_to_href, options) do
|
||||||
|
|
|
@ -72,7 +72,7 @@ test "it does not fetch replied-to activities beyond max_replies_depth" do
|
||||||
data = Map.put(data, "object", object)
|
data = Map.put(data, "object", object)
|
||||||
|
|
||||||
with_mock Pleroma.Web.Federator,
|
with_mock Pleroma.Web.Federator,
|
||||||
max_replies_depth: fn -> 0 end do
|
allowed_incoming_reply_depth?: fn _ -> false end do
|
||||||
{:ok, returned_activity} = Transmogrifier.handle_incoming(data)
|
{:ok, returned_activity} = Transmogrifier.handle_incoming(data)
|
||||||
|
|
||||||
returned_object = Object.normalize(returned_activity.data["object"], false)
|
returned_object = Object.normalize(returned_activity.data["object"], false)
|
||||||
|
|
|
@ -298,7 +298,7 @@ test "handle incoming favorites with locally available object - GS, websub" do
|
||||||
incoming = File.read!("test/fixtures/incoming_note_activity_answer.xml")
|
incoming = File.read!("test/fixtures/incoming_note_activity_answer.xml")
|
||||||
|
|
||||||
with_mock Pleroma.Web.Federator,
|
with_mock Pleroma.Web.Federator,
|
||||||
max_replies_depth: fn -> 0 end do
|
allowed_incoming_reply_depth?: fn _ -> false end do
|
||||||
{:ok, [activity]} = OStatus.handle_incoming(incoming)
|
{:ok, [activity]} = OStatus.handle_incoming(incoming)
|
||||||
object = Object.normalize(activity.data["object"], false)
|
object = Object.normalize(activity.data["object"], false)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue