feat(channels): share line and zalo binary attachments via minio
This commit is contained in:
@@ -18,8 +18,33 @@ export interface ChannelsResult {
|
||||
gmailWatcher?: GmailWatcher;
|
||||
}
|
||||
|
||||
function resolveChannelMinioShare(config: Config): {
|
||||
enabled: boolean;
|
||||
endpoint: string;
|
||||
accessKey: string;
|
||||
secretKey: string;
|
||||
bucket: string;
|
||||
prefix: string;
|
||||
secure: boolean;
|
||||
} | undefined {
|
||||
const minio = config.backup.minio;
|
||||
if (!minio.enabled || !minio.endpoint || !minio.access_key || !minio.secret_key || !minio.bucket) {
|
||||
return undefined;
|
||||
}
|
||||
return {
|
||||
enabled: true,
|
||||
endpoint: minio.endpoint,
|
||||
accessKey: minio.access_key,
|
||||
secretKey: minio.secret_key,
|
||||
bucket: minio.bucket,
|
||||
prefix: minio.prefix,
|
||||
secure: minio.secure,
|
||||
};
|
||||
}
|
||||
|
||||
export function registerChannels(deps: ChannelsDeps): ChannelsResult {
|
||||
const { config, channelRegistry, hookEngine, pairingManager, gateway } = deps;
|
||||
const channelMinioShare = resolveChannelMinioShare(config);
|
||||
|
||||
// Register Telegram adapter (if configured)
|
||||
if (config.telegram) {
|
||||
@@ -162,6 +187,9 @@ export function registerChannels(deps: ChannelsDeps): ChannelsResult {
|
||||
allowedSourceIds: config.line.allowed_source_ids.length > 0 ? config.line.allowed_source_ids : undefined,
|
||||
requireMention: config.line.require_mention,
|
||||
mentionName: config.line.mention_name,
|
||||
minio: channelMinioShare
|
||||
? { ...channelMinioShare, prefix: `${channelMinioShare.prefix.replace(/\/+$/, '')}/channels/line` }
|
||||
: undefined,
|
||||
});
|
||||
channelRegistry.register(lineAdapter);
|
||||
gateway.setLineHandler(lineAdapter);
|
||||
@@ -191,6 +219,9 @@ export function registerChannels(deps: ChannelsDeps): ChannelsResult {
|
||||
allowedUserIds: config.zalo.allowed_user_ids.length > 0 ? config.zalo.allowed_user_ids : undefined,
|
||||
requireMention: config.zalo.require_mention,
|
||||
mentionName: config.zalo.mention_name,
|
||||
minio: channelMinioShare
|
||||
? { ...channelMinioShare, prefix: `${channelMinioShare.prefix.replace(/\/+$/, '')}/channels/zalo` }
|
||||
: undefined,
|
||||
});
|
||||
channelRegistry.register(zaloAdapter);
|
||||
gateway.setZaloHandler(zaloAdapter);
|
||||
|
||||
Reference in New Issue
Block a user