]> git.mxchange.org Git - friendica.git/blob - src/Navigation/Notifications/Entity/Notification.php
Don't create empty announce notifications
[friendica.git] / src / Navigation / Notifications / Entity / Notification.php
1 <?php
2 /**
3  * @copyright Copyright (C) 2010-2022, the Friendica project
4  *
5  * @license GNU AGPL version 3 or any later version
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Affero General Public License as
9  * published by the Free Software Foundation, either version 3 of the
10  * License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU Affero General Public License for more details.
16  *
17  * You should have received a copy of the GNU Affero General Public License
18  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19  *
20  */
21
22 namespace Friendica\Navigation\Notifications\Entity;
23
24 use DateTime;
25 use Friendica\BaseEntity;
26
27 /**
28  * @property-read $id
29  * @property-read $uid
30  * @property-read $verb
31  * @property-read $type
32  * @property-read $actorId
33  * @property-read $targetUriId
34  * @property-read $parentUriId
35  * @property-read $created
36  * @property-read $seen
37  * @property-read $dismissed
38  */
39 class Notification extends BaseEntity
40 {
41         /** @var int */
42         protected $id;
43         /** @var int */
44         protected $uid;
45         /** @var string */
46         protected $verb;
47         /**
48          * @var int One of the \Friendica\Model\Post\UserNotification::TYPE_* constant values
49          * @see \Friendica\Model\Post\UserNotification
50          */
51         protected $type;
52         /** @var int */
53         protected $actorId;
54         /** @var int */
55         protected $targetUriId;
56         /** @var int */
57         protected $parentUriId;
58         /** @var DateTime */
59         protected $created;
60         /** @var bool */
61         protected $seen;
62         /** @var bool */
63         protected $dismissed;
64
65         /**
66          * Please do not use this constructor directly, instead use one of the method of the Notification factory.
67          *
68          * @param int           $uid
69          * @param string        $verb
70          * @param int           $type
71          * @param int           $actorId
72          * @param int|null      $targetUriId
73          * @param int|null      $parentUriId
74          * @param DateTime|null $created
75          * @param bool          $seen
76          * @param bool          $dismissed
77          * @param int|null      $id
78          * @see \Friendica\Navigation\Notifications\Factory\Notification
79          */
80         public function __construct(int $uid, string $verb, int $type, int $actorId, int $targetUriId = null, int $parentUriId = null, DateTime $created = null, bool $seen = false, bool $dismissed = false, int $id = null)
81         {
82                 $this->uid         = $uid;
83                 $this->verb        = $verb;
84                 $this->type        = $type;
85                 $this->actorId     = $actorId;
86                 $this->targetUriId = $targetUriId;
87                 $this->parentUriId = $parentUriId ?: $targetUriId;
88                 $this->created     = $created;
89                 $this->seen        = $seen;
90                 $this->dismissed   = $dismissed;
91
92                 $this->id          = $id;
93         }
94
95         public function setSeen()
96         {
97                 $this->seen = true;
98         }
99
100         public function setDismissed()
101         {
102                 $this->dismissed = true;
103         }
104 }