]> git.mxchange.org Git - friendica.git/commitdiff
Add NotFoundException for recipients in api_direct_messages_new()
authorHypolite Petovan <mrpetovan@gmail.com>
Sun, 1 Jul 2018 18:43:22 +0000 (14:43 -0400)
committerHypolite Petovan <mrpetovan@gmail.com>
Mon, 2 Jul 2018 11:48:59 +0000 (07:48 -0400)
include/api.php

index bd16206a5859e2994848e250b45b7e0d6a9c970a..cae93a372bae3af9a280ecd1596b27c41ac5b5c2 100644 (file)
@@ -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')) {