feat(debug): expose nextEligibleAt and structured send-wakeup results
Extend authenticated debug endpoints for local iOS notification testing: add nextEligibleAt (23h prod / 10m test) to device lookup, return success and failureReason from send-wakeup with masked tokens only, reuse resolveOwnedDevice for ownership checks, and standardize [DebugEndpoint] logs.
This commit is contained in:
@@ -5,10 +5,22 @@ import { messaging } from "./firebase.js";
|
||||
const MS_PRODUCTION = 23 * 60 * 60 * 1000;
|
||||
const MS_TEST = 10 * 60 * 1000;
|
||||
|
||||
function notifyThresholdMs(testMode?: boolean): number {
|
||||
export function notifyThresholdMs(testMode?: boolean): number {
|
||||
return testMode === true ? MS_TEST : MS_PRODUCTION;
|
||||
}
|
||||
|
||||
/** Epoch ms when the device may receive another push (diagnostics only). */
|
||||
export function computeNextEligibleAt(row: {
|
||||
lastNotifiedAt?: number;
|
||||
testMode?: boolean;
|
||||
}): number {
|
||||
const threshold = notifyThresholdMs(row.testMode);
|
||||
if (row.lastNotifiedAt === undefined) {
|
||||
return Date.now();
|
||||
}
|
||||
return row.lastNotifiedAt + threshold;
|
||||
}
|
||||
|
||||
function lastNotifiedMs(row: StoredRow | undefined): number | undefined {
|
||||
const v = row?.lastNotifiedAt;
|
||||
if (v === undefined) return undefined;
|
||||
|
||||
Reference in New Issue
Block a user