mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2025-12-26 13:20:48 +00:00
Handle server alerts received on libsignal auth socket
Co-authored-by: trevor-signal <trevor@signal.org>
This commit is contained in:
@@ -51,7 +51,8 @@ import { isNightly, isBeta, isStaging } from '../util/version';
|
||||
import { getBasicAuth } from '../util/getBasicAuth';
|
||||
import { isTestOrMockEnvironment } from '../environment';
|
||||
import type { ConfigKeyType } from '../RemoteConfig';
|
||||
import { ServerAlert } from '../state/ducks/server';
|
||||
import type { ServerAlert } from '../state/ducks/server';
|
||||
import { parseServerAlertFromHeader } from '../state/ducks/server';
|
||||
|
||||
const FIVE_MINUTES = 5 * durations.MINUTE;
|
||||
|
||||
@@ -205,6 +206,9 @@ export class SocketManager extends EventListener {
|
||||
handler: (req: IncomingWebSocketRequest): void => {
|
||||
this.#queueOrHandleRequest(req);
|
||||
},
|
||||
onReceivedAlerts: (alerts: Array<ServerAlert>) => {
|
||||
this.emit('serverAlerts', alerts);
|
||||
},
|
||||
receiveStories: !this.#hasStoriesDisabled,
|
||||
keepalive: { path: '/v1/keepalive' },
|
||||
})
|
||||
@@ -972,12 +976,9 @@ export class SocketManager extends EventListener {
|
||||
}
|
||||
}
|
||||
|
||||
const serverAlerts: Array<ServerAlert> = [];
|
||||
alerts.forEach(alert => {
|
||||
if (alert.toLowerCase() === 'critical-idle-primary-device') {
|
||||
serverAlerts.push(ServerAlert.CRITICAL_IDLE_PRIMARY_DEVICE);
|
||||
}
|
||||
});
|
||||
const serverAlerts: Array<ServerAlert> = alerts
|
||||
.map(parseServerAlertFromHeader)
|
||||
.filter(v => v !== undefined);
|
||||
|
||||
this.emit('serverAlerts', serverAlerts);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user