ForceMentionsInContent: use `to` instead of `tag`

This commit is contained in:
Alex Gleason 2022-01-24 19:11:14 -06:00
parent 19d557c870
commit 1bbc701a3a
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
1 changed files with 2 additions and 5 deletions

View File

@ -35,15 +35,12 @@ defp extract_mention_uris_from_content(content) do
end end
@impl true @impl true
def filter(%{"type" => "Create", "object" => %{"type" => "Note", "tag" => tag}} = object) do def filter(%{"type" => "Create", "object" => %{"type" => "Note", "to" => to}} = object) do
# image-only posts from pleroma apparently reach this MRF without the content field # image-only posts from pleroma apparently reach this MRF without the content field
content = object["object"]["content"] || "" content = object["object"]["content"] || ""
mention_users = mention_users =
tag to
|> Enum.filter(fn tag -> tag["type"] == "Mention" end)
|> Enum.map(& &1["href"])
|> Enum.reject(&is_nil/1)
|> Enum.map(fn ap_id_or_uri -> |> Enum.map(fn ap_id_or_uri ->
case User.get_or_fetch_by_ap_id(ap_id_or_uri) do case User.get_or_fetch_by_ap_id(ap_id_or_uri) do
{:ok, user} -> {ap_id_or_uri, user} {:ok, user} -> {ap_id_or_uri, user}