2019-07-10 01:13:23 -04:00
|
|
|
# Pleroma: A lightweight social networking server
|
|
|
|
# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
|
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2017-08-01 11:05:07 -04:00
|
|
|
defmodule Pleroma.Web.OStatus.DeleteHandlingTest do
|
|
|
|
use Pleroma.DataCase
|
|
|
|
|
|
|
|
import Pleroma.Factory
|
2019-01-29 05:12:28 -05:00
|
|
|
import Tesla.Mock
|
|
|
|
|
2019-02-10 16:57:38 -05:00
|
|
|
alias Pleroma.Activity
|
|
|
|
alias Pleroma.Object
|
2017-08-01 11:05:07 -04:00
|
|
|
alias Pleroma.Web.OStatus
|
|
|
|
|
2019-01-29 05:12:28 -05:00
|
|
|
setup do
|
|
|
|
mock(fn env -> apply(HttpRequestMock, :request, [env]) end)
|
|
|
|
:ok
|
|
|
|
end
|
|
|
|
|
2017-08-01 11:05:07 -04:00
|
|
|
describe "deletions" do
|
|
|
|
test "it removes the mentioned activity" do
|
|
|
|
note = insert(:note_activity)
|
|
|
|
second_note = insert(:note_activity)
|
2019-07-08 12:53:02 -04:00
|
|
|
object = Object.normalize(note)
|
|
|
|
second_object = Object.normalize(second_note)
|
2017-08-16 10:29:25 -04:00
|
|
|
user = insert(:user)
|
|
|
|
|
2018-02-12 04:13:54 -05:00
|
|
|
{:ok, like, _object} = Pleroma.Web.ActivityPub.ActivityPub.like(user, object)
|
2017-08-01 11:05:07 -04:00
|
|
|
|
2018-03-30 09:01:53 -04:00
|
|
|
incoming =
|
|
|
|
File.read!("test/fixtures/delete.xml")
|
|
|
|
|> String.replace(
|
|
|
|
"tag:mastodon.sdf.org,2017-06-10:objectId=310513:objectType=Status",
|
2019-07-08 12:53:02 -04:00
|
|
|
object.data["id"]
|
2018-03-30 09:01:53 -04:00
|
|
|
)
|
|
|
|
|
2017-09-04 12:47:46 -04:00
|
|
|
{:ok, [delete]} = OStatus.handle_incoming(incoming)
|
2017-08-01 11:05:07 -04:00
|
|
|
|
2019-04-02 06:08:03 -04:00
|
|
|
refute Activity.get_by_id(note.id)
|
|
|
|
refute Activity.get_by_id(like.id)
|
2019-07-08 12:53:02 -04:00
|
|
|
assert Object.get_by_ap_id(object.data["id"]).data["type"] == "Tombstone"
|
2019-04-02 06:08:03 -04:00
|
|
|
assert Activity.get_by_id(second_note.id)
|
2019-07-08 12:53:02 -04:00
|
|
|
assert Object.get_by_ap_id(second_object.data["id"])
|
2017-09-04 12:47:46 -04:00
|
|
|
|
|
|
|
assert delete.data["type"] == "Delete"
|
2017-08-01 11:05:07 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|