]> BookStack Code Mirror - bookstack/blobdiff - app/Activity/Controllers/WatchController.php
Fixed OIDC Logout
[bookstack] / app / Activity / Controllers / WatchController.php
index f9e8a4e3dc100602cf53e83681aaf6ba4f669cb0..3d7e18116bec0b404bd8dd804480c23ab150376d 100644 (file)
@@ -2,7 +2,7 @@
 
 namespace BookStack\Activity\Controllers;
 
-use BookStack\Activity\Models\Watch;
+use BookStack\Activity\Tools\UserEntityWatchOptions;
 use BookStack\App\Model;
 use BookStack\Entities\Models\Entity;
 use BookStack\Http\Controller;
@@ -14,18 +14,20 @@ class WatchController extends Controller
 {
     public function update(Request $request)
     {
+        $this->checkPermission('receive-notifications');
+        $this->preventGuestAccess();
+
         $requestData = $this->validate($request, [
             'level' => ['required', 'string'],
         ]);
 
         $watchable = $this->getValidatedModelFromRequest($request);
-        $newLevel = Watch::optionNameToLevel($requestData['level']);
+        $watchOptions = new UserEntityWatchOptions(user(), $watchable);
+        $watchOptions->updateLevelByName($requestData['level']);
 
-        if ($newLevel < 0) {
-            // TODO - Delete
-        } else {
-            // TODO - Upsert
-        }
+        $this->showSuccessNotification(trans('activities.watch_update_level_notification'));
+
+        return redirect()->back();
     }
 
     /**