From 43688c04b16c093444a29f15193d9911fb84df2f Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 1 Jul 2018 14:43:22 -0400 Subject: [PATCH] Add NotFoundException for recipients in api_direct_messages_new() --- include/api.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/include/api.php b/include/api.php index bd16206a5..cae93a372 100644 --- a/include/api.php +++ b/include/api.php @@ -3487,14 +3487,20 @@ function api_direct_messages_new($type) dbesc($_POST['screen_name']) ); - // Selecting the id by priority, friendica first - api_best_nickname($r); + if (DBM::is_result($r)) { + // Selecting the id by priority, friendica first + api_best_nickname($r); - $recipient = api_get_user($a, $r[0]['nurl']); + $recipient = api_get_user($a, $r[0]['nurl']); + } } else { $recipient = api_get_user($a, $_POST['user_id']); } + if (empty($recipient)) { + throw new NotFoundException('Recipient not found'); + } + $replyto = ''; $sub = ''; if (x($_REQUEST, 'replyto')) {