diff --git a/app/Services/UserService.php b/app/Services/UserService.php index 2baca89a4..46d8a9d93 100644 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -281,10 +281,18 @@ public function disableTwoFactor($code, $user) { * @param mixed $user */ public function updateContentWarningVisibility($data, $user) { - $user->settings->content_warning_visibility = $data; - $user->settings->save(); + DB::beginTransaction(); - return true; + try { + $user->settings->content_warning_visibility = $data; + $user->settings->save(); + + return $this->commitReturn(true); + } catch (\Exception $e) { + $this->setError('error', $e->getMessage()); + } + + return $this->rollbackReturn(false); } /**