WIP. Implement oembed route and handle both json/xml for "Note" type activity
[akkoma] / lib / pleroma / web / oembed / activity_representer.ex
1 defmodule Pleroma.Web.OEmbed.ActivityRepresenter do
2 alias Pleroma.{Activity, User, Object}
3 alias Pleroma.Web.OStatus.UserRepresenter
4
5 def to_simple_form(%{data: %{"object" => %{"type" => "Note"}}} = activity, user, with_author) do
6 h = fn str -> [to_charlist(str)] end
7
8 content = if activity.data["object"]["content"] do
9 [{:content, [], h.(activity.data["object"]["content"])}]
10 else
11 []
12 end
13
14 [
15 {:version, ["1.0"]},
16 {:type, ["link"]},
17 ] ++ content
18
19 end
20
21 def wrap_with_entry(simple_form) do
22 [ { :oembed, [], simple_form } ]
23 end
24
25 end