Add fields to Report entity

- Add clock dependency to Moderation\Factory\Report
- Change DateTime field to DateTimeImmutable to satisfy Clock return type
- Add category, status and resolution constants
This commit is contained in:
Hypolite Petovan 2022-12-10 09:08:12 -05:00
parent d29a84ae46
commit 76de49a25c
13 changed files with 543 additions and 222 deletions

View file

@ -62,21 +62,23 @@ class Reports extends BaseApi
'forward' => false, // If the account is remote, should the report be forwarded to the remote admin?
], $request);
$contact = Contact::getById($request['account_id'], ['id']);
$contact = Contact::getById($request['account_id'], ['id', 'gsid']);
if (empty($contact)) {
throw new HTTPException\NotFoundException('Account ' . $request['account_id'] . ' not found');
}
$violation = '';
$rules = System::getRules(true);
foreach ($request['rule_ids'] as $key) {
if (!empty($rules[$key])) {
$violation .= $rules[$key] . "\n";
}
}
$report = $this->reportFactory->createFromReportsRequest(Contact::getPublicIdByUserId(self::getCurrentUserID()), $request['account_id'], $request['comment'], $request['category'], trim($violation), $request['forward'], $request['status_ids'], self::getCurrentUserID());
$report = $this->reportFactory->createFromReportsRequest(
System::getRules(),
Contact::getPublicIdByUserId(self::getCurrentUserID()),
$contact['id'],
$contact['gsid'],
$request['comment'],
$request['category'],
$request['forward'],
$request['status_ids'],
$request['rule_ids'],
self::getCurrentUserID()
);
$this->reportRepo->save($report);