forked from AkkomaGang/akkoma
Attachments: Have the mediaType on the root, too.
This commit is contained in:
parent
814c3e5171
commit
cc0d462e91
2 changed files with 24 additions and 0 deletions
|
@ -67,6 +67,7 @@ def store(upload, opts \\ []) do
|
||||||
{:ok,
|
{:ok,
|
||||||
%{
|
%{
|
||||||
"type" => opts.activity_type,
|
"type" => opts.activity_type,
|
||||||
|
"mediaType" => upload.content_type,
|
||||||
"url" => [
|
"url" => [
|
||||||
%{
|
%{
|
||||||
"type" => "Link",
|
"type" => "Link",
|
||||||
|
|
|
@ -25,6 +25,8 @@ test "works with honkerific attachments" do
|
||||||
assert {:ok, attachment} =
|
assert {:ok, attachment} =
|
||||||
AttachmentValidator.cast_and_validate(attachment)
|
AttachmentValidator.cast_and_validate(attachment)
|
||||||
|> Ecto.Changeset.apply_action(:insert)
|
|> Ecto.Changeset.apply_action(:insert)
|
||||||
|
|
||||||
|
assert attachment.mediaType == "application/octet-stream"
|
||||||
end
|
end
|
||||||
|
|
||||||
test "it turns mastodon attachments into our attachments" do
|
test "it turns mastodon attachments into our attachments" do
|
||||||
|
@ -48,6 +50,27 @@ test "it turns mastodon attachments into our attachments" do
|
||||||
mediaType: "image/jpeg"
|
mediaType: "image/jpeg"
|
||||||
}
|
}
|
||||||
] = attachment.url
|
] = attachment.url
|
||||||
|
|
||||||
|
assert attachment.mediaType == "image/jpeg"
|
||||||
|
end
|
||||||
|
|
||||||
|
test "it handles our own uploads" do
|
||||||
|
user = insert(:user)
|
||||||
|
|
||||||
|
file = %Plug.Upload{
|
||||||
|
content_type: "image/jpg",
|
||||||
|
path: Path.absname("test/fixtures/image.jpg"),
|
||||||
|
filename: "an_image.jpg"
|
||||||
|
}
|
||||||
|
|
||||||
|
{:ok, attachment} = ActivityPub.upload(file, actor: user.ap_id)
|
||||||
|
|
||||||
|
{:ok, attachment} =
|
||||||
|
attachment.data
|
||||||
|
|> AttachmentValidator.cast_and_validate()
|
||||||
|
|> Ecto.Changeset.apply_action(:insert)
|
||||||
|
|
||||||
|
assert attachment.mediaType == "image/jpeg"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue