diff --git a/include/api.php b/include/api.php index ef0e0bfbd0..5d6fb2add0 100644 --- a/include/api.php +++ b/include/api.php @@ -2633,7 +2633,7 @@ function api_direct_messages_new($type) $replyto = ''; if (!empty($_REQUEST['replyto'])) { - $mail = DBA::selectFirst('mail', ['parent-uri', 'title'], ['uid' => $uid, 'id' => $_REQUEST['replyto']]); + $mail = DBA::selectFirst('mail', ['parent-uri', 'title'], ['uid' => $uid, 'id' => $_REQUEST['replyto']]); $replyto = $mail['parent-uri']; $sub = $mail['title']; } else { @@ -2644,7 +2644,9 @@ function api_direct_messages_new($type) } } - $id = Mail::send($cid, $_POST['text'], $sub, $replyto); + $cdata = Contact::getPublicAndUserContactID($cid, $uid); + + $id = Mail::send($cdata['user'], $_POST['text'], $sub, $replyto); if ($id > -1) { $mail = DBA::selectFirst('mail', [], ['id' => $id]); diff --git a/tests/legacy/ApiTest.php b/tests/legacy/ApiTest.php index 593d48975b..cfe748977a 100644 --- a/tests/legacy/ApiTest.php +++ b/tests/legacy/ApiTest.php @@ -2236,6 +2236,7 @@ class ApiTest extends FixtureTest 'owner-id' => 43, 'plink' => '', 'uid' => $this->selfUser['id'], + 'uri-id' => 1, ] ]; foreach ($items as $item) { @@ -2261,6 +2262,7 @@ class ApiTest extends FixtureTest 'owner-id' => 43, 'plink' => '', 'uid' => $this->selfUser['id'], + 'uri-id' => 1, ] ];