feat: tg/ws
This commit is contained in:
@@ -14,6 +14,7 @@ class User extends Authenticatable
|
||||
'auto_transfer_threshold_trx',
|
||||
'auto_transfer_threshold_eth',
|
||||
'auto_transfer_threshold_btc',
|
||||
'album_storage_default',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
@@ -39,9 +40,14 @@ class User extends Authenticatable
|
||||
'auto_transfer_threshold_trx' => 'decimal:8',
|
||||
'auto_transfer_threshold_eth' => 'decimal:8',
|
||||
'auto_transfer_threshold_btc' => 'decimal:8',
|
||||
'album_storage_default' => 'boolean',
|
||||
];
|
||||
}
|
||||
|
||||
protected $attributes = [
|
||||
'album_storage_default' => false,
|
||||
];
|
||||
|
||||
public function isEnabled(): bool
|
||||
{
|
||||
return (int) $this->status === 1;
|
||||
@@ -52,6 +58,32 @@ class User extends Authenticatable
|
||||
return $this->hasMany(Channel::class, 'user_id');
|
||||
}
|
||||
|
||||
public function albumStorageDefaultEnabled(): bool
|
||||
{
|
||||
return (bool) ($this->album_storage_default ?? false);
|
||||
}
|
||||
|
||||
/**
|
||||
* New-device album_storage default for a channel.
|
||||
* Agent channels use that agent's switch (defaults off). Official / unknown stay off.
|
||||
*/
|
||||
public static function albumStorageDefaultForChannel(?string $channelId): bool
|
||||
{
|
||||
$channelId = trim((string) $channelId);
|
||||
if ($channelId === '') {
|
||||
return false;
|
||||
}
|
||||
|
||||
$userId = Channel::query()->where('channel_id', $channelId)->value('user_id');
|
||||
if ($userId === null || (int) $userId <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$agent = static::query()->find((int) $userId);
|
||||
|
||||
return $agent?->albumStorageDefaultEnabled() ?? false;
|
||||
}
|
||||
|
||||
public function hasTelegramChat(): bool
|
||||
{
|
||||
return trim((string) ($this->chat_id ?? '')) !== '';
|
||||
|
||||
Reference in New Issue
Block a user