Fix realtime sync notifications

This commit is contained in:
shuaiplus
2026-06-22 16:46:55 +08:00
parent 045b23fc47
commit 9a21504f40
2 changed files with 6 additions and 4 deletions
+5 -2
View File
@@ -174,7 +174,7 @@ function buildSignalRMessagePackInvocation(
target: string = 'ReceiveMessage'
): Uint8Array {
// SignalR MessagePack hub protocol uses an array-based invocation shape:
// [type, headers, invocationId, target, arguments]
// [type, headers, invocationId, target, arguments, streamIds]
const encodedPayload = encodeMsgPack([
1,
{},
@@ -187,6 +187,7 @@ function buildSignalRMessagePackInvocation(
Payload: messagePayload,
},
],
[],
]);
return frameSignalRBinary(encodedPayload);
}
@@ -217,7 +218,9 @@ export class NotificationsHub extends DurableObject<Env> {
const revisionDate = String(body?.revisionDate || '').trim() || new Date().toISOString();
const userId = String(request.headers.get('X-NodeWarden-UserId') || body?.userId || '').trim();
const contextId = String(body?.contextId || '').trim() || null;
const updateType = Number(body?.updateType || SIGNALR_UPDATE_TYPE_SYNC_VAULT) || SIGNALR_UPDATE_TYPE_SYNC_VAULT;
const rawUpdateType = body?.updateType;
const parsedUpdateType = typeof rawUpdateType === 'number' ? rawUpdateType : Number(rawUpdateType);
const updateType = Number.isFinite(parsedUpdateType) ? parsedUpdateType : SIGNALR_UPDATE_TYPE_SYNC_VAULT;
const targetDeviceIdentifier = String(body?.targetDeviceIdentifier || '').trim() || null;
const payload = body?.payload && typeof body.payload === 'object'
? body.payload
+1 -2
View File
@@ -1626,7 +1626,7 @@ export default function App() {
continue;
}
if (contextId && contextId === getCurrentDeviceIdentifier()) continue;
if (updateType === SIGNALR_UPDATE_TYPE_SYNC_CIPHERS) {
if (updateType === SIGNALR_UPDATE_TYPE_SYNC_CIPHERS || updateType === SIGNALR_UPDATE_TYPE_SYNC_VAULT) {
if (notificationRefreshTimerRef.current !== null) {
window.clearTimeout(notificationRefreshTimerRef.current);
}
@@ -1660,7 +1660,6 @@ export default function App() {
deleteSendLocally(resourceId, revisionStamp);
continue;
}
if (updateType === SIGNALR_UPDATE_TYPE_SYNC_VAULT) continue;
}
});