diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index 3e4d859e74..800d369607 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -27,7 +27,6 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do alias Pleroma.Workers.BackgroundWorker alias Pleroma.Workers.PollWorker - import Ecto.Changeset import Ecto.Query import Pleroma.Web.ActivityPub.Utils import Pleroma.Web.ActivityPub.Visibility @@ -1454,15 +1453,7 @@ def upload(file, opts \\ []) do with {:ok, data} <- Upload.store(file, opts) do obj_data = Maps.put_if_present(data, "actor", opts[:actor]) - # FIXME: If Objects used FlakeIds, we could pregenerate the ID - # instead of calling the DB twice. - with {:ok, object} <- Repo.insert(%Object{data: obj_data}) do - new_data = Map.put(object.data, "id", object.id) - - object - |> change(data: new_data) - |> Repo.update() - end + Repo.insert(%Object{data: obj_data}) end end diff --git a/test/pleroma/web/activity_pub/activity_pub_test.exs b/test/pleroma/web/activity_pub/activity_pub_test.exs index 3064ffc810..88c86e9fa8 100644 --- a/test/pleroma/web/activity_pub/activity_pub_test.exs +++ b/test/pleroma/web/activity_pub/activity_pub_test.exs @@ -1365,11 +1365,6 @@ test "returns reblogs for users for whom reblogs have not been muted" do %{test_file: test_file} end - test "produces an ID", %{test_file: file} do - {:ok, %Object{} = object} = ActivityPub.upload(file) - assert object.data["id"] == object.id - end - test "sets a description if given", %{test_file: file} do {:ok, %Object{} = object} = ActivityPub.upload(file, description: "a cool file") assert object.data["name"] == "a cool file" diff --git a/test/pleroma/web/activity_pub/transmogrifier_test.exs b/test/pleroma/web/activity_pub/transmogrifier_test.exs index e01ed2f198..89bc460799 100644 --- a/test/pleroma/web/activity_pub/transmogrifier_test.exs +++ b/test/pleroma/web/activity_pub/transmogrifier_test.exs @@ -10,7 +10,6 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do alias Pleroma.Object alias Pleroma.Tests.ObanHelpers alias Pleroma.User - alias Pleroma.Web.ActivityPub.ActivityPub alias Pleroma.Web.ActivityPub.Transmogrifier alias Pleroma.Web.ActivityPub.Utils alias Pleroma.Web.AdminAPI.AccountView @@ -349,47 +348,6 @@ test "it prepares a quote post" do assert modified["object"]["quoteUrl"] == quote_id assert modified["object"]["quoteUri"] == quote_id end - - test "it drops attachment IDs" do - user = insert(:user) - - file = %Plug.Upload{ - content_type: "image/jpeg", - path: Path.absname("test/fixtures/image.jpg"), - filename: "an_image.jpg" - } - - {:ok, upload} = ActivityPub.upload(file, actor: user.ap_id) - {:ok, activity} = CommonAPI.post(user, %{status: "", media_ids: [upload.id]}) - - {:ok, %{"object" => %{"attachment" => [attachment]}}} = - Transmogrifier.prepare_outgoing(activity.data) - - refute attachment["id"] - assert attachment["type"] == "Document" - end - - test "Updates of Notes are handled" do - user = insert(:user) - - {:ok, activity} = CommonAPI.post(user, %{status: "everybody do the dinosaur :dinosaur:"}) - {:ok, update} = CommonAPI.update(user, activity, %{status: "mew mew :blank:"}) - - {:ok, prepared} = Transmogrifier.prepare_outgoing(update.data) - - assert %{ - "content" => "mew mew :blank:", - "tag" => [%{"name" => ":blank:", "type" => "Emoji"}], - "formerRepresentations" => %{ - "orderedItems" => [ - %{ - "content" => "everybody do the dinosaur :dinosaur:", - "tag" => [%{"name" => ":dinosaur:", "type" => "Emoji"}] - } - ] - } - } = prepared["object"] - end end describe "user upgrade" do diff --git a/test/pleroma/web/mastodon_api/controllers/status_controller_test.exs b/test/pleroma/web/mastodon_api/controllers/status_controller_test.exs index 2e5d51490b..92a218ea0e 100644 --- a/test/pleroma/web/mastodon_api/controllers/status_controller_test.exs +++ b/test/pleroma/web/mastodon_api/controllers/status_controller_test.exs @@ -1015,27 +1015,6 @@ test "when you're an admin or moderator", %{conn: conn} do refute Activity.get_by_id(activity1.id) refute Activity.get_by_id(activity2.id) end - - test "deleting a status with attachments returns the original IDs" do - %{user: user, conn: conn} = oauth_access(["write:statuses"]) - - file = %Plug.Upload{ - content_type: "image/jpeg", - path: Path.absname("test/fixtures/image.jpg"), - filename: "an_image.jpg" - } - - {:ok, upload} = ActivityPub.upload(file, actor: user.ap_id) - {:ok, activity} = CommonAPI.post(user, %{status: "", media_ids: [upload.id]}) - - expected = to_string(upload.id) - - assert %{"media_attachments" => [%{"id" => ^expected}]} = - conn - |> assign(:user, user) - |> delete("/api/v1/statuses/#{activity.id}") - |> json_response_and_validate_schema(200) - end end describe "reblogging" do