test: transmogrifier: verify directMessage flag is sent outbound based on declared...
authorWilliam Pitcock <nenolod@dereferenced.org>
Sun, 23 Dec 2018 15:55:07 +0000 (15:55 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Sun, 20 Jan 2019 02:28:28 +0000 (02:28 +0000)
test/web/activity_pub/transmogrifier_test.exs

index 5aa136e65e16909ae8cc90fc0a29c43d00580eb5..c1d542245b5e493a12e3cbdb200f5a332cfa5bac 100644 (file)
@@ -902,6 +902,34 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
       assert modified["object"]["likes"]["type"] == "OrderedCollection"
       assert modified["object"]["likes"]["totalItems"] == 0
     end
+
+    test "the directMessage flag is present" do
+      user = insert(:user)
+      other_user = insert(:user)
+
+      {:ok, activity} = CommonAPI.post(user, %{"status" => "2hu :moominmamma:"})
+
+      {:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
+
+      assert modified["directMessage"] == false
+
+      {:ok, activity} =
+        CommonAPI.post(user, %{"status" => "@{other_user.nickname} :moominmamma:"})
+
+      {:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
+
+      assert modified["directMessage"] == false
+
+      {:ok, activity} =
+        CommonAPI.post(user, %{
+          "status" => "@{other_user.nickname} :moominmamma:",
+          "visibility" => "direct"
+        })
+
+      {:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
+
+      assert modified["directMessage"] == true
+    end
   end
 
   describe "user upgrade" do