mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-10 02:40:45 +08:00
Expose resolveSessionPeer on ctx.dshIm for ops schedulers (ops.23).
WhatsApp registers a peer resolver so cron_create can default IM delivery to the calling session's bot/target. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
6d2229acd2
commit
41f13bb90c
3 changed files with 42 additions and 2 deletions
|
|
@ -17,7 +17,20 @@ export async function apply(ctx, config = {}) {
|
|||
config.rpcOptions,
|
||||
config.rpcAuthority,
|
||||
);
|
||||
let unregisterPeer = () => {};
|
||||
try {
|
||||
const dshIm = typeof ctx.get === 'function' ? ctx.get('dshIm') : undefined;
|
||||
if (dshIm && typeof dshIm.registerPeerResolver === 'function'
|
||||
&& typeof production.controller?.resolveChannelPeer === 'function') {
|
||||
unregisterPeer = dshIm.registerPeerResolver((sessionId) => (
|
||||
production.controller.resolveChannelPeer(sessionId)
|
||||
));
|
||||
}
|
||||
} catch {
|
||||
// dshIm optional during partial boots
|
||||
}
|
||||
ctx.effect(() => async () => {
|
||||
unregisterPeer?.();
|
||||
await unregisterDelivery?.();
|
||||
await production.close();
|
||||
}, 'dsh-im: close WhatsApp Web connections');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue