]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Mail.php
Added logging
[friendica.git] / src / Model / Mail.php
index c0efe4f2334138f60cb3e118b64141588342c923..2670a5885f2d8ef57dde74d9fcc0dd723b0ab020 100644 (file)
@@ -27,7 +27,6 @@ use Friendica\Core\Worker;
 use Friendica\DI;
 use Friendica\Database\DBA;
 use Friendica\Model\Notify\Type;
-use Friendica\Network\Probe;
 use Friendica\Protocol\Activity;
 use Friendica\Util\DateTimeFormat;
 use Friendica\Worker\Delivery;
@@ -85,19 +84,12 @@ class Mail
 
                // send notifications.
                $notif_params = [
-                       'type' => Type::MAIL,
-                       'notify_flags' => $user['notify-flags'],
-                       'language' => $user['language'],
-                       'to_name' => $user['username'],
-                       'to_email' => $user['email'],
-                       'uid' => $user['uid'],
-                       'item' => $msg,
-                       'parent' => 0,
-                       'source_name' => $msg['from-name'],
-                       'source_link' => $msg['from-url'],
-                       'source_photo' => $msg['from-photo'],
-                       'verb' => Activity::POST,
-                       'otype' => 'mail'
+                       'type'  => Type::MAIL,
+                       'otype' => Notify\ObjectType::MAIL,
+                       'verb'  => Activity::POST,
+                       'uid'   => $user['uid'],
+                       'cid'   => $msg['contact-id'],
+                       'link'  => DI::baseUrl() . '/message/' . $msg['id'],
                ];
 
                notification($notif_params);
@@ -130,9 +122,12 @@ class Mail
                }
 
                $me = DBA::selectFirst('contact', [], ['uid' => local_user(), 'self' => true]);
-               $contact = DBA::selectFirst('contact', [], ['id' => $recipient, 'uid' => local_user()]);
+               if (!DBA::isResult($me)) {
+                       return -2;
+               }
 
-               if (!(count($me) && (count($contact)))) {
+               $contact = DBA::selectFirst('contact', [], ['id' => $recipient, 'uid' => local_user()]);
+               if (!DBA::isResult($contact)) {
                        return -2;
                }
 
@@ -267,8 +262,7 @@ class Mail
                $guid = System::createUUID();
                $uri = Item::newURI(local_user(), $guid);
 
-               $me = Probe::uri($replyto);
-
+               $me = Contact::getByURL($replyto);
                if (!$me['name']) {
                        return -2;
                }
@@ -277,10 +271,7 @@ class Mail
 
                $recip_handle = $recipient['nickname'] . '@' . substr(DI::baseUrl(), strpos(DI::baseUrl(), '://') + 3);
 
-               $sender_nick = basename($replyto);
-               $sender_host = substr($replyto, strpos($replyto, '://') + 3);
-               $sender_host = substr($sender_host, 0, strpos($sender_host, '/'));
-               $sender_handle = $sender_nick . '@' . $sender_host;
+               $sender_handle = $me['addr'];
 
                $handles = $recip_handle . ';' . $sender_handle;
 
@@ -313,7 +304,7 @@ class Mail
                                'reply' => 0,
                                'replied' => 0,
                                'uri' => $uri,
-                               'parent-uri' => $replyto,
+                               'parent-uri' => $me['url'],
                                'created' => DateTimeFormat::utcNow(),
                                'unknown' => 1
                        ]