aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/chat.ex7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/pleroma/chat.ex b/lib/pleroma/chat.ex
index 2475019d1..c2044881f 100644
--- a/lib/pleroma/chat.ex
+++ b/lib/pleroma/chat.ex
@@ -26,6 +26,13 @@ defmodule Pleroma.Chat do
def creation_cng(struct, params) do
struct
|> cast(params, [:user_id, :recipient, :unread])
+ |> validate_change(:recipient, fn
+ :recipient, recipient ->
+ case User.get_cached_by_ap_id(recipient) do
+ nil -> [recipient: "must a an existing user"]
+ _ -> []
+ end
+ end)
|> validate_required([:user_id, :recipient])
|> unique_constraint(:user_id, name: :chats_user_id_recipient_index)
end