2017-03-30 16:08:49 +02:00
|
|
|
defmodule Pleroma.Web.TwitterAPI.Representers.ObjectRepresenter do
|
|
|
|
use Pleroma.Web.TwitterAPI.Representers.BaseRepresenter
|
|
|
|
alias Pleroma.Object
|
|
|
|
|
|
|
|
def to_map(%Object{} = object, _opts) do
|
|
|
|
data = object.data
|
|
|
|
url = List.first(data["url"])
|
|
|
|
%{
|
2017-11-22 19:06:07 +01:00
|
|
|
url: url["href"] |> Pleroma.Web.MediaProxy.url(),
|
2017-03-30 16:08:49 +02:00
|
|
|
mimetype: url["mediaType"],
|
2017-03-30 17:07:03 +02:00
|
|
|
id: data["uuid"],
|
2017-03-30 16:08:49 +02:00
|
|
|
oembed: false
|
|
|
|
}
|
|
|
|
end
|
2017-03-30 17:07:03 +02:00
|
|
|
|
|
|
|
# If we only get the naked data, wrap in an object
|
|
|
|
def to_map(%{} = data, opts) do
|
|
|
|
to_map(%Object{data: data}, opts)
|
|
|
|
end
|
2017-03-30 16:08:49 +02:00
|
|
|
end
|