]> git.mxchange.org Git - friendica.git/blobdiff - src/Factory/Notification/Notification.php
Fix notices
[friendica.git] / src / Factory / Notification / Notification.php
index cedc0ad656813f71fc522a24b3e43489bb239637..1167c5a75ce63981cd948162d029e08f13b9bcaa 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
  *
@@ -32,7 +32,7 @@ use Friendica\Core\PConfig\IPConfig;
 use Friendica\Core\Protocol;
 use Friendica\Core\Session\ISession;
 use Friendica\Database\Database;
-use Friendica\Model\Item;
+use Friendica\Model\Post;
 use Friendica\Module\BaseNotifications;
 use Friendica\Network\HTTPException\InternalServerErrorException;
 use Friendica\Object\Api\Friendica\Notification as ApiNotification;
@@ -56,7 +56,7 @@ class Notification extends BaseFactory
 {
        /** @var Database */
        private $dba;
-       /** @var Repository\Notify */
+       /** @var Repository\Notification */
        private $notification;
        /** @var BaseURL */
        private $baseUrl;
@@ -65,7 +65,7 @@ class Notification extends BaseFactory
        /** @var string */
        private $nurl;
 
-       public function __construct(LoggerInterface $logger, Database $dba, Repository\Notify $notification, BaseURL $baseUrl, L10n $l10n, App $app, IPConfig $pConfig, ISession $session)
+       public function __construct(LoggerInterface $logger, Database $dba, Repository\Notification $notification, BaseURL $baseUrl, L10n $l10n, App $app, IPConfig $pConfig, ISession $session)
        {
                parent::__construct($logger);
 
@@ -97,7 +97,7 @@ class Notification extends BaseFactory
 
                $item['label'] = (($item['gravity'] == GRAVITY_PARENT) ? 'post' : 'comment');
                $item['link']  = $this->baseUrl->get(true) . '/display/' . $item['parent-guid'];
-               $item['image'] = Proxy::proxifyUrl($item['author-avatar'], false, Proxy::SIZE_MICRO);
+               $item['image'] = $item['author-avatar'];
                $item['url']   = $item['author-link'];
                $item['text']  = (($item['gravity'] == GRAVITY_PARENT)
                        ? $this->l10n->t("%s created a new post", $item['author-name'])
@@ -125,7 +125,7 @@ class Notification extends BaseFactory
                                return new \Friendica\Object\Notification\Notification([
                                        'label' => 'like',
                                        'link'  => $this->baseUrl->get(true) . '/display/' . $item['parent-guid'],
-                                       'image' => Proxy::proxifyUrl($item['author-avatar'], false, Proxy::SIZE_MICRO),
+                                       'image' => $item['author-avatar'],
                                        'url'   => $item['author-link'],
                                        'text'  => $this->l10n->t("%s liked %s's post", $item['author-name'], $item['parent-author-name']),
                                        'when'  => $item['when'],
@@ -136,7 +136,7 @@ class Notification extends BaseFactory
                                return new \Friendica\Object\Notification\Notification([
                                        'label' => 'dislike',
                                        'link'  => $this->baseUrl->get(true) . '/display/' . $item['parent-guid'],
-                                       'image' => Proxy::proxifyUrl($item['author-avatar'], false, Proxy::SIZE_MICRO),
+                                       'image' => $item['author-avatar'],
                                        'url'   => $item['author-link'],
                                        'text'  => $this->l10n->t("%s disliked %s's post", $item['author-name'], $item['parent-author-name']),
                                        'when'  => $item['when'],
@@ -147,7 +147,7 @@ class Notification extends BaseFactory
                                return new \Friendica\Object\Notification\Notification([
                                        'label' => 'attend',
                                        'link'  => $this->baseUrl->get(true) . '/display/' . $item['parent-guid'],
-                                       'image' => Proxy::proxifyUrl($item['author-avatar'], false, Proxy::SIZE_MICRO),
+                                       'image' => $item['author-avatar'],
                                        'url'   => $item['author-link'],
                                        'text'  => $this->l10n->t("%s is attending %s's event", $item['author-name'], $item['parent-author-name']),
                                        'when'  => $item['when'],
@@ -158,7 +158,7 @@ class Notification extends BaseFactory
                                return new \Friendica\Object\Notification\Notification([
                                        'label' => 'attendno',
                                        'link'  => $this->baseUrl->get(true) . '/display/' . $item['parent-guid'],
-                                       'image' => Proxy::proxifyUrl($item['author-avatar'], false, Proxy::SIZE_MICRO),
+                                       'image' => $item['author-avatar'],
                                        'url'   => $item['author-link'],
                                        'text'  => $this->l10n->t("%s is not attending %s's event", $item['author-name'], $item['parent-author-name']),
                                        'when'  => $item['when'],
@@ -169,7 +169,7 @@ class Notification extends BaseFactory
                                return new \Friendica\Object\Notification\Notification([
                                        'label' => 'attendmaybe',
                                        'link'  => $this->baseUrl->get(true) . '/display/' . $item['parent-guid'],
-                                       'image' => Proxy::proxifyUrl($item['author-avatar'], false, Proxy::SIZE_MICRO),
+                                       'image' => $item['author-avatar'],
                                        'url'   => $item['author-link'],
                                        'text'  => $this->l10n->t("%s may attending %s's event", $item['author-name'], $item['parent-author-name']),
                                        'when'  => $item['when'],
@@ -196,7 +196,7 @@ class Notification extends BaseFactory
                                return new \Friendica\Object\Notification\Notification([
                                        'label' => 'friend',
                                        'link'  => $this->baseUrl->get(true) . '/display/' . $item['parent-guid'],
-                                       'image' => Proxy::proxifyUrl($item['author-avatar'], false, Proxy::SIZE_MICRO),
+                                       'image' => $item['author-avatar'],
                                        'url'   => $item['author-link'],
                                        'text'  => $this->l10n->t("%s is now friends with %s", $item['author-name'], $item['fname']),
                                        'when'  => $item['when'],
@@ -272,13 +272,13 @@ class Notification extends BaseFactory
                }
 
                $fields = ['id', 'parent', 'verb', 'author-name', 'unseen', 'author-link', 'author-avatar', 'contact-avatar',
-                       'network', 'created', 'object', 'parent-author-name', 'parent-author-link', 'parent-guid'];
+                       'network', 'created', 'object', 'parent-author-name', 'parent-author-link', 'parent-guid', 'gravity'];
                $params = ['order' => ['received' => true], 'limit' => [$start, $limit]];
 
                $formattedNotifications = [];
 
                try {
-                       $items = Item::selectForUser(local_user(), $fields, $conditions, $params);
+                       $items = Post::selectForUser(local_user(), $fields, $conditions, $params);
 
                        while ($item = $this->dba->fetch($items)) {
                                $formattedNotifications[] = $this->createFromItem($item);
@@ -302,24 +302,20 @@ class Notification extends BaseFactory
         */
        public function getPersonalList(bool $seen = false, int $start = 0, int $limit = BaseNotifications::DEFAULT_PAGE_LIMIT)
        {
-               $myUrl    = str_replace('http://', '', $this->nurl);
-               $diaspUrl = str_replace('/profile/', '/u/', $myUrl);
-
-               $condition = ["NOT `wall` AND `uid` = ? AND (`item`.`author-id` = ? OR `item`.`tag` REGEXP ? OR `item`.`tag` REGEXP ?)",
-                       local_user(), public_contact(), $myUrl . '\\]', $diaspUrl . '\\]'];
+               $condition = ["NOT `wall` AND `uid` = ? AND `author-id` = ?", local_user(), public_contact()];
 
                if (!$seen) {
                        $condition[0] .= " AND `unseen`";
                }
 
                $fields = ['id', 'parent', 'verb', 'author-name', 'unseen', 'author-link', 'author-avatar', 'contact-avatar',
-                       'network', 'created', 'object', 'parent-author-name', 'parent-author-link', 'parent-guid'];
+                       'network', 'created', 'object', 'parent-author-name', 'parent-author-link', 'parent-guid', 'gravity'];
                $params = ['order' => ['received' => true], 'limit' => [$start, $limit]];
 
                $formattedNotifications = [];
 
                try {
-                       $items = Item::selectForUser(local_user(), $fields, $condition, $params);
+                       $items = Post::selectForUser(local_user(), $fields, $condition, $params);
 
                        while ($item = $this->dba->fetch($items)) {
                                $formattedNotifications[] = $this->createFromItem($item);
@@ -350,13 +346,13 @@ class Notification extends BaseFactory
                }
 
                $fields = ['id', 'parent', 'verb', 'author-name', 'unseen', 'author-link', 'author-avatar', 'contact-avatar',
-                       'network', 'created', 'object', 'parent-author-name', 'parent-author-link', 'parent-guid'];
+                       'network', 'created', 'object', 'parent-author-name', 'parent-author-link', 'parent-guid', 'gravity'];
                $params = ['order' => ['received' => true], 'limit' => [$start, $limit]];
 
                $formattedNotifications = [];
 
                try {
-                       $items = Item::selectForUser(local_user(), $fields, $condition, $params);
+                       $items = Post::selectForUser(local_user(), $fields, $condition, $params);
 
                        while ($item = $this->dba->fetch($items)) {
                                $item = $this->formatItem($item);