#68 - reply working + remove marker on comment delete

This commit is contained in:
isUnknown 2024-12-18 18:22:41 +01:00
parent cf83edc1e6
commit 231bb21a4f
9 changed files with 64 additions and 95 deletions

View file

@ -42,8 +42,6 @@ return [
"type" => "comment",
];
$user->sendNotification($project, $commentData);
$newComment = new Comment($commentData);
$comments[] = $newComment->toArray();

View file

@ -9,36 +9,40 @@ return [
$json = file_get_contents('php://input');
$data = json_decode($json);
$parsedUrl = parse_url($data->path);
$parsedUrl = parse_url($data->dialogUri);
$query = $parsedUrl['query'] ?? null;
parse_str($query, $queryParams);
$stepSlug = $queryParams['dialog'] ?? null;
$targetPageUri = $stepSlug ? $parsedUrl['path'] . '/' . $stepSlug : $parsedUrl['path'];
$project = page($parsedUrl['path']);
$page = page($targetPageUri);
$file = $page->file($data->fileName);
$user = kirby()->user($data->userUuid);
$user = kirby()->user($data->userUuid);
$comments = $file->comments()->isEmpty() == true ? [] : Yaml::decode($file->comments()->value());
$data = [
'href' => $data->path,
'page' => $page,
'parentId' => $data->parentId,
'file' => $file,
'position' => [
'pageIndex' => $data->position->pageIndex,
$replyData = [
"location" => [
"page" => $page,
"project" => $project,
"dialogUri" => $data->dialogUri,
"file" => $file,
],
'text' => $data->text,
'author' => $user,
'date' => (string) $data->date,
'id' => $data->id,
'type' => 'comment'
"parentId" => $data->parentId,
"position" => [
"pageIndex" => $data->position->pageIndex,
],
"date" => (string) $data->date,
"text" => $data->text,
"author" => kirby()->user(),
"id" => Str::uuid(),
"type" => "comment",
];
$newReply = new Reply($data);
$newReply = new Reply($replyData);
foreach ($comments as &$comment) {
if ($comment['id'] === $newReply->parentId()) {
@ -50,7 +54,7 @@ return [
'comments' => $comments
]);
$user->sendNotification($page->parent(), $newReply->toArray());
$user->sendNotification($project, $replyData);
return getFileData($newFile);
}