WIP. Implement oembed route and handle both json/xml for "Note" type activity
[akkoma] / lib / pleroma / web / oembed / views / note_view.ex
1 defmodule Pleroma.Web.OEmbed.NoteView do
2 use Pleroma.Web, :view
3 alias Pleroma.{User, Activity}
4 alias Pleroma.Web.OEmbed
5
6 def render("note.json", %{type: type, entity: activity }) do
7 oembed_data(activity)
8 end
9
10 def oembed_data(activity) do
11 with %User{} = user <- User.get_cached_by_ap_id(activity.data["actor"]),
12 image = User.avatar_url(user) |> MediaProxy.url() do
13 %{
14 version: "1.0",
15 type: "link",
16 title: OEmbed.truncated_content(activity),
17 provider_url: "https://pleroma.site",
18 thumbnail_url: image,
19 }
20 end
21 end