logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma

delete_handling_test.exs (1405B)


      1 # Pleroma: A lightweight social networking server
      2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
      3 # SPDX-License-Identifier: AGPL-3.0-only
      4 
      5 defmodule Pleroma.Web.OStatus.DeleteHandlingTest do
      6   use Pleroma.DataCase
      7 
      8   import Pleroma.Factory
      9   import Tesla.Mock
     10 
     11   alias Pleroma.Activity
     12   alias Pleroma.Object
     13   alias Pleroma.Web.OStatus
     14 
     15   setup do
     16     mock(fn env -> apply(HttpRequestMock, :request, [env]) end)
     17     :ok
     18   end
     19 
     20   describe "deletions" do
     21     test "it removes the mentioned activity" do
     22       note = insert(:note_activity)
     23       second_note = insert(:note_activity)
     24       object = Object.normalize(note)
     25       second_object = Object.normalize(second_note)
     26       user = insert(:user)
     27 
     28       {:ok, like, _object} = Pleroma.Web.ActivityPub.ActivityPub.like(user, object)
     29 
     30       incoming =
     31         File.read!("test/fixtures/delete.xml")
     32         |> String.replace(
     33           "tag:mastodon.sdf.org,2017-06-10:objectId=310513:objectType=Status",
     34           object.data["id"]
     35         )
     36 
     37       {:ok, [delete]} = OStatus.handle_incoming(incoming)
     38 
     39       refute Activity.get_by_id(note.id)
     40       refute Activity.get_by_id(like.id)
     41       assert Object.get_by_ap_id(object.data["id"]).data["type"] == "Tombstone"
     42       assert Activity.get_by_id(second_note.id)
     43       assert Object.get_by_ap_id(second_object.data["id"])
     44 
     45       assert delete.data["type"] == "Delete"
     46     end
     47   end
     48 end