X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=test%2Fweb%2Factivity_pub%2Ftransmogrifier_test.exs;h=a3408da9db58a95983585a645879d68b6b5fb04d;hb=5bfb7b4ce6c23f84c27643e9871b78b867f86b7e;hp=060ebe9f10f04679fbb4bf4e0984cf6d6eb35f49;hpb=4afbef39f49948ddd3b1cd1bbda58ff7e3ac2785;p=akkoma diff --git a/test/web/activity_pub/transmogrifier_test.exs b/test/web/activity_pub/transmogrifier_test.exs index 060ebe9f1..a3408da9d 100644 --- a/test/web/activity_pub/transmogrifier_test.exs +++ b/test/web/activity_pub/transmogrifier_test.exs @@ -89,6 +89,10 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do "tag:mastodon.example.org,2018-02-12:objectId=20:objectType=Conversation" assert object["sensitive"] == true + + user = User.get_by_ap_id(object["actor"]) + + assert user.info["note_count"] == 1 end test "it works for incoming notices with hashtags" do @@ -102,7 +106,8 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do user = insert(:user) data = - File.read!("test/fixtures/mastodon-follow-activity.json") |> Poison.decode!() + File.read!("test/fixtures/mastodon-follow-activity.json") + |> Poison.decode!() |> Map.put("object", user.ap_id) {:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data) @@ -118,7 +123,8 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do {:ok, activity} = CommonAPI.post(user, %{"status" => "hello"}) data = - File.read!("test/fixtures/mastodon-like.json") |> Poison.decode!() + File.read!("test/fixtures/mastodon-like.json") + |> Poison.decode!() |> Map.put("object", activity.data["object"]["id"]) {:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data) @@ -226,6 +232,34 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do refute Repo.get(Activity, activity.id) end + + test "it works for incoming unannounces with an existing notice" do + user = insert(:user) + {:ok, activity} = CommonAPI.post(user, %{"status" => "hey"}) + + announce_data = + File.read!("test/fixtures/mastodon-announce.json") + |> Poison.decode!() + |> Map.put("object", activity.data["object"]["id"]) + + {:ok, %Activity{data: announce_data, local: false}} = + Transmogrifier.handle_incoming(announce_data) + + data = + File.read!("test/fixtures/mastodon-undo-announce.json") + |> Poison.decode!() + |> Map.put("object", announce_data) + |> Map.put("actor", announce_data["actor"]) + + {:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data) + + assert data["type"] == "Undo" + assert data["object"]["type"] == "Announce" + assert data["object"]["object"] == activity.data["object"]["id"] + + assert data["object"]["id"] == + "http://mastodon.example.org/users/admin/statuses/99542391527669785/activity" + end end describe "prepare outgoing" do