X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=test%2Fconversation_test.exs;h=aa193e0d40dadf907f974ef2cfa378ee7788844e;hb=f84fb340b7358df195734f2db199e76a819e45bf;hp=cdec18f0f2f68dbe3d1cc3df0d024438f73e6fe7;hpb=a33bec7d58091059d578f6b7537513de11eb0679;p=akkoma diff --git a/test/conversation_test.exs b/test/conversation_test.exs index cdec18f0f..aa193e0d4 100644 --- a/test/conversation_test.exs +++ b/test/conversation_test.exs @@ -4,11 +4,23 @@ defmodule Pleroma.ConversationTest do use Pleroma.DataCase + alias Pleroma.Activity alias Pleroma.Conversation + alias Pleroma.Object alias Pleroma.Web.CommonAPI import Pleroma.Factory + setup_all do + config_path = [:instance, :federating] + initial_setting = Pleroma.Config.get(config_path) + + Pleroma.Config.put(config_path, true) + on_exit(fn -> Pleroma.Config.put(config_path, initial_setting) end) + + :ok + end + test "it goes through old direct conversations" do user = insert(:user) other_user = insert(:user) @@ -154,4 +166,40 @@ defmodule Pleroma.ConversationTest do assert {:error, _} = Conversation.create_or_bump_for(activity) end + + test "create_or_bump_for does not normalize objects before checking the activity type" do + note = insert(:note) + note_id = note.data["id"] + Repo.delete(note) + refute Object.get_by_ap_id(note_id) + + Tesla.Mock.mock(fn env -> + case env.url do + ^note_id -> + # TODO: add attributedTo and tag to the note factory + body = + note.data + |> Map.put("attributedTo", note.data["actor"]) + |> Map.put("tag", []) + |> Jason.encode!() + + %Tesla.Env{status: 200, body: body} + end + end) + + undo = %Activity{ + id: "fake", + data: %{ + "id" => Pleroma.Web.ActivityPub.Utils.generate_activity_id(), + "actor" => note.data["actor"], + "to" => [note.data["actor"]], + "object" => note_id, + "type" => "Undo" + } + } + + Conversation.create_or_bump_for(undo) + + refute Object.get_by_ap_id(note_id) + end end