forked from AkkomaGang/akkoma
SideEffects: Correctly handle chat messages sent to yourself
This commit is contained in:
parent
77e827bb66
commit
8d251096fe
2 changed files with 15 additions and 0 deletions
|
@ -306,6 +306,7 @@ def handle_object_creation(%{"type" => "ChatMessage"} = object, meta) do
|
||||||
|
|
||||||
streamables =
|
streamables =
|
||||||
[[actor, recipient], [recipient, actor]]
|
[[actor, recipient], [recipient, actor]]
|
||||||
|
|> Enum.uniq()
|
||||||
|> Enum.map(fn [user, other_user] ->
|
|> Enum.map(fn [user, other_user] ->
|
||||||
if user.local do
|
if user.local do
|
||||||
{:ok, chat} = Chat.bump_or_create(user.id, other_user.ap_id)
|
{:ok, chat} = Chat.bump_or_create(user.id, other_user.ap_id)
|
||||||
|
|
|
@ -95,6 +95,20 @@ test "it blocks and does not federate if outgoing blocks are disabled", %{
|
||||||
describe "posting chat messages" do
|
describe "posting chat messages" do
|
||||||
setup do: clear_config([:instance, :chat_limit])
|
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
|
test "it posts a chat message without content but with an attachment" do
|
||||||
author = insert(:user)
|
author = insert(:user)
|
||||||
recipient = insert(:user)
|
recipient = insert(:user)
|
||||||
|
|
Loading…
Reference in a new issue