1
0
Fork 0
mirror of https://framagit.org/framasoft/mobilizon.git synced 2025-01-27 02:58:39 +00:00
mobilizon/lib/service/activity_pub/converter/picture.ex
2019-09-26 17:45:47 +02:00

28 lines
660 B
Elixir

defmodule Mobilizon.Service.ActivityPub.Converter.Picture do
@moduledoc """
Picture converter.
This module allows to convert events from ActivityStream format to our own
internal one, and back.
"""
alias Mobilizon.Media.Picture, as: PictureModel
@doc """
Convert a picture struct to an ActivityStream representation.
"""
@spec model_to_as(PictureModel.t()) :: map
def model_to_as(%PictureModel{file: file}) do
%{
"type" => "Document",
"url" => [
%{
"type" => "Link",
"mediaType" => file.content_type,
"href" => file.url
}
],
"name" => file.name
}
end
end