2017-08-01 09:05:07 -06:00
|
|
|
defmodule Pleroma.Web.OStatus.DeleteHandlingTest do
|
|
|
|
use Pleroma.DataCase
|
|
|
|
|
|
|
|
import Pleroma.Factory
|
2019-01-29 03:12:28 -07:00
|
|
|
import Tesla.Mock
|
|
|
|
|
2019-02-10 14:57:38 -07:00
|
|
|
alias Pleroma.Repo
|
|
|
|
alias Pleroma.Activity
|
|
|
|
alias Pleroma.Object
|
2017-08-01 09:05:07 -06:00
|
|
|
alias Pleroma.Web.OStatus
|
|
|
|
|
2019-01-29 03:12:28 -07:00
|
|
|
setup do
|
|
|
|
mock(fn env -> apply(HttpRequestMock, :request, [env]) end)
|
|
|
|
:ok
|
|
|
|
end
|
|
|
|
|
2017-08-01 09:05:07 -06:00
|
|
|
describe "deletions" do
|
|
|
|
test "it removes the mentioned activity" do
|
|
|
|
note = insert(:note_activity)
|
|
|
|
second_note = insert(:note_activity)
|
2017-08-16 08:29:25 -06:00
|
|
|
user = insert(:user)
|
|
|
|
object = Object.get_by_ap_id(note.data["object"]["id"])
|
|
|
|
|
2018-02-12 02:13:54 -07:00
|
|
|
{:ok, like, _object} = Pleroma.Web.ActivityPub.ActivityPub.like(user, object)
|
2017-08-01 09:05:07 -06:00
|
|
|
|
2018-03-30 07:01:53 -06:00
|
|
|
incoming =
|
|
|
|
File.read!("test/fixtures/delete.xml")
|
|
|
|
|> String.replace(
|
|
|
|
"tag:mastodon.sdf.org,2017-06-10:objectId=310513:objectType=Status",
|
|
|
|
note.data["object"]["id"]
|
|
|
|
)
|
|
|
|
|
2017-09-04 10:47:46 -06:00
|
|
|
{:ok, [delete]} = OStatus.handle_incoming(incoming)
|
2017-08-01 09:05:07 -06:00
|
|
|
|
2018-12-24 17:00:06 -07:00
|
|
|
refute Repo.get(Activity, note.id)
|
|
|
|
refute Repo.get(Activity, like.id)
|
2018-12-24 14:29:13 -07:00
|
|
|
assert Object.get_by_ap_id(note.data["object"]["id"]).data["type"] == "Tombstone"
|
2017-08-01 09:05:07 -06:00
|
|
|
assert Repo.get(Activity, second_note.id)
|
|
|
|
assert Object.get_by_ap_id(second_note.data["object"]["id"])
|
2017-09-04 10:47:46 -06:00
|
|
|
|
|
|
|
assert delete.data["type"] == "Delete"
|
2017-08-01 09:05:07 -06:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|