Category added
This commit is contained in:
@@ -42,6 +42,8 @@ class Report extends \Friendica\BaseEntity
|
||||
protected $cid;
|
||||
/** @var string Optional comment */
|
||||
protected $comment;
|
||||
/** @var string Optional category */
|
||||
protected $category;
|
||||
/** @var bool Whether this report should be forwarded to the remote server */
|
||||
protected $forward;
|
||||
/** @var \DateTime|null When the report was created */
|
||||
@@ -49,13 +51,14 @@ class Report extends \Friendica\BaseEntity
|
||||
/** @var array Optional list of URI IDs of posts supporting the report*/
|
||||
protected $postUriIds;
|
||||
|
||||
public function __construct(int $uid = null, int $reporterId, int $cid, \DateTime $created, string $comment = '', bool $forward = false, array $postUriIds = [], int $id = null)
|
||||
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)
|
||||
{
|
||||
$this->uid = $uid;
|
||||
$this->reporterId = $reporterId;
|
||||
$this->cid = $cid;
|
||||
$this->created = $created;
|
||||
$this->comment = $comment;
|
||||
$this->category = $category;
|
||||
$this->forward = $forward;
|
||||
$this->postUriIds = $postUriIds;
|
||||
$this->id = $id;
|
||||
|
||||
@@ -40,6 +40,7 @@ class Report extends \Friendica\BaseFactory implements ICanCreateFromTableRow
|
||||
$row['cid'],
|
||||
new \DateTime($row['created'] ?? 'now', new \DateTimeZone('UTC')),
|
||||
$row['comment'],
|
||||
$row['category'],
|
||||
$row['forward'],
|
||||
$postUriIds,
|
||||
$row['id'],
|
||||
@@ -60,7 +61,7 @@ class Report extends \Friendica\BaseFactory implements ICanCreateFromTableRow
|
||||
* @return Entity\Report
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function createFromReportsRequest(int $uid = null, int $reporterId, int $cid, string $comment = '', bool $forward = false, array $postUriIds = []): Entity\Report
|
||||
public function createFromReportsRequest(int $uid = null, int $reporterId, int $cid, string $comment = '', string $category = null, bool $forward = false, array $postUriIds = []): Entity\Report
|
||||
{
|
||||
return new Entity\Report(
|
||||
$uid,
|
||||
@@ -68,6 +69,7 @@ class Report extends \Friendica\BaseFactory implements ICanCreateFromTableRow
|
||||
$cid,
|
||||
new \DateTime('now', new \DateTimeZone('UTC')),
|
||||
$comment,
|
||||
$category,
|
||||
$forward,
|
||||
$postUriIds,
|
||||
);
|
||||
|
||||
@@ -57,6 +57,7 @@ class Report extends \Friendica\BaseRepository
|
||||
'reporter-id' => $Report->reporterId,
|
||||
'cid' => $Report->cid,
|
||||
'comment' => $Report->comment,
|
||||
'category' => $Report->category,
|
||||
'forward' => $Report->forward,
|
||||
];
|
||||
|
||||
|
||||
@@ -54,10 +54,11 @@ class Reports extends BaseApi
|
||||
self::checkAllowedScope(self::SCOPE_WRITE);
|
||||
|
||||
$request = $this->getRequest([
|
||||
'account_id' => '', // ID of the account to report
|
||||
'status_ids' => [], // Array of Statuses to attach to the report, for context
|
||||
'comment' => '', // Reason for the report (default max 1000 characters)
|
||||
'forward' => false, // If the account is remote, should the report be forwarded to the remote admin?
|
||||
'account_id' => '', // ID of the account to report
|
||||
'status_ids' => [], // Array of Statuses to attach to the report, for context
|
||||
'comment' => '', // Reason for the report (default max 1000 characters)
|
||||
'category' => 'other', // Specify if the report is due to spam, violation of enumerated instance rules, or some other reason.
|
||||
'forward' => false, // If the account is remote, should the report be forwarded to the remote admin?
|
||||
], $request);
|
||||
|
||||
$contact = Contact::getById($request['account_id'], ['id']);
|
||||
@@ -65,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['forward'], $request['status_ids']);
|
||||
$report = $this->reportFactory->createFromReportsRequest(self::getCurrentUserID(), Contact::getPublicIdByUserId(self::getCurrentUserID()), $request['account_id'], $request['comment'], $request['category'], $request['forward'], $request['status_ids']);
|
||||
|
||||
$this->reportRepo->save($report);
|
||||
|
||||
|
||||
@@ -1855,7 +1855,7 @@ class Processor
|
||||
}
|
||||
}
|
||||
|
||||
$report = DI::reportFactory()->createFromReportsRequest(null, $reporter_id, $account_id, $activity['content'], false, $uri_ids);
|
||||
$report = DI::reportFactory()->createFromReportsRequest(null, $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'], 'status_ids' => $status_ids]);
|
||||
|
||||
Reference in New Issue
Block a user