From 456f7cab3e20b6affe5c5ed6c04631d5bbac3aca Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Sun, 28 Jan 2024 14:14:26 -0500 Subject: [PATCH] Pleroma.Web.PleromaAPI.ChatController: Dialyzer errors lib/pleroma/web/pleroma_api/controllers/chat_controller.ex:91:pattern_match The pattern can never match the type. Pattern: {:reject, _message} Type: nil ________________________________________________________________________________ lib/pleroma/web/pleroma_api/controllers/chat_controller.ex:96:pattern_match The pattern can never match the type. Pattern: {:error, _message} Type: nil --- lib/pleroma/web/pleroma_api/controllers/chat_controller.ex | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/pleroma/web/pleroma_api/controllers/chat_controller.ex b/lib/pleroma/web/pleroma_api/controllers/chat_controller.ex index 3d7b6a4a7..6158af60e 100644 --- a/lib/pleroma/web/pleroma_api/controllers/chat_controller.ex +++ b/lib/pleroma/web/pleroma_api/controllers/chat_controller.ex @@ -76,7 +76,7 @@ defmodule Pleroma.Web.PleromaAPI.ChatController do %{id: id} ) do with {:ok, chat} <- Chat.get_by_user_and_id(user, id), - %User{} = recipient <- User.get_cached_by_ap_id(chat.recipient), + {_, %User{} = recipient} <- {:user, User.get_cached_by_ap_id(chat.recipient)}, {:ok, activity} <- CommonAPI.post_chat_message(user, recipient, params[:content], media_id: params[:media_id], @@ -97,6 +97,11 @@ defmodule Pleroma.Web.PleromaAPI.ChatController do conn |> put_status(:bad_request) |> json(%{error: message}) + + {:user, nil} -> + conn + |> put_status(:bad_request) + |> json(%{error: "Recipient does not exist"}) end end