]> git.mxchange.org Git - friendica.git/commitdiff
Changed parameter order
authorMichael <heluecht@pirati.ca>
Sun, 25 Dec 2022 07:30:39 +0000 (07:30 +0000)
committerMichael <heluecht@pirati.ca>
Sun, 25 Dec 2022 07:30:39 +0000 (07:30 +0000)
src/Moderation/Entity/Report.php
src/Moderation/Factory/Report.php
src/Module/Api/Mastodon/Reports.php
src/Protocol/ActivityPub/Processor.php
tests/src/Moderation/Factory/ReportTest.php

index 4689a11b33b6e944636ecf8157fa444c2e8b61e4..2bb4350d485914cd3e93b822e11807d5d32826d7 100644 (file)
@@ -23,21 +23,21 @@ namespace Friendica\Moderation\Entity;
 
 /**
  * @property-read int            $id
- * @property-read int            $uid
+ * @property-read int            $reporterId
  * @property-read int            $cid
  * @property-read string         $comment
+ * @property-read string|null    $category
  * @property-read bool           $forward
  * @property-read array          $postUriIds
+ * @property-read int            $uid
  * @property-read \DateTime|null $created
  */
 class Report extends \Friendica\BaseEntity
 {
        /** @var int|null */
        protected $id;
-       /** @var int ID of the user making a moderation report*/
-       protected $reporterId;
        /** @var int ID of the contact making a moderation report*/
-       protected $uid;
+       protected $reporterId;
        /** @var int ID of the contact being reported*/
        protected $cid;
        /** @var string Optional comment */
@@ -50,10 +50,11 @@ class Report extends \Friendica\BaseEntity
        protected $created;
        /** @var array Optional list of URI IDs of posts supporting the report*/
        protected $postUriIds;
+       /** @var int ID of the user making a moderation report*/
+       protected $uid;
 
-       public function __construct(int $uid = null, int $reporterId, int $cid, \DateTime $created, string $comment = '', string $category = null, bool $forward = false, array $postUriIds = [], int $id = null)
+       public function __construct(int $reporterId, int $cid, \DateTime $created, string $comment = '', string $category = null, bool $forward = false, array $postUriIds = [], int $uid = null, int $id = null)
        {
-               $this->uid        = $uid;
                $this->reporterId = $reporterId;
                $this->cid        = $cid;
                $this->created    = $created;
@@ -61,6 +62,7 @@ class Report extends \Friendica\BaseEntity
                $this->category   = $category;
                $this->forward    = $forward;
                $this->postUriIds = $postUriIds;
+               $this->uid        = $uid;
                $this->id         = $id;
        }
 }
index fbe0aa58b65de166698ee3b28d8dd2048f83a1d3..bbcbe8eb12461a9266f534a1ab1ede2b744540c1 100644 (file)
@@ -35,7 +35,6 @@ class Report extends \Friendica\BaseFactory implements ICanCreateFromTableRow
        public function createFromTableRow(array $row, array $postUriIds = []): Entity\Report
        {
                return new Entity\Report(
-                       $row['uid'],
                        $row['reporter-id'],
                        $row['cid'],
                        new \DateTime($row['created'] ?? 'now', new \DateTimeZone('UTC')),
@@ -43,6 +42,7 @@ class Report extends \Friendica\BaseFactory implements ICanCreateFromTableRow
                        $row['category'],
                        $row['forward'],
                        $postUriIds,
+                       $row['uid'],
                        $row['id'],
                );
        }
@@ -61,10 +61,9 @@ class Report extends \Friendica\BaseFactory implements ICanCreateFromTableRow
         * @return Entity\Report
         * @throws \Exception
         */
-       public function createFromReportsRequest(int $uid = null, int $reporterId, int $cid, string $comment = '', string $category = null, bool $forward = false, array $postUriIds = []): Entity\Report
+       public function createFromReportsRequest(int $reporterId, int $cid, string $comment = '', string $category = null, bool $forward = false, array $postUriIds = [], int $uid = null): Entity\Report
        {
                return new Entity\Report(
-                       $uid,
                        $reporterId,
                        $cid,
                        new \DateTime('now', new \DateTimeZone('UTC')),
@@ -72,6 +71,7 @@ class Report extends \Friendica\BaseFactory implements ICanCreateFromTableRow
                        $category,
                        $forward,
                        $postUriIds,
+                       $uid,
                );
        }
 }
index 13d41eb2337fe498b8c28ed0644a2fdc4c25508a..7d98a5e664d9d8bb3c8f04b3bed4072134711335 100644 (file)
@@ -66,7 +66,7 @@ class Reports extends BaseApi
                        throw new HTTPException\NotFoundException('Account ' . $request['account_id'] . ' not found');
                }
 
-               $report = $this->reportFactory->createFromReportsRequest(self::getCurrentUserID(), Contact::getPublicIdByUserId(self::getCurrentUserID()), $request['account_id'], $request['comment'], $request['category'], $request['forward'], $request['status_ids']);
+               $report = $this->reportFactory->createFromReportsRequest(Contact::getPublicIdByUserId(self::getCurrentUserID()), $request['account_id'], $request['comment'], $request['category'], $request['forward'], $request['status_ids'], self::getCurrentUserID());
 
                $this->reportRepo->save($report);
 
index 0390913be0ed974d868f91a8914aee0e8ca806ce..400a52b3271d843d7ab9ec28bf270eaf46ad95ff 100644 (file)
@@ -1852,7 +1852,7 @@ class Processor
                        }
                }
 
-               $report = DI::reportFactory()->createFromReportsRequest(null, $reporter_id, $account_id, $activity['content'], null, false, $uri_ids);
+               $report = DI::reportFactory()->createFromReportsRequest($reporter_id, $account_id, $activity['content'], null, false, $uri_ids);
                DI::report()->save($report);
 
                Logger::info('Stored report', ['reporter' => $reporter_id, 'account_id' => $account_id, 'comment' => $activity['content'], 'object_ids' => $activity['object_ids']]);
index 5eb4cb323e30bbe8a12f27735783d85f17bb68e0..f21dd2ec4ec3b6b5364b53165e2850842fb66ed5 100644 (file)
@@ -44,7 +44,6 @@ class ReportTest extends MockedTest
                                ],
                                'postUriIds' => [],
                                'assertion'  => new Entity\Report(
-                                       12,
                                        14,
                                        13,
                                        new \DateTime('now', new \DateTimeZone('UTC')),
@@ -52,6 +51,7 @@ class ReportTest extends MockedTest
                                        null,
                                        false,
                                        [],
+                                       12,
                                        11,
                                ),
                        ],
@@ -68,7 +68,6 @@ class ReportTest extends MockedTest
                                ],
                                'postUriIds' => [89, 90],
                                'assertion'  => new Entity\Report(
-                                       12,
                                        14,
                                        13,
                                        new \DateTime('2021-10-12 12:23:00', new \DateTimeZone('UTC')),
@@ -76,6 +75,7 @@ class ReportTest extends MockedTest
                                        'violation',
                                        true,
                                        [89, 90],
+                                       12,
                                        11
                                ),
                        ],
@@ -121,7 +121,6 @@ class ReportTest extends MockedTest
                                'forward'     => false,
                                'postUriIds'  => [],
                                'assertion'   => new Entity\Report(
-                                       12,
                                        14,
                                        13,
                                        new \DateTime('now', new \DateTimeZone('UTC')),
@@ -129,6 +128,7 @@ class ReportTest extends MockedTest
                                        null,
                                        false,
                                        [],
+                                       12,
                                        null
                                ),
                        ],
@@ -141,7 +141,6 @@ class ReportTest extends MockedTest
                                'forward'     => true,
                                'postUriIds'  => [89, 90],
                                'assertion'   => new Entity\Report(
-                                       12,
                                        14,
                                        13,
                                        new \DateTime('now', new \DateTimeZone('UTC')),
@@ -149,6 +148,7 @@ class ReportTest extends MockedTest
                                        'violation',
                                        true,
                                        [89, 90],
+                                       12,
                                        null
                                ),
                        ],
@@ -158,10 +158,10 @@ class ReportTest extends MockedTest
        /**
         * @dataProvider dataCreateFromReportsRequest
         */
-       public function testCreateFromReportsRequest(int $uid, int $reporter, int $cid, string $comment, string $category = null, bool $forward, array $postUriIds, Entity\Report $assertion)
+       public function testCreateFromReportsRequest(int $reporter, int $cid, string $comment, string $category = null, bool $forward, array $postUriIds, int $uid, Entity\Report $assertion)
        {
                $factory = new Factory\Report(new NullLogger());
 
-               $this->assertReport($factory->createFromReportsRequest($uid, $reporter, $cid, $comment, $category, $forward, $postUriIds), $assertion);
+               $this->assertReport($factory->createFromReportsRequest($reporter, $cid, $comment, $category, $forward, $postUriIds, $uid), $assertion);
        }
 }