mirror of https://github.com/openclaw/openclaw.git
refactor: share slack allowlist target mapping
This commit is contained in:
parent
f0d0ad39c4
commit
168394980f
|
|
@ -244,6 +244,18 @@ export const slackPlugin: ChannelPlugin<ResolvedSlackAccount> = {
|
||||||
},
|
},
|
||||||
resolver: {
|
resolver: {
|
||||||
resolveTargets: async ({ cfg, accountId, inputs, kind }) => {
|
resolveTargets: async ({ cfg, accountId, inputs, kind }) => {
|
||||||
|
const toResolvedTarget = <
|
||||||
|
T extends { input: string; resolved: boolean; id?: string; name?: string },
|
||||||
|
>(
|
||||||
|
entry: T,
|
||||||
|
note?: string,
|
||||||
|
) => ({
|
||||||
|
input: entry.input,
|
||||||
|
resolved: entry.resolved,
|
||||||
|
id: entry.id,
|
||||||
|
name: entry.name,
|
||||||
|
note,
|
||||||
|
});
|
||||||
const account = resolveSlackAccount({ cfg, accountId });
|
const account = resolveSlackAccount({ cfg, accountId });
|
||||||
const token = account.config.userToken?.trim() || account.botToken?.trim();
|
const token = account.config.userToken?.trim() || account.botToken?.trim();
|
||||||
if (!token) {
|
if (!token) {
|
||||||
|
|
@ -258,25 +270,15 @@ export const slackPlugin: ChannelPlugin<ResolvedSlackAccount> = {
|
||||||
token,
|
token,
|
||||||
entries: inputs,
|
entries: inputs,
|
||||||
});
|
});
|
||||||
return resolved.map((entry) => ({
|
return resolved.map((entry) =>
|
||||||
input: entry.input,
|
toResolvedTarget(entry, entry.archived ? "archived" : undefined),
|
||||||
resolved: entry.resolved,
|
);
|
||||||
id: entry.id,
|
|
||||||
name: entry.name,
|
|
||||||
note: entry.archived ? "archived" : undefined,
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
const resolved = await getSlackRuntime().channel.slack.resolveUserAllowlist({
|
const resolved = await getSlackRuntime().channel.slack.resolveUserAllowlist({
|
||||||
token,
|
token,
|
||||||
entries: inputs,
|
entries: inputs,
|
||||||
});
|
});
|
||||||
return resolved.map((entry) => ({
|
return resolved.map((entry) => toResolvedTarget(entry, entry.note));
|
||||||
input: entry.input,
|
|
||||||
resolved: entry.resolved,
|
|
||||||
id: entry.id,
|
|
||||||
name: entry.name,
|
|
||||||
note: entry.note,
|
|
||||||
}));
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue