mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 03:51:25 +00:00
refactor(channels): share allowlist user resolve helpers
This commit is contained in:
@@ -4,7 +4,12 @@ import type { SessionScope } from "../../config/sessions.js";
|
||||
import type { MonitorSlackOpts } from "./types.js";
|
||||
import { resolveTextChunkLimit } from "../../auto-reply/chunk.js";
|
||||
import { DEFAULT_GROUP_HISTORY_LIMIT } from "../../auto-reply/reply/history.js";
|
||||
import { mergeAllowlist, summarizeMapping } from "../../channels/allowlists/resolve-utils.js";
|
||||
import {
|
||||
buildAllowlistResolutionSummary,
|
||||
mergeAllowlist,
|
||||
resolveAllowlistIdAdditions,
|
||||
summarizeMapping,
|
||||
} from "../../channels/allowlists/resolve-utils.js";
|
||||
import { loadConfig } from "../../config/config.js";
|
||||
import { warn } from "../../globals.js";
|
||||
import { installRequestBodyLimitGuard } from "../../infra/http-body.js";
|
||||
@@ -322,13 +327,8 @@ export async function monitorSlackProvider(opts: MonitorSlackOpts = {}) {
|
||||
token: resolveToken,
|
||||
entries: Array.from(userEntries),
|
||||
});
|
||||
const resolvedMap = new Map(resolvedUsers.map((entry) => [entry.input, entry]));
|
||||
const mapping = resolvedUsers
|
||||
.filter((entry) => entry.resolved && entry.id)
|
||||
.map((entry) => `${entry.input}→${entry.id}`);
|
||||
const unresolved = resolvedUsers
|
||||
.filter((entry) => !entry.resolved)
|
||||
.map((entry) => entry.input);
|
||||
const { resolvedMap, mapping, unresolved } =
|
||||
buildAllowlistResolutionSummary(resolvedUsers);
|
||||
|
||||
const nextChannels = { ...channelsConfig };
|
||||
for (const [channelKey, channelConfig] of Object.entries(channelsConfig)) {
|
||||
@@ -339,14 +339,10 @@ export async function monitorSlackProvider(opts: MonitorSlackOpts = {}) {
|
||||
if (!Array.isArray(channelUsers) || channelUsers.length === 0) {
|
||||
continue;
|
||||
}
|
||||
const additions: string[] = [];
|
||||
for (const entry of channelUsers) {
|
||||
const trimmed = String(entry).trim();
|
||||
const resolved = resolvedMap.get(trimmed);
|
||||
if (resolved?.resolved && resolved.id) {
|
||||
additions.push(resolved.id);
|
||||
}
|
||||
}
|
||||
const additions = resolveAllowlistIdAdditions({
|
||||
existing: channelUsers,
|
||||
resolvedMap,
|
||||
});
|
||||
nextChannels[channelKey] = {
|
||||
...channelConfig,
|
||||
users: mergeAllowlist({ existing: channelUsers, additions }),
|
||||
|
||||
Reference in New Issue
Block a user