]> git.mxchange.org Git - friendica.git/blobdiff - mod/message.php
Merge pull request #10237 from annando/oauth-flow
[friendica.git] / mod / message.php
index 4f680aa0b7b7ebd448eecb65c3df326a1d8c6f77..06542bbaf24708f507448f88f817cc9c6aa4c755 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2020, Friendica
+ * @copyright Copyright (C) 2010-2021, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -29,7 +29,6 @@ use Friendica\Database\DBA;
 use Friendica\DI;
 use Friendica\Model\Contact;
 use Friendica\Model\Mail;
-use Friendica\Model\Notify\Type;
 use Friendica\Module\Security\Login;
 use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Strings;
@@ -282,7 +281,6 @@ function message_content(App $a)
                        $messages = DBA::toArray($messages_stmt);
 
                        DBA::update('mail', ['seen' => 1], ['parent-uri' => $message['parent-uri'], 'uid' => local_user()]);
-                       DBA::update('notify', ['seen' => 1], ['type' => Type::MAIL, 'parent' => $message['id'], 'uid' => local_user()]);
                } else {
                        $messages = false;
                }
@@ -333,7 +331,7 @@ function message_content(App $a)
                                'id' => $message['id'],
                                'from_name' => $from_name_e,
                                'from_url' => $from_url,
-                               'from_addr' => $contact['addr'],
+                               'from_addr' => $contact['addr'] ?? $from_url,
                                'sparkle' => $sparkle,
                                'from_photo' => $from_photo,
                                'subject' => $subject_e,
@@ -386,7 +384,7 @@ function message_content(App $a)
  * @param int $limit
  * @return array
  */
-function get_messages($uid, $start, $limit)
+function get_messages(int $uid, int $start, int $limit)
 {
        return DBA::toArray(DBA::p('SELECT
                        m.`id`,
@@ -453,6 +451,11 @@ function render_messages(array $msg, $t)
                $body_e = $rr['body'];
                $to_name_e = $rr['name'];
 
+               if (is_null($rr['url'])) {
+                       // contact-id is pointing to a non existing contact
+                       continue;
+               }
+
                $contact = Contact::getByURL($rr['url'], false, ['thumb', 'addr', 'id', 'avatar']);
                $from_photo = Contact::getThumb($contact, $rr['thumb'] ?: $rr['from-photo']);