]> git.mxchange.org Git - friendica.git/blob - src/Moderation/Entity/Report.php
bump version 2023.12
[friendica.git] / src / Moderation / Entity / Report.php
1 <?php
2 /**
3  * @copyright Copyright (C) 2010-2023, 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\Moderation\Entity;
23
24 use Friendica\Moderation\Collection;
25
26 /**
27  * @property-read int                     $id
28  * @property-read int                     $reporterCid
29  * @property-read int                     $cid
30  * @property-read int                     $gsid
31  * @property-read string                  $comment
32  * @property-read string                  $publicRemarks
33  * @property-read string                  $privateRemarks
34  * @property-read bool                    $forward
35  * @property-read int                     $category
36  * @property-read int                     $status
37  * @property-read int|null                $resolution
38  * @property-read int                     $reporterUid
39  * @property-read int|null                $lastEditorUid
40  * @property-read int|null                $assignedUid
41  * @property-read \DateTimeImmutable      $created
42  * @property-read \DateTimeImmutable|null $edited
43  * @property-read Collection\Report\Posts $posts
44  * @property-read Collection\Report\Rules $rules
45  */
46 final class Report extends \Friendica\BaseEntity
47 {
48         const CATEGORY_OTHER = 1;
49         const CATEGORY_SPAM = 2;
50         const CATEGORY_ILLEGAL = 4;
51         const CATEGORY_SAFETY = 8;
52         const CATEGORY_UNWANTED = 16;
53         const CATEGORY_VIOLATION = 32;
54
55         const CATEGORIES  = [
56                 self::CATEGORY_OTHER,
57                 self::CATEGORY_SPAM,
58                 self::CATEGORY_ILLEGAL,
59                 self::CATEGORY_SAFETY,
60                 self::CATEGORY_UNWANTED,
61                 self::CATEGORY_VIOLATION,
62         ];
63
64         const STATUS_CLOSED = 0;
65         const STATUS_OPEN = 1;
66
67         const RESOLUTION_ACCEPTED = 0;
68         const RESOLUTION_REJECTED = 1;
69
70         /** @var int|null */
71         protected $id;
72         /** @var int ID of the contact making a moderation report */
73         protected $reporterCid;
74         /** @var int ID of the contact being reported */
75         protected $cid;
76         /** @var int ID of the gserver of the contact being reported */
77         protected $gsid;
78         /** @var string Reporter comment */
79         protected $comment;
80         /** @var int One of CATEGORY_* */
81         protected $category;
82         /** @var int ID of the user making a moderation report, null in case of an incoming forwarded report */
83         protected $reporterUid;
84         /** @var bool Whether this report should be forwarded to the remote server */
85         protected $forward;
86         /** @var \DateTimeImmutable When the report was created */
87         protected $created;
88         /** @var Collection\Report\Rules List of terms of service rule lines being possibly violated */
89         protected $rules;
90         /** @var Collection\Report\Posts List of URI IDs of posts supporting the report */
91         protected $posts;
92         /** @var string Remarks shared with the reporter */
93         protected $publicRemarks;
94         /** @var string Remarks shared with the moderation team */
95         protected $privateRemarks;
96         /** @var \DateTimeImmutable|null When the report was last edited */
97         protected $edited;
98         /** @var int One of STATUS_* */
99         protected $status;
100         /** @var int|null One of RESOLUTION_* if any */
101         protected $resolution;
102         /** @var int|null Assigned moderator user id if any */
103         protected $assignedUid;
104         /** @var int|null Last editor user ID if any */
105         protected $lastEditorUid;
106
107         public function __construct(
108                 int $reporterCid,
109                 int $cid,
110                 int $gsid,
111                 \DateTimeImmutable $created,
112                 int $category,
113                 int $reporterUid = null,
114                 string $comment = '',
115                 bool $forward = false,
116                 Collection\Report\Posts $posts = null,
117                 Collection\Report\Rules $rules = null,
118                 string $publicRemarks = '',
119                 string $privateRemarks = '',
120                 \DateTimeImmutable $edited = null,
121                 int $status = self::STATUS_OPEN,
122                 int $resolution = null,
123                 int $assignedUid = null,
124                 int $lastEditorUid = null,
125                 int $id = null
126         ) {
127                 $this->reporterCid    = $reporterCid;
128                 $this->cid            = $cid;
129                 $this->gsid           = $gsid;
130                 $this->created        = $created;
131                 $this->category       = $category;
132                 $this->reporterUid    = $reporterUid;
133                 $this->comment        = $comment;
134                 $this->forward        = $forward;
135                 $this->posts          = $posts ?? new Collection\Report\Posts();
136                 $this->rules          = $rules ?? new Collection\Report\Rules();
137                 $this->publicRemarks  = $publicRemarks;
138                 $this->privateRemarks = $privateRemarks;
139                 $this->edited         = $edited;
140                 $this->status         = $status;
141                 $this->resolution     = $resolution;
142                 $this->assignedUid    = $assignedUid;
143                 $this->lastEditorUid  = $lastEditorUid;
144                 $this->id             = $id;
145         }
146 }