/**
* @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 */
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;
$this->category = $category;
$this->forward = $forward;
$this->postUriIds = $postUriIds;
+ $this->uid = $uid;
$this->id = $id;
}
}
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')),
$row['category'],
$row['forward'],
$postUriIds,
+ $row['uid'],
$row['id'],
);
}
* @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')),
$category,
$forward,
$postUriIds,
+ $uid,
);
}
}
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);
}
}
- $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']]);
],
'postUriIds' => [],
'assertion' => new Entity\Report(
- 12,
14,
13,
new \DateTime('now', new \DateTimeZone('UTC')),
null,
false,
[],
+ 12,
11,
),
],
],
'postUriIds' => [89, 90],
'assertion' => new Entity\Report(
- 12,
14,
13,
new \DateTime('2021-10-12 12:23:00', new \DateTimeZone('UTC')),
'violation',
true,
[89, 90],
+ 12,
11
),
],
'forward' => false,
'postUriIds' => [],
'assertion' => new Entity\Report(
- 12,
14,
13,
new \DateTime('now', new \DateTimeZone('UTC')),
null,
false,
[],
+ 12,
null
),
],
'forward' => true,
'postUriIds' => [89, 90],
'assertion' => new Entity\Report(
- 12,
14,
13,
new \DateTime('now', new \DateTimeZone('UTC')),
'violation',
true,
[89, 90],
+ 12,
null
),
],
/**
* @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);
}
}