Changed parameter order

This commit is contained in:
Michael 2022-12-25 07:30:39 +00:00
parent dc73cbe30c
commit cef4349421
5 changed files with 19 additions and 17 deletions

View file

@ -23,21 +23,21 @@ namespace Friendica\Moderation\Entity;
/** /**
* @property-read int $id * @property-read int $id
* @property-read int $uid * @property-read int $reporterId
* @property-read int $cid * @property-read int $cid
* @property-read string $comment * @property-read string $comment
* @property-read string|null $category
* @property-read bool $forward * @property-read bool $forward
* @property-read array $postUriIds * @property-read array $postUriIds
* @property-read int $uid
* @property-read \DateTime|null $created * @property-read \DateTime|null $created
*/ */
class Report extends \Friendica\BaseEntity class Report extends \Friendica\BaseEntity
{ {
/** @var int|null */ /** @var int|null */
protected $id; protected $id;
/** @var int ID of the user making a moderation report*/
protected $reporterId;
/** @var int ID of the contact making a moderation report*/ /** @var int ID of the contact making a moderation report*/
protected $uid; protected $reporterId;
/** @var int ID of the contact being reported*/ /** @var int ID of the contact being reported*/
protected $cid; protected $cid;
/** @var string Optional comment */ /** @var string Optional comment */
@ -50,10 +50,11 @@ class Report extends \Friendica\BaseEntity
protected $created; protected $created;
/** @var array Optional list of URI IDs of posts supporting the report*/ /** @var array Optional list of URI IDs of posts supporting the report*/
protected $postUriIds; 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->reporterId = $reporterId;
$this->cid = $cid; $this->cid = $cid;
$this->created = $created; $this->created = $created;
@ -61,6 +62,7 @@ class Report extends \Friendica\BaseEntity
$this->category = $category; $this->category = $category;
$this->forward = $forward; $this->forward = $forward;
$this->postUriIds = $postUriIds; $this->postUriIds = $postUriIds;
$this->uid = $uid;
$this->id = $id; $this->id = $id;
} }
} }

View file

@ -35,7 +35,6 @@ class Report extends \Friendica\BaseFactory implements ICanCreateFromTableRow
public function createFromTableRow(array $row, array $postUriIds = []): Entity\Report public function createFromTableRow(array $row, array $postUriIds = []): Entity\Report
{ {
return new Entity\Report( return new Entity\Report(
$row['uid'],
$row['reporter-id'], $row['reporter-id'],
$row['cid'], $row['cid'],
new \DateTime($row['created'] ?? 'now', new \DateTimeZone('UTC')), new \DateTime($row['created'] ?? 'now', new \DateTimeZone('UTC')),
@ -43,6 +42,7 @@ class Report extends \Friendica\BaseFactory implements ICanCreateFromTableRow
$row['category'], $row['category'],
$row['forward'], $row['forward'],
$postUriIds, $postUriIds,
$row['uid'],
$row['id'], $row['id'],
); );
} }
@ -61,10 +61,9 @@ class Report extends \Friendica\BaseFactory implements ICanCreateFromTableRow
* @return Entity\Report * @return Entity\Report
* @throws \Exception * @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( return new Entity\Report(
$uid,
$reporterId, $reporterId,
$cid, $cid,
new \DateTime('now', new \DateTimeZone('UTC')), new \DateTime('now', new \DateTimeZone('UTC')),
@ -72,6 +71,7 @@ class Report extends \Friendica\BaseFactory implements ICanCreateFromTableRow
$category, $category,
$forward, $forward,
$postUriIds, $postUriIds,
$uid,
); );
} }
} }

View file

@ -66,7 +66,7 @@ class Reports extends BaseApi
throw new HTTPException\NotFoundException('Account ' . $request['account_id'] . ' not found'); 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); $this->reportRepo->save($report);

View 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); DI::report()->save($report);
Logger::info('Stored report', ['reporter' => $reporter_id, 'account_id' => $account_id, 'comment' => $activity['content'], 'object_ids' => $activity['object_ids']]); Logger::info('Stored report', ['reporter' => $reporter_id, 'account_id' => $account_id, 'comment' => $activity['content'], 'object_ids' => $activity['object_ids']]);

View file

@ -44,7 +44,6 @@ class ReportTest extends MockedTest
], ],
'postUriIds' => [], 'postUriIds' => [],
'assertion' => new Entity\Report( 'assertion' => new Entity\Report(
12,
14, 14,
13, 13,
new \DateTime('now', new \DateTimeZone('UTC')), new \DateTime('now', new \DateTimeZone('UTC')),
@ -52,6 +51,7 @@ class ReportTest extends MockedTest
null, null,
false, false,
[], [],
12,
11, 11,
), ),
], ],
@ -68,7 +68,6 @@ class ReportTest extends MockedTest
], ],
'postUriIds' => [89, 90], 'postUriIds' => [89, 90],
'assertion' => new Entity\Report( 'assertion' => new Entity\Report(
12,
14, 14,
13, 13,
new \DateTime('2021-10-12 12:23:00', new \DateTimeZone('UTC')), new \DateTime('2021-10-12 12:23:00', new \DateTimeZone('UTC')),
@ -76,6 +75,7 @@ class ReportTest extends MockedTest
'violation', 'violation',
true, true,
[89, 90], [89, 90],
12,
11 11
), ),
], ],
@ -121,7 +121,6 @@ class ReportTest extends MockedTest
'forward' => false, 'forward' => false,
'postUriIds' => [], 'postUriIds' => [],
'assertion' => new Entity\Report( 'assertion' => new Entity\Report(
12,
14, 14,
13, 13,
new \DateTime('now', new \DateTimeZone('UTC')), new \DateTime('now', new \DateTimeZone('UTC')),
@ -129,6 +128,7 @@ class ReportTest extends MockedTest
null, null,
false, false,
[], [],
12,
null null
), ),
], ],
@ -141,7 +141,6 @@ class ReportTest extends MockedTest
'forward' => true, 'forward' => true,
'postUriIds' => [89, 90], 'postUriIds' => [89, 90],
'assertion' => new Entity\Report( 'assertion' => new Entity\Report(
12,
14, 14,
13, 13,
new \DateTime('now', new \DateTimeZone('UTC')), new \DateTime('now', new \DateTimeZone('UTC')),
@ -149,6 +148,7 @@ class ReportTest extends MockedTest
'violation', 'violation',
true, true,
[89, 90], [89, 90],
12,
null null
), ),
], ],
@ -158,10 +158,10 @@ class ReportTest extends MockedTest
/** /**
* @dataProvider dataCreateFromReportsRequest * @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()); $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);
} }
} }