Change how events are re-sent when auth is done

This commit is contained in:
Jon Staab
2024-02-23 10:57:39 -08:00
parent 516299e4c4
commit d02794998e
+9 -8
View File
@@ -94,11 +94,18 @@ export class ConnectionMeta {
this.pendingPublishes.set(event.id, {sent: Date.now(), event})
}
onReceiveOk([verb, eventId, ok]: Message) {
onReceiveOk([verb, eventId, ok, notice]: Message) {
const publish = this.pendingPublishes.get(eventId)
if (ok) {
this.authStatus = AuthStatus.Ok
} else if (notice.startsWith('auth-required:')) {
// Re-enqueue pending reqs when auth challenge is received
const pub = this.pendingPublishes.get(eventId)
if (pub) {
this.cxn.send(['EVENT', pub.event])
}
}
if (publish) {
@@ -130,14 +137,8 @@ export class ConnectionMeta {
}
onReceiveClosed([verb, id, notice]: Message) {
// Re-enqueue pending reqs/events when auth challenge is received
if (notice.startsWith('auth-required:')) {
const pub = this.pendingPublishes.get(id)
if (pub) {
this.cxn.send(['EVENT', pub.event])
}
// Re-enqueue pending reqs when auth challenge is received
const req = this.pendingRequests.get(id)
if (req) {