mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-09 11:43:19 +08:00
Add Telegram and Discord IM channels
This commit is contained in:
parent
7123fce47a
commit
cb74e1c4c7
66 changed files with 8579 additions and 1910 deletions
|
|
@ -24,10 +24,17 @@ function controllerFrom(ctx, config) {
|
|||
*/
|
||||
export async function apply(ctx, config = {}) {
|
||||
const controller = controllerFrom(ctx, config);
|
||||
if (controller) return installFeishuRpc(ctx, controller);
|
||||
if (controller) {
|
||||
return installFeishuRpc(ctx, controller, config.rpcOptions, config.rpcAuthority);
|
||||
}
|
||||
|
||||
const production = await createProductionController(ctx, config);
|
||||
const disposeRpc = installFeishuRpc(ctx, production.controller);
|
||||
const disposeRpc = installFeishuRpc(
|
||||
ctx,
|
||||
production.controller,
|
||||
config.rpcOptions,
|
||||
config.rpcAuthority,
|
||||
);
|
||||
ctx.effect(() => async () => {
|
||||
await production.close();
|
||||
}, 'dsh-feishu: close controller and live connection');
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import QRCode from 'qrcode';
|
||||
import { resolveRpcAuthority } from '../../rpc-authority.mjs';
|
||||
import {
|
||||
FEISHU_ENDPOINTS,
|
||||
FEISHU_RPC_CHANNEL,
|
||||
|
|
@ -440,14 +441,14 @@ export function createFeishuRpcHandler(controller, { encodeQr = qrCodeDataUrl }
|
|||
};
|
||||
}
|
||||
|
||||
/** Register the loopback-only `/feishu` logical channel. */
|
||||
export function installFeishuRpc(ctx, controller, options) {
|
||||
/** Register the `/feishu` logical channel with its configured browser authority. */
|
||||
export function installFeishuRpc(ctx, controller, options, authority) {
|
||||
if (!ctx?.connection?.rpc || typeof ctx.connection.rpc.handle !== 'function') {
|
||||
throw new TypeError('DSH Host Connection RPC is required');
|
||||
}
|
||||
return ctx.connection.rpc.handle(
|
||||
FEISHU_RPC_CHANNEL,
|
||||
createFeishuRpcHandler(controller, options),
|
||||
{ authority: 'loopback' },
|
||||
{ authority: resolveRpcAuthority(authority) },
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue