Users should automatically have access to their own channel

This commit is contained in:
Alex Thomassen 2023-11-24 15:53:50 +00:00
parent b97913a24e
commit 66ed47b35b
Signed by: Alex
GPG Key ID: 10BD786B5F6FF5DE
2 changed files with 7 additions and 4 deletions

View File

@ -4,7 +4,6 @@
use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
class ModeratorAction extends Model class ModeratorAction extends Model
{ {
use HasFactory; use HasFactory;
@ -43,7 +42,7 @@ public function formatted() : string
} }
/** /**
* Timeout/untimeout * Timeouts
*/ */
if ($cmd === 'timeout') { if ($cmd === 'timeout') {
$duration = $this->timeout_duration; $duration = $this->timeout_duration;

View File

@ -43,7 +43,9 @@ class User extends Authenticatable
* *
* @var array<string, string> * @var array<string, string>
*/ */
protected $casts = []; protected $casts = [
'is_admin' => 'boolean',
];
/** /**
* Get the channel permissions for the user. * Get the channel permissions for the user.
@ -86,6 +88,8 @@ public function getTraceChannels() : Collection
if (! $this->isAdmin()) { if (! $this->isAdmin()) {
$permissionChannelIds = $this->channelPermissions()->pluck('channel_provider_id')->toArray(); $permissionChannelIds = $this->channelPermissions()->pluck('channel_provider_id')->toArray();
$permissionChannelIds[] = $this->provider_id;
$channels = $channels->whereIn('channel_id', $permissionChannelIds); $channels = $channels->whereIn('channel_id', $permissionChannelIds);
} }
@ -99,6 +103,6 @@ public function getTraceChannels() : Collection
*/ */
public function isAdmin() : bool public function isAdmin() : bool
{ {
return $this->is_admin === 1; return $this->is_admin;
} }
} }