Skip to content

Commit

Permalink
fix: Add proper messages to mention response
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Knorr <jus@bitgrid.net>
  • Loading branch information
juliushaertl committed Oct 8, 2024
1 parent f897059 commit 1c065a1
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/Controller/MentionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ public function mention(int $fileId, string $mention): DataResponse {
$userFolder = $this->rootFolder->getUserFolder($this->userId);
$file = $userFolder->getFirstNodeById($fileId);
if ($file === null) {
return new DataResponse([], Http::STATUS_NOT_FOUND);
return new DataResponse(['message' => 'File not found for current user'], Http::STATUS_NOT_FOUND);
}

$userFolder = $this->rootFolder->getUserFolder($mention);
$file = $userFolder->getFirstNodeById($fileId);
if ($file === null) {
return new DataResponse([], Http::STATUS_NOT_FOUND);
return new DataResponse(['message' => 'File not found for mentioned user'], Http::STATUS_NOT_FOUND);
}

$notification = $this->manager->createNotification();
Expand All @@ -58,9 +58,8 @@ public function mention(int $fileId, string $mention): DataResponse {
$notification->setDateTime(\DateTime::createFromImmutable($this->timeFactory->now()));
$this->manager->notify($notification);
return new DataResponse([], Http::STATUS_OK);

}

return new DataResponse([], Http::STATUS_NOT_FOUND);
return new DataResponse(['message' => 'Notification already present'], Http::STATUS_NOT_FOUND);
}
}

0 comments on commit 1c065a1

Please sign in to comment.