diff options
| author | lain <lain@soykaf.club> | 2020-04-10 14:47:56 +0200 | 
|---|---|---|
| committer | lain <lain@soykaf.club> | 2020-04-10 14:47:56 +0200 | 
| commit | 64c78581fe397b6d9356c52cf3f43becd2ff3b4e (patch) | |
| tree | cc65fcc7f7c369698affbe7e9b8e1050f7628efd /lib | |
| parent | 2cc68414245805dc3b83c200798e424f139e71fc (diff) | |
| download | pleroma-64c78581fe397b6d9356c52cf3f43becd2ff3b4e.tar.gz pleroma-64c78581fe397b6d9356c52cf3f43becd2ff3b4e.zip | |
Chat: Only create them for valid users for now.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/pleroma/chat.ex | 7 | 
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 | 
