+
+ test "it creates a delete activity and checks that it is also sent to users mentioned by the deleted object" do
+ user = insert(:user)
+ note = insert(:note_activity)
+
+ {:ok, object} =
+ Object.get_by_ap_id(note.data["object"]["id"])
+ |> Object.change(%{
+ data: %{
+ "actor" => note.data["object"]["actor"],
+ "id" => note.data["object"]["id"],
+ "to" => [user.ap_id],
+ "type" => "Note"
+ }
+ })
+ |> Object.update_and_set_cache()
+
+ {:ok, delete} = ActivityPub.delete(object)
+
+ assert user.ap_id in delete.data["to"]
+ end
+
+ test "decreases reply count" do
+ user = insert(:user)
+ user2 = insert(:user)
+
+ {:ok, activity} = CommonAPI.post(user, %{"status" => "1", "visibility" => "public"})
+ reply_data = %{"status" => "1", "in_reply_to_status_id" => activity.id}
+ ap_id = activity.data["id"]
+
+ {:ok, public_reply} = CommonAPI.post(user2, Map.put(reply_data, "visibility", "public"))
+ {:ok, unlisted_reply} = CommonAPI.post(user2, Map.put(reply_data, "visibility", "unlisted"))
+ {:ok, private_reply} = CommonAPI.post(user2, Map.put(reply_data, "visibility", "private"))
+ {:ok, direct_reply} = CommonAPI.post(user2, Map.put(reply_data, "visibility", "direct"))
+
+ _ = CommonAPI.delete(direct_reply.id, user2)
+ assert %{data: data, object: object} = Activity.get_by_ap_id_with_object(ap_id)
+ assert data["object"]["repliesCount"] == 2
+ assert object.data["repliesCount"] == 2
+
+ _ = CommonAPI.delete(private_reply.id, user2)
+ assert %{data: data, object: object} = Activity.get_by_ap_id_with_object(ap_id)
+ assert data["object"]["repliesCount"] == 2
+ assert object.data["repliesCount"] == 2
+
+ _ = CommonAPI.delete(public_reply.id, user2)
+ assert %{data: data, object: object} = Activity.get_by_ap_id_with_object(ap_id)
+ assert data["object"]["repliesCount"] == 1
+ assert object.data["repliesCount"] == 1
+
+ _ = CommonAPI.delete(unlisted_reply.id, user2)
+ assert %{data: data, object: object} = Activity.get_by_ap_id_with_object(ap_id)
+ assert data["object"]["repliesCount"] == 0
+ assert object.data["repliesCount"] == 0
+ end