Files
wehub-resource-sync 4ce4204b6c
CI / Lint (push) Failing after 2s
CI / Build (push) Has been skipped
SDK CI / PHP SDK (push) Failing after 1s
Split PHP SDK / PHP SDK tests (push) Failing after 1s
CI / Test (push) Failing after 1s
CI / Dashboard (push) Failing after 0s
SDK CI / JavaScript SDK (push) Failing after 0s
SDK CI / Python SDK (push) Failing after 2s
SDK CI / Java SDK (push) Failing after 1s
Split PHP SDK / Mirror sdk/php -> rmyndharis/openwa-php (push) Has been skipped
CI / Test (PostgreSQL migrations) (push) Failing after 7m47s
CI / Docker Build (push) Has been skipped
chore: import upstream snapshot with attribution
2026-07-13 12:24:08 +08:00

14 lines
739 B
JavaScript

// Sandbox fixture: a message:received hook that echoes ctx.config back in the result data — after an
// optional `data.delay` await. Lets the integration test assert (a) the host-resolved per-session
// config slice reaches ctx.config, and (b) it stays correct when dispatches for different sessions
// interleave across an await (the AsyncLocalStorage scope must survive the await).
module.exports = class HookConfigPlugin {
async onEnable(ctx) {
ctx.registerHook('message:received', async (hookCtx) => {
const delay = hookCtx.data && hookCtx.data.delay ? hookCtx.data.delay : 0;
if (delay) await new Promise((r) => setTimeout(r, delay));
return { continue: true, data: { config: ctx.config } };
});
}
};