]> git.mxchange.org Git - friendica.git/blobdiff - src/Navigation/Notifications/Factory/FormattedNavNotification.php
Fixes for the notifications
[friendica.git] / src / Navigation / Notifications / Factory / FormattedNavNotification.php
index a9498eaa58c2901f94b1c898cb7af246397c6107..d8d6dc029d255b75aa492a6a708bcc233fe37bcf 100644 (file)
@@ -25,6 +25,7 @@ use Friendica\BaseFactory;
 use Friendica\Core\Renderer;
 use Friendica\Model\Contact;
 use Friendica\Navigation\Notifications\Entity;
+use Friendica\Navigation\Notifications\Exception\NoMessageException;
 use Friendica\Navigation\Notifications\ValueObject;
 use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Proxy;
@@ -94,10 +95,22 @@ class FormattedNavNotification extends BaseFactory
                );
        }
 
+       /**
+        * @param Entity\Notification $notification
+        * @return ValueObject\FormattedNavNotification
+        * @throws NoMessageException
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+        * @throws \Friendica\Network\HTTPException\NotFoundException
+        * @throws \Friendica\Network\HTTPException\ServiceUnavailableException
+        */
        public function createFromNotification(Entity\Notification $notification): ValueObject\FormattedNavNotification
        {
                $message = $this->notification->getMessageFromNotification($notification);
 
+               if (empty($message)) {
+                       throw new NoMessageException();
+               }
+
                if (!isset(self::$contacts[$notification->actorId])) {
                        self::$contacts[$notification->actorId] = Contact::getById($notification->actorId, ['name', 'url']);
                }
@@ -119,8 +132,8 @@ class FormattedNavNotification extends BaseFactory
 
                return $this->createFromParams(
                        self::$contacts[$intro->cid],
-                       $this->l10n->t('{0}} wants to follow you'),
-                       new \DateTime($intro->datetime, new \DateTimeZone('UTC')),
+                       $this->l10n->t('{0} wants to follow you'),
+                       $intro->datetime,
                        new Uri($this->baseUrl->get() . '/notifications/intros/' . $intro->id)
                );
        }