Revert "StatusController: deleting a status returns the original media IDs"

This reverts commit a6598128ca.

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak 2022-07-18 18:18:15 +02:00
parent 8277995c82
commit 2f28aba5a4
4 changed files with 1 additions and 78 deletions

View file

@ -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

View file

@ -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"

View file

@ -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

View file

@ -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