Merge branch '2257-self-chat' into 'develop'
authorrinpatch <rinpatch@sdf.org>
Thu, 22 Oct 2020 10:56:17 +0000 (10:56 +0000)
committerrinpatch <rinpatch@sdf.org>
Wed, 4 Nov 2020 14:12:37 +0000 (17:12 +0300)
Resolve "Can't message yourself in a chat (but can start it)"

Closes #2257

See merge request pleroma/pleroma!3099

CHANGELOG.md
lib/pleroma/web/activity_pub/side_effects.ex
test/pleroma/web/common_api_test.exs

index 80ca6a350ddaa6dbe96be91f87677365c1b884d3..01038b7eca3151d2d99838aa5627f31653abf51a 100644 (file)
@@ -49,6 +49,7 @@ switched to a new configuration mechanism, however it was not officially removed
 
 - Add documented-but-missing chat pagination.
 - Allow sending out emails again.
+- Allow sending chat messages to yourself
 
 ### Upgrade notes
 
index d421ca7af59c713f6cba366bbecfbbd273f91d27..0fff5faf2d4a138978f6ff8c85097574e7f0320d 100644 (file)
@@ -306,6 +306,7 @@ defmodule Pleroma.Web.ActivityPub.SideEffects do
 
       streamables =
         [[actor, recipient], [recipient, actor]]
+        |> Enum.uniq()
         |> Enum.map(fn [user, other_user] ->
           if user.local do
             {:ok, chat} = Chat.bump_or_create(user.id, other_user.ap_id)
index 64476a099e8b53920d098472baf9ec3ee524fc41..c5b90ad84297b7d569eac29dd92069a6f9125328 100644 (file)
@@ -95,6 +95,20 @@ defmodule Pleroma.Web.CommonAPITest do
   describe "posting chat messages" do
     setup do: clear_config([:instance, :chat_limit])
 
+    test "it posts a self-chat" do
+      author = insert(:user)
+      recipient = author
+
+      {:ok, activity} =
+        CommonAPI.post_chat_message(
+          author,
+          recipient,
+          "remember to buy milk when milk truk arive"
+        )
+
+      assert activity.data["type"] == "Create"
+    end
+
     test "it posts a chat message without content but with an attachment" do
       author = insert(:user)
       recipient = insert(:user)