mirror of
https://github.com/djdevin/recflare.git
synced 2026-09-08 14:41:28 -07:00
fix incorrect balance push notification
This commit is contained in:
@@ -14,6 +14,12 @@ export default defineConfig({
|
||||
// isolated test, so provide a minimal stub exposing the same NotificationsHub
|
||||
// RPC surface — enough for the runtime to start and for notification sends to
|
||||
// no-op.
|
||||
//
|
||||
// The stub RECORDS what it was sent (`drainFrames`) rather than discarding it.
|
||||
// Pushes are best-effort and swallow their own errors, so a frame carrying the
|
||||
// wrong payload is otherwise invisible here — which is exactly how
|
||||
// StorefrontBalanceUpdate shipped with the resulting total in a field the
|
||||
// client adds to what it is already showing.
|
||||
workers: [
|
||||
{
|
||||
name: 'notify',
|
||||
@@ -24,8 +30,18 @@ export default defineConfig({
|
||||
script: `
|
||||
import { DurableObject } from 'cloudflare:workers'
|
||||
export class NotificationsHub extends DurableObject {
|
||||
async notifyPlayer() { return { delivered: 0, queued: true } }
|
||||
frames = []
|
||||
async notifyPlayer(accountId, notificationType, payload) {
|
||||
this.frames.push({ accountId, notificationType, payload })
|
||||
return { delivered: 0, queued: true }
|
||||
}
|
||||
async broadcast() { return { delivered: 0 } }
|
||||
/** Everything pushed since the last call, then forget it. */
|
||||
async drainFrames() {
|
||||
const drained = this.frames
|
||||
this.frames = []
|
||||
return drained
|
||||
}
|
||||
}
|
||||
export default { fetch() { return new Response('ok') } }
|
||||
`,
|
||||
|
||||
Reference in New Issue
Block a user