end
end
+ # Do not return instance default avatar for federation
+ def avatar_url_ap(user) do
+ case user.avatar do
+ %{"url" => [%{"href" => href} | _]} -> href
+ _ -> nil
+ end
+ end
+
def banner_url(user) do
case user.info.banner do
%{"url" => [%{"href" => href} | _]} -> href
end)
end
+ # Only federate user icon if not nil
+ # Prevents federating instance default avatars
+ def maybe_make_icon(user) do
+ if User.avatar_url_ap(user) do
+ %{
+ "icon" => %{
+ "type" => "Image",
+ "url" => User.avatar_url_ap(user)
+ }
+ }
+ else
+ []
+ end
+ end
+
#### Like-related helpers
@doc """
"publicKeyPem" => public_key
},
"endpoints" => endpoints,
- "icon" => %{
- "type" => "Image",
- "url" => User.avatar_url(user)
- },
"image" => %{
"type" => "Image",
"url" => User.banner_url(user)
},
"tag" => user.info.source_data["tag"] || []
}
+ |> Map.merge(Utils.maybe_make_icon(user))
|> Map.merge(Utils.make_json_ld_header())
end