Update config_cache, fix type casting

This commit is contained in:
Daniel Supernault 2024-03-12 04:27:24 -06:00
parent d1adb109de
commit 2d113de536
No known key found for this signature in database
GPG key ID: 23740873EE6F76A1
2 changed files with 10 additions and 10 deletions

View file

@ -373,7 +373,7 @@ class ProfileController extends Controller
public function stories(Request $request, $username) public function stories(Request $request, $username)
{ {
abort_if(! config_cache('instance.stories.enabled') || ! $request->user(), 404); abort_if(!(bool) config_cache('instance.stories.enabled') || ! $request->user(), 404);
$profile = Profile::whereNull('domain')->whereUsername($username)->firstOrFail(); $profile = Profile::whereNull('domain')->whereUsername($username)->firstOrFail();
$pid = $profile->id; $pid = $profile->id;
$authed = Auth::user()->profile_id; $authed = Auth::user()->profile_id;

View file

@ -34,7 +34,7 @@ class StoryController extends StoryComposeController
{ {
public function recent(Request $request) public function recent(Request $request)
{ {
abort_if(!config_cache('instance.stories.enabled') || !$request->user(), 404); abort_if(!(bool) config_cache('instance.stories.enabled') || !$request->user(), 404);
$user = $request->user(); $user = $request->user();
if($user->has_roles && !UserRoleService::can('can-use-stories', $user->id)) { if($user->has_roles && !UserRoleService::can('can-use-stories', $user->id)) {
return []; return [];
@ -117,7 +117,7 @@ class StoryController extends StoryComposeController
public function profile(Request $request, $id) public function profile(Request $request, $id)
{ {
abort_if(!config_cache('instance.stories.enabled') || !$request->user(), 404); abort_if(!(bool) config_cache('instance.stories.enabled') || !$request->user(), 404);
$user = $request->user(); $user = $request->user();
if($user->has_roles && !UserRoleService::can('can-use-stories', $user->id)) { if($user->has_roles && !UserRoleService::can('can-use-stories', $user->id)) {
@ -176,7 +176,7 @@ class StoryController extends StoryComposeController
public function viewed(Request $request) public function viewed(Request $request)
{ {
abort_if(!config_cache('instance.stories.enabled') || !$request->user(), 404); abort_if(!(bool) config_cache('instance.stories.enabled') || !$request->user(), 404);
$this->validate($request, [ $this->validate($request, [
'id' => 'required|min:1', 'id' => 'required|min:1',
@ -221,7 +221,7 @@ class StoryController extends StoryComposeController
public function exists(Request $request, $id) public function exists(Request $request, $id)
{ {
abort_if(!config_cache('instance.stories.enabled') || !$request->user(), 404); abort_if(!(bool) config_cache('instance.stories.enabled') || !$request->user(), 404);
$user = $request->user(); $user = $request->user();
if($user->has_roles && !UserRoleService::can('can-use-stories', $user->id)) { if($user->has_roles && !UserRoleService::can('can-use-stories', $user->id)) {
return response()->json(false); return response()->json(false);
@ -233,7 +233,7 @@ class StoryController extends StoryComposeController
public function iRedirect(Request $request) public function iRedirect(Request $request)
{ {
abort_if(!config_cache('instance.stories.enabled') || !$request->user(), 404); abort_if(!(bool) config_cache('instance.stories.enabled') || !$request->user(), 404);
$user = $request->user(); $user = $request->user();
abort_if(!$user, 404); abort_if(!$user, 404);
@ -243,7 +243,7 @@ class StoryController extends StoryComposeController
public function viewers(Request $request) public function viewers(Request $request)
{ {
abort_if(!config_cache('instance.stories.enabled') || !$request->user(), 404); abort_if(!(bool) config_cache('instance.stories.enabled') || !$request->user(), 404);
$this->validate($request, [ $this->validate($request, [
'sid' => 'required|string' 'sid' => 'required|string'
@ -274,7 +274,7 @@ class StoryController extends StoryComposeController
public function remoteStory(Request $request, $id) public function remoteStory(Request $request, $id)
{ {
abort_if(!config_cache('instance.stories.enabled') || !$request->user(), 404); abort_if(!(bool) config_cache('instance.stories.enabled') || !$request->user(), 404);
$profile = Profile::findOrFail($id); $profile = Profile::findOrFail($id);
if($profile->user_id != null || $profile->domain == null) { if($profile->user_id != null || $profile->domain == null) {
@ -286,7 +286,7 @@ class StoryController extends StoryComposeController
public function pollResults(Request $request) public function pollResults(Request $request)
{ {
abort_if(!config_cache('instance.stories.enabled') || !$request->user(), 404); abort_if(!(bool) config_cache('instance.stories.enabled') || !$request->user(), 404);
$this->validate($request, [ $this->validate($request, [
'sid' => 'required|string' 'sid' => 'required|string'
@ -304,7 +304,7 @@ class StoryController extends StoryComposeController
public function getActivityObject(Request $request, $username, $id) public function getActivityObject(Request $request, $username, $id)
{ {
abort_if(!config_cache('instance.stories.enabled'), 404); abort_if(!(bool) config_cache('instance.stories.enabled'), 404);
if(!$request->wantsJson()) { if(!$request->wantsJson()) {
return redirect('/stories/' . $username); return redirect('/stories/' . $username);