logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://anongit.hacktivis.me/git/pleroma.git/

rel_me.ex (822B)


  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.Web.Metadata.Providers.RelMe do
  5. alias Pleroma.Web.Metadata.Providers.Provider
  6. @behaviour Provider
  7. @impl Provider
  8. def build_tags(%{user: user}) do
  9. profile_tree =
  10. user.bio
  11. |> append_fields_tag(user.fields)
  12. |> Floki.parse_fragment!()
  13. (Floki.attribute(profile_tree, "link[rel~=me]", "href") ++
  14. Floki.attribute(profile_tree, "a[rel~=me]", "href"))
  15. |> Enum.map(fn link ->
  16. {:link, [rel: "me", href: link], []}
  17. end)
  18. end
  19. @impl Provider
  20. def build_tags(_), do: []
  21. defp append_fields_tag(bio, fields) do
  22. fields
  23. |> Enum.reduce(bio, fn %{"value" => v}, res -> res <> v end)
  24. end
  25. end