Skip to content

Commit

Permalink
fix: warnings not getting associated with posts
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Skvortsov <[email protected]>
  • Loading branch information
askvortsov1 committed Aug 18, 2023
1 parent f0e0167 commit 9d9d48b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Api/Controller/CreateWarningController.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ protected function data(ServerRequestInterface $request, Document $document)
$actor->assertCan('user.manageWarnings');

$requestData = $request->getParsedBody()['data']['attributes'];
$requestRelationships = $request->getParsedBody()['data']['relationships'];

$publicComment = $requestData['public_comment'];

Expand All @@ -70,8 +71,8 @@ protected function data(ServerRequestInterface $request, Document $document)
$warning->created_user_id = $actor->id;
$warning->created_at = Carbon::now();

if (array_key_exists('post', $requestData)) {
$warning->post_id = $requestData['post']['data']['id'];
if (array_key_exists('post', $requestRelationships)) {
$warning->post_id = $requestRelationships['post']['data']['id'];
}

if (!$warning->strikes) {
Expand Down

0 comments on commit 9d9d48b

Please sign in to comment.