From 66ed47b35b97c32b95619e4f021e39e4ddba0299 Mon Sep 17 00:00:00 2001 From: Alex Thomassen Date: Fri, 24 Nov 2023 15:53:50 +0000 Subject: [PATCH] Users should automatically have access to their own channel --- app/Models/Trace/ModeratorAction.php | 3 +-- app/Models/User.php | 8 ++++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/Models/Trace/ModeratorAction.php b/app/Models/Trace/ModeratorAction.php index 14cf979..7ea291f 100644 --- a/app/Models/Trace/ModeratorAction.php +++ b/app/Models/Trace/ModeratorAction.php @@ -4,7 +4,6 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; - class ModeratorAction extends Model { use HasFactory; @@ -43,7 +42,7 @@ public function formatted() : string } /** - * Timeout/untimeout + * Timeouts */ if ($cmd === 'timeout') { $duration = $this->timeout_duration; diff --git a/app/Models/User.php b/app/Models/User.php index f68c762..f33f448 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -43,7 +43,9 @@ class User extends Authenticatable * * @var array */ - protected $casts = []; + protected $casts = [ + 'is_admin' => 'boolean', + ]; /** * Get the channel permissions for the user. @@ -86,6 +88,8 @@ public function getTraceChannels() : Collection if (! $this->isAdmin()) { $permissionChannelIds = $this->channelPermissions()->pluck('channel_provider_id')->toArray(); + $permissionChannelIds[] = $this->provider_id; + $channels = $channels->whereIn('channel_id', $permissionChannelIds); } @@ -99,6 +103,6 @@ public function getTraceChannels() : Collection */ public function isAdmin() : bool { - return $this->is_admin === 1; + return $this->is_admin; } }