Add object id to uploaded attachments
This commit is contained in:
parent
d2d3532e5f
commit
237b220d71
|
@ -36,6 +36,7 @@ defmodule Pleroma.Upload do
|
||||||
alias Ecto.UUID
|
alias Ecto.UUID
|
||||||
alias Pleroma.Config
|
alias Pleroma.Config
|
||||||
alias Pleroma.Maps
|
alias Pleroma.Maps
|
||||||
|
alias Pleroma.Web.ActivityPub.Utils
|
||||||
require Logger
|
require Logger
|
||||||
|
|
||||||
@type source ::
|
@type source ::
|
||||||
|
@ -88,6 +89,7 @@ def store(upload, opts \\ []) do
|
||||||
{:ok, url_spec} <- Pleroma.Uploaders.Uploader.put_file(opts.uploader, upload) do
|
{:ok, url_spec} <- Pleroma.Uploaders.Uploader.put_file(opts.uploader, upload) do
|
||||||
{:ok,
|
{:ok,
|
||||||
%{
|
%{
|
||||||
|
"id" => Utils.generate_object_id(),
|
||||||
"type" => opts.activity_type,
|
"type" => opts.activity_type,
|
||||||
"mediaType" => upload.content_type,
|
"mediaType" => upload.content_type,
|
||||||
"url" => [
|
"url" => [
|
||||||
|
|
|
@ -49,9 +49,11 @@ def put_file(upload), do: TestUploaderBase.put_file(upload, __MODULE__)
|
||||||
test "it returns file" do
|
test "it returns file" do
|
||||||
File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
|
File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
|
||||||
|
|
||||||
assert Upload.store(@upload_file) ==
|
assert {:ok, result} = Upload.store(@upload_file)
|
||||||
{:ok,
|
|
||||||
|
assert result ==
|
||||||
%{
|
%{
|
||||||
|
"id" => result["id"],
|
||||||
"name" => "image.jpg",
|
"name" => "image.jpg",
|
||||||
"type" => "Document",
|
"type" => "Document",
|
||||||
"mediaType" => "image/jpeg",
|
"mediaType" => "image/jpeg",
|
||||||
|
@ -62,7 +64,7 @@ test "it returns file" do
|
||||||
"type" => "Link"
|
"type" => "Link"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}}
|
}
|
||||||
|
|
||||||
Task.await(Agent.get(TestUploaderSuccess, fn task_pid -> task_pid end))
|
Task.await(Agent.get(TestUploaderSuccess, fn task_pid -> task_pid end))
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue