aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrinpatch <rinpatch@sdf.org>2020-10-22 10:56:17 +0000
committerrinpatch <rinpatch@sdf.org>2020-10-22 10:56:17 +0000
commitd031b185e2c9f143b134b1813a799910adf10bad (patch)
tree98d9421f36187c94e52fb7c7561182f82373569e
parent77e827bb66ca42b11795133563b0d805c843fb56 (diff)
parent3fdc2a0d1e96b45bf71a822afeda72ea667e2b37 (diff)
downloadpleroma-d031b185e2c9f143b134b1813a799910adf10bad.tar.gz
Merge branch '2257-self-chat' into 'develop'
Resolve "Can't message yourself in a chat (but can start it)" Closes #2257 See merge request pleroma/pleroma!3099
-rw-r--r--CHANGELOG.md1
-rw-r--r--lib/pleroma/web/activity_pub/side_effects.ex1
-rw-r--r--test/pleroma/web/common_api_test.exs14
3 files changed, 16 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 05e94581a..afeaa930b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -47,6 +47,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
## Unreleased (Patch)
diff --git a/lib/pleroma/web/activity_pub/side_effects.ex b/lib/pleroma/web/activity_pub/side_effects.ex
index d421ca7af..0fff5faf2 100644
--- a/lib/pleroma/web/activity_pub/side_effects.ex
+++ b/lib/pleroma/web/activity_pub/side_effects.ex
@@ -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)
diff --git a/test/pleroma/web/common_api_test.exs b/test/pleroma/web/common_api_test.exs
index f5d09f396..d8dc90173 100644
--- a/test/pleroma/web/common_api_test.exs
+++ b/test/pleroma/web/common_api_test.exs
@@ -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)