CommonFixes, Transmogrifier: Fix tests.
This commit is contained in:
parent
4496dc81c4
commit
ec58b6a4cc
2 changed files with 9 additions and 5 deletions
|
|
@ -20,13 +20,15 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.CommonFixes do
|
|||
require Pleroma.Constants
|
||||
|
||||
def cast_and_filter_recipients(message, field, follower_collection, field_fallback \\ []) do
|
||||
# calling this here since we need to fix as:Public address before ObjectID cast throws it out
|
||||
message =
|
||||
message
|
||||
# Fix as:Public/Public before ObjectID casting drops it, but keep `field_fallback`
|
||||
# semantics (only used when the field is missing).
|
||||
recipients =
|
||||
%{field => message[field] || field_fallback}
|
||||
|> Transmogrifier.fix_addressing_list(field)
|
||||
|> Transmogrifier.fix_addressing_public(field)
|
||||
|> Map.fetch!(field)
|
||||
|
||||
{:ok, data} = ObjectValidators.Recipients.cast(message[field] || field_fallback)
|
||||
{:ok, data} = ObjectValidators.Recipients.cast(recipients)
|
||||
|
||||
data =
|
||||
Enum.reject(data, fn x ->
|
||||
|
|
|
|||
|
|
@ -109,10 +109,12 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
|
|||
https://codeberg.org/bovine/bovine/issues/53
|
||||
"""
|
||||
def fix_addressing_public(map, field) do
|
||||
addrs = Map.get(map, field, []) |> List.wrap()
|
||||
|
||||
Map.put(
|
||||
map,
|
||||
field,
|
||||
Enum.map(Map.get(map, field), fn
|
||||
Enum.map(addrs, fn
|
||||
"Public" -> Pleroma.Constants.as_public()
|
||||
"as:Public" -> Pleroma.Constants.as_public()
|
||||
x -> x
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue