mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-11-22 07:12:36 +00:00
45ce7a7126
Swapped back handling to instead be pre-determined instead of being based upon session/referrer which would cause inconsistent results when referrer data was not available (redirect to app-loaded images/files). To support, this adds a mechansism to provide a URL through request data. Also cleaned up some imports in code while making changes. Closes #4656.
30 lines
976 B
PHP
30 lines
976 B
PHP
<?php
|
|
|
|
namespace BookStack\Activity\Controllers;
|
|
|
|
use BookStack\Activity\Tools\UserEntityWatchOptions;
|
|
use BookStack\Entities\Tools\MixedEntityRequestHelper;
|
|
use BookStack\Http\Controller;
|
|
use Illuminate\Http\Request;
|
|
|
|
class WatchController extends Controller
|
|
{
|
|
public function update(Request $request, MixedEntityRequestHelper $entityHelper)
|
|
{
|
|
$this->checkPermission('receive-notifications');
|
|
$this->preventGuestAccess();
|
|
|
|
$requestData = $this->validate($request, array_merge([
|
|
'level' => ['required', 'string'],
|
|
], $entityHelper->validationRules()));
|
|
|
|
$watchable = $entityHelper->getVisibleEntityFromRequestData($requestData);
|
|
$watchOptions = new UserEntityWatchOptions(user(), $watchable);
|
|
$watchOptions->updateLevelByName($requestData['level']);
|
|
|
|
$this->showSuccessNotification(trans('activities.watch_update_level_notification'));
|
|
|
|
return redirect($watchable->getUrl());
|
|
}
|
|
}
|