1
0
Fork 0
forked from AkkomaGang/akkoma

Merge branch 'bugfix/object-age-create' into 'develop'

ObjectAgePolicy: Fix pattern matching on published

See merge request 
This commit is contained in:
Haelwenn 2021-08-10 18:16:02 +00:00
commit 8679a57a71
2 changed files with 6 additions and 1 deletions
lib/pleroma/web/activity_pub/mrf
test/pleroma/web/activity_pub/mrf

View file

@ -49,6 +49,8 @@ defp check_delist(message, actions) do
message
|> Map.put("to", to)
|> Map.put("cc", cc)
|> Kernel.put_in(["object", "to"], to)
|> Kernel.put_in(["object", "cc"], cc)
{:ok, message}
else
@ -70,6 +72,8 @@ defp check_strip_followers(message, actions) do
message
|> Map.put("to", to)
|> Map.put("cc", cc)
|> Kernel.put_in(["object", "to"], to)
|> Kernel.put_in(["object", "cc"], cc)
{:ok, message}
else
@ -82,7 +86,7 @@ defp check_strip_followers(message, actions) do
end
@impl true
def filter(%{"type" => "Create", "published" => _} = message) do
def filter(%{"type" => "Create", "object" => %{"published" => _}} = message) do
with actions <- Config.get([:mrf_object_age, :actions]),
{:reject, _} <- check_date(message),
{:ok, message} <- check_reject(message, actions),

View file

@ -22,6 +22,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.ObjectAgePolicyTest do
defp get_old_message do
File.read!("test/fixtures/mastodon-post-activity.json")
|> Jason.decode!()
|> Map.drop(["published"])
end
defp get_new_message do