ForceMentionsInContent: simplify finding users

This commit is contained in:
Alex Gleason 2022-01-24 19:44:44 -06:00
parent d5644a52aa
commit c5a20c80c4
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7

View file

@ -41,13 +41,8 @@ defmodule Pleroma.Web.ActivityPub.MRF.ForceMentionsInContent do
mention_users =
to
|> Enum.map(fn ap_id_or_uri ->
case User.get_or_fetch_by_ap_id(ap_id_or_uri) do
{:ok, user} -> {ap_id_or_uri, user}
_ -> {ap_id_or_uri, User.get_by_uri(ap_id_or_uri)}
end
end)
|> Enum.reject(fn {_, user} -> user == nil end)
|> Enum.map(& {&1, User.get_cached_by_ap_id(&1)})
|> Enum.reject(fn {_, user} -> is_nil(user) end)
|> Enum.into(%{})
explicitly_mentioned_uris = extract_mention_uris_from_content(content)