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 $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;
}
}

View 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,
);
}
}

View 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);

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);
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' => [],
'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);
}
}