diff --git a/framework/core/src/Forum/Controller/UnsubscribeActionController.php b/framework/core/src/Forum/Controller/UnsubscribeActionController.php index 0f4c65775b..e33c9dac27 100644 --- a/framework/core/src/Forum/Controller/UnsubscribeActionController.php +++ b/framework/core/src/Forum/Controller/UnsubscribeActionController.php @@ -34,26 +34,21 @@ public function handle(Request $request): ResponseInterface $token = Arr::get($parsedBody, 'token'); $userId = Arr::get($parsedBody, 'userId'); - // Fetch the unsubscribe token record /** @var UnsubscribeToken|null $unsubscribeRecord */ $unsubscribeRecord = UnsubscribeToken::where('user_id', $userId) ->where('token', $token) ->first(); - // If record exists and has not been used before if ($unsubscribeRecord && empty($unsubscribeRecord->unsubscribed_at)) { - // Mark as unsubscribed $unsubscribeRecord->unsubscribed_at = Carbon::now(); $unsubscribeRecord->save(); - // Update user preferences /** @var User $user */ $user = User::find($userId); $user->setNotificationPreference($unsubscribeRecord->email_type, 'email', false); $user->save(); } - // Redirect back to the forum's home page after unsubscribing return new RedirectResponse($this->url->to('forum')->base()); } }