mirror of
https://github.com/BEDOLAGA-DEV/remnawave-bedolaga-telegram-bot.git
synced 2026-02-23 12:53:41 +00:00
fix: revert device pagination, add raw user data field discovery
Bulk device endpoint ignores take/skip params, causing duplicates. Revert to single call. Add logging to discover extra fields in panel user response that might include device count.
This commit is contained in:
60
app/external/remnawave_api.py
vendored
60
app/external/remnawave_api.py
vendored
@@ -627,7 +627,45 @@ class RemnaWaveAPI:
|
||||
params = {'start': start, 'size': size}
|
||||
response = await self._make_request('GET', '/api/users', params=params)
|
||||
|
||||
users = [self._parse_user(user) for user in response['response']['users']]
|
||||
raw_users = response['response']['users']
|
||||
if raw_users:
|
||||
sample = raw_users[0]
|
||||
extra_keys = set(sample.keys()) - {
|
||||
'uuid',
|
||||
'shortUuid',
|
||||
'username',
|
||||
'status',
|
||||
'trafficLimitBytes',
|
||||
'trafficLimitStrategy',
|
||||
'expireAt',
|
||||
'telegramId',
|
||||
'email',
|
||||
'hwidDeviceLimit',
|
||||
'description',
|
||||
'tag',
|
||||
'subscriptionUrl',
|
||||
'activeInternalSquads',
|
||||
'createdAt',
|
||||
'updatedAt',
|
||||
'userTraffic',
|
||||
'subLastUserAgent',
|
||||
'subLastOpenedAt',
|
||||
'subRevokedAt',
|
||||
'lastTrafficResetAt',
|
||||
'trojanPassword',
|
||||
'vlessUuid',
|
||||
'ssPassword',
|
||||
'lastTriggeredThreshold',
|
||||
'happ',
|
||||
'externalSquadUuid',
|
||||
'id',
|
||||
}
|
||||
if extra_keys:
|
||||
logger.info('Panel user extra keys: %s', extra_keys)
|
||||
for ek in list(extra_keys)[:5]:
|
||||
logger.info(' %s = %s', ek, sample.get(ek))
|
||||
|
||||
users = [self._parse_user(user) for user in raw_users]
|
||||
|
||||
if enrich_happ_links:
|
||||
users = [await self.enrich_user_with_happ_link(u) for u in users]
|
||||
@@ -1000,23 +1038,9 @@ class RemnaWaveAPI:
|
||||
)
|
||||
|
||||
async def get_all_hwid_devices(self) -> dict[str, Any]:
|
||||
"""GET /api/hwid/devices — all devices, handles pagination."""
|
||||
all_devices = []
|
||||
page_size = 500
|
||||
offset = 0
|
||||
|
||||
while True:
|
||||
response = await self._make_request('GET', '/api/hwid/devices', params={'take': page_size, 'skip': offset})
|
||||
data = response.get('response', {'devices': [], 'total': 0})
|
||||
devices = data.get('devices', [])
|
||||
total = data.get('total', 0)
|
||||
all_devices.extend(devices)
|
||||
|
||||
if len(all_devices) >= total or not devices:
|
||||
break
|
||||
offset += len(devices)
|
||||
|
||||
return {'devices': all_devices, 'total': len(all_devices)}
|
||||
"""GET /api/hwid/devices — all devices for all users."""
|
||||
response = await self._make_request('GET', '/api/hwid/devices')
|
||||
return response.get('response', {'devices': [], 'total': 0})
|
||||
|
||||
async def get_all_panel_subscriptions(self) -> list[dict[str, Any]]:
|
||||
"""GET /api/subscriptions — all panel subscriptions."""
|
||||
|
||||
Reference in New Issue
Block a user