<?php

return [
  'pattern' => '(:all)delete-user-notification.json',
  'method' => 'POST',
  'action'  => function () {
      $json = file_get_contents('php://input');
      $data = json_decode($json);
      
      try {
        kirby()->user()->deleteNotification($data->notificationId);
        return json_encode([
          "status" => "success",
          "message" => "Notification n°{$data->notificationId} correctly deleted for all \"{$$project->title()}\" managers."
        ]);
      } catch (\Throwable $th) {
        return json_encode($th->getMessage() . ' line ' . $th->getLine());
      }
  }
];