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:
parent
8277995c82
commit
2f28aba5a4
4 changed files with 1 additions and 78 deletions
|
@ -27,7 +27,6 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
|
||||||
alias Pleroma.Workers.BackgroundWorker
|
alias Pleroma.Workers.BackgroundWorker
|
||||||
alias Pleroma.Workers.PollWorker
|
alias Pleroma.Workers.PollWorker
|
||||||
|
|
||||||
import Ecto.Changeset
|
|
||||||
import Ecto.Query
|
import Ecto.Query
|
||||||
import Pleroma.Web.ActivityPub.Utils
|
import Pleroma.Web.ActivityPub.Utils
|
||||||
import Pleroma.Web.ActivityPub.Visibility
|
import Pleroma.Web.ActivityPub.Visibility
|
||||||
|
@ -1454,15 +1453,7 @@ def upload(file, opts \\ []) do
|
||||||
with {:ok, data} <- Upload.store(file, opts) do
|
with {:ok, data} <- Upload.store(file, opts) do
|
||||||
obj_data = Maps.put_if_present(data, "actor", opts[:actor])
|
obj_data = Maps.put_if_present(data, "actor", opts[:actor])
|
||||||
|
|
||||||
# FIXME: If Objects used FlakeIds, we could pregenerate the ID
|
Repo.insert(%Object{data: obj_data})
|
||||||
# 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
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1365,11 +1365,6 @@ test "returns reblogs for users for whom reblogs have not been muted" do
|
||||||
%{test_file: test_file}
|
%{test_file: test_file}
|
||||||
end
|
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
|
test "sets a description if given", %{test_file: file} do
|
||||||
{:ok, %Object{} = object} = ActivityPub.upload(file, description: "a cool file")
|
{:ok, %Object{} = object} = ActivityPub.upload(file, description: "a cool file")
|
||||||
assert object.data["name"] == "a cool file"
|
assert object.data["name"] == "a cool file"
|
||||||
|
|
|
@ -10,7 +10,6 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
||||||
alias Pleroma.Object
|
alias Pleroma.Object
|
||||||
alias Pleroma.Tests.ObanHelpers
|
alias Pleroma.Tests.ObanHelpers
|
||||||
alias Pleroma.User
|
alias Pleroma.User
|
||||||
alias Pleroma.Web.ActivityPub.ActivityPub
|
|
||||||
alias Pleroma.Web.ActivityPub.Transmogrifier
|
alias Pleroma.Web.ActivityPub.Transmogrifier
|
||||||
alias Pleroma.Web.ActivityPub.Utils
|
alias Pleroma.Web.ActivityPub.Utils
|
||||||
alias Pleroma.Web.AdminAPI.AccountView
|
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"]["quoteUrl"] == quote_id
|
||||||
assert modified["object"]["quoteUri"] == quote_id
|
assert modified["object"]["quoteUri"] == quote_id
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
describe "user upgrade" do
|
describe "user upgrade" do
|
||||||
|
|
|
@ -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(activity1.id)
|
||||||
refute Activity.get_by_id(activity2.id)
|
refute Activity.get_by_id(activity2.id)
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
describe "reblogging" do
|
describe "reblogging" do
|
||||||
|
|
Loading…
Reference in a new issue