mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-09 04:13:17 +08:00
33 lines
1.3 KiB
JavaScript
33 lines
1.3 KiB
JavaScript
import { createProductionController } from './production.mjs';
|
|
import { installSlackRpc } from './rpc.mjs';
|
|
|
|
export const name = 'dsh-im-slack-host';
|
|
export const inject = ['connection', 'credentials', 'typertGateway'];
|
|
|
|
export async function apply(ctx, config = {}) {
|
|
if (config?.controller) return installSlackRpc(ctx, config.controller, config.rpcAuthority);
|
|
const production = await createProductionController(ctx, config, config.internals ?? {});
|
|
const unregisterDelivery = config.deliveryService && production.deliveryAdapter
|
|
? config.deliveryService.registerAdapter(production.deliveryAdapter) : undefined;
|
|
const disposeRpc = installSlackRpc(ctx, production.controller, config.rpcAuthority);
|
|
ctx.effect(() => async () => {
|
|
await unregisterDelivery?.();
|
|
await production.close();
|
|
}, 'dsh-im: close Slack bot connections');
|
|
return disposeRpc;
|
|
}
|
|
|
|
export function createSlackHostPlugin(config) {
|
|
return Object.freeze({ name, inject, apply: (ctx) => apply(ctx, config) });
|
|
}
|
|
|
|
export { createProductionController } from './production.mjs';
|
|
export {
|
|
SLACK_ENDPOINTS,
|
|
SLACK_RPC_CHANNEL,
|
|
SLACK_RPC_ENDPOINTS,
|
|
createSlackRpcHandler,
|
|
installSlackRpc,
|
|
} from './rpc.mjs';
|
|
export { SlackController } from '../../../../src/channels/slack/slack-controller.mjs';
|
|
export { SlackRuntime } from '../../../../src/channels/slack/slack-runtime.mjs';
|