X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModel%2FMail.php;h=e82a01fbce1a732190769cb20a150023cc89519e;hb=624e4c192c7f837ac0587a50da6e1409081eb519;hp=f9c197ffa0fa55dd7939fea61c098daa5f4162e6;hpb=353cd66b269d0d926eb88223939625e548184ff2;p=friendica.git diff --git a/src/Model/Mail.php b/src/Model/Mail.php index f9c197ffa0..e82a01fbce 100644 --- a/src/Model/Mail.php +++ b/src/Model/Mail.php @@ -1,6 +1,6 @@ $msg['parent-uri']]); @@ -92,7 +95,7 @@ class Mail DBA::update('conv', ['updated' => DateTimeFormat::utcNow()], ['id' => $msg['convid']]); } - if ($notifiction) { + if ($notification) { $user = User::getById($msg['uid']); // send notifications. $notif_params = [ @@ -139,11 +142,15 @@ class Mail return -2; } - $contact = DBA::selectFirst('contact', [], ['id' => $recipient, 'uid' => local_user()]); - if (!DBA::isResult($contact)) { + $contacts = ACL::getValidMessageRecipientsForUser(local_user()); + + $contactIndex = array_search($recipient, array_column($contacts, 'id')); + if ($contactIndex === false) { return -2; } + $contact = $contacts[$contactIndex]; + Photo::setPermissionFromBody($body, local_user(), $me['id'], '<' . $contact['id'] . '>', '', '', ''); $guid = System::createUUID(); @@ -167,27 +174,19 @@ class Mail $convuri = ''; if (!$convid) { // create a new conversation - $recip_host = substr($contact['url'], strpos($contact['url'], '://') + 3); - $recip_host = substr($recip_host, 0, strpos($recip_host, '/')); - - $recip_handle = (($contact['addr']) ? $contact['addr'] : $contact['nick'] . '@' . $recip_host); - $sender_handle = $a->getLoggedInUserNickname() . '@' . substr(DI::baseUrl(), strpos(DI::baseUrl(), '://') + 3); - $conv_guid = System::createUUID(); - $convuri = $recip_handle . ':' . $conv_guid; - - $handles = $recip_handle . ';' . $sender_handle; + $convuri = $contact['addr'] . ':' . $conv_guid; - $fields = ['uid' => local_user(), 'guid' => $conv_guid, 'creator' => $sender_handle, + $fields = ['uid' => local_user(), 'guid' => $conv_guid, 'creator' => $me['addr'], 'created' => DateTimeFormat::utcNow(), 'updated' => DateTimeFormat::utcNow(), - 'subject' => $subject, 'recips' => $handles]; + 'subject' => $subject, 'recips' => $contact['addr'] . ';' . $me['addr']]; if (DBA::insert('conv', $fields)) { $convid = DBA::lastInsertId(); } } if (!$convid) { - Logger::log('send message: conversation not found.'); + Logger::notice('send message: conversation not found.'); return -4; } @@ -291,7 +290,7 @@ class Mail } if (!$convid) { - Logger::log('send message: conversation not found.'); + Logger::notice('send message: conversation not found.'); return -4; }