- def get_status_card(status_id) do
- with %Activity{} = activity <- Repo.get(Activity, status_id),
- true <- ActivityPub.is_public?(activity),
- %Object{} = object <- Object.normalize(activity.data["object"]),
- page_url <- HTML.extract_first_external_url(object, object.data["content"]),
- {:ok, rich_media} <- Pleroma.Web.RichMedia.Parser.parse(page_url) do
- page_url = rich_media[:url] || page_url
- site_name = rich_media[:site_name] || URI.parse(page_url).host
-
- rich_media
- |> Map.take([:image, :title, :description])
- |> Map.put(:type, "link")
- |> Map.put(:provider_name, site_name)
- |> Map.put(:url, page_url)
- else
- _ -> %{}
- end
- end
-