fix(xtream): address portal review feedback

This commit is contained in:
4gray committed 2026-06-14 13:47:42 +02:00
1 parent 254879f92b
commit 20d0f01428
12 files changed
+295 -51

No files matched your search

@@ -110,6 +110,32 @@ describe('PortalStatusService', () => {
);
});
it('reads cached status with the same normalized connection key used by checks', async () => {
dataService.sendIpcEvent.mockResolvedValue({
payload: {
user_info: {
auth: 1,
exp_date: '0',
status: 'Active',
},
},
});
await service.checkPortalStatus(
' https://example.com/get.php?username=old&password=old&type=m3u_plus ',
' user ',
' pass '
);
expect(
service.getCachedStatus(
' https://example.com/get.php?username=old&password=old&type=m3u_plus ',
' user ',
' pass '
)
).toBe('active');
});
it('falls back to alternate account actions when get_account_info does not return user info', async () => {
dataService.sendIpcEvent.mockImplementation(
async (_type: string, payload: unknown) => {
+16 -6
View File
@@ -137,8 +137,21 @@ export class PortalStatusService {
username: string,
password: string
): PortalStatus | null {
const connection = this.normalizeConnection(
serverUrl,
username,
password
);
if (!connection) {
return null;
}
const cached = this.cache.get(
this.buildCacheKey(serverUrl, username, password)
this.buildCacheKey(
connection.serverUrl,
connection.username,
connection.password
)
);
if (!cached) {
return null;
@@ -193,8 +206,6 @@ export class PortalStatusService {
username: string,
password: string
): Promise<PortalStatus> {
let fallbackStatus: PortalStatus = 'unavailable';
for (const action of XTREAM_STATUS_ACTIONS) {
try {
const response =
@@ -214,13 +225,12 @@ export class PortalStatusService {
if (status !== 'unavailable') {
return status;
}
fallbackStatus = status;
} catch {
fallbackStatus = 'unavailable';
// Try the next Xtream account-info action variant.
}
}
return fallbackStatus;
return 'unavailable';
}
/**