Skip to content

Commit 270630b

Browse files
committed
refactor: simplify channel setup conversions
1 parent 55f3570 commit 270630b

21 files changed

Lines changed: 37 additions & 29 deletions

File tree

extensions/feishu/src/channel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,7 @@ export const feishuPlugin: ChannelPlugin<ResolvedFeishuAccount, FeishuProbeResul
10581058
return jsonActionResult({ ok: true, reactions });
10591059
}
10601060

1061-
throw new Error(`Unsupported Feishu action: "${String(ctx.action)}"`);
1061+
throw new Error(`Unsupported Feishu action: "${ctx.action}"`);
10621062
},
10631063
},
10641064
bindings: {

extensions/feishu/src/policy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export function resolveFeishuAllowlistMatch(params: {
4242

4343
// Feishu allowlists are ID-based; mutable display names must never grant access.
4444
const senderCandidates = [params.senderId, ...(params.senderIds ?? [])]
45-
.map((entry) => normalizeFeishuAllowEntry(String(entry ?? "")))
45+
.map((entry) => normalizeFeishuAllowEntry(entry ?? ""))
4646
.filter(Boolean);
4747

4848
for (const senderId of senderCandidates) {

extensions/feishu/src/send.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ function parseFeishuMessageItem(
276276
senderType: item.sender?.sender_type,
277277
content: parseFeishuMessageContent(rawContent, msgType),
278278
contentType: msgType,
279-
createTime: item.create_time ? parseInt(String(item.create_time), 10) : undefined,
279+
createTime: item.create_time ? parseInt(item.create_time, 10) : undefined,
280280
threadId: item.thread_id || undefined,
281281
};
282282
}

extensions/firecrawl/src/firecrawl-client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ async function postFirecrawlJson<T>(
141141
detail = errorBody.text;
142142
}
143143
}
144-
const safeDetail = wrapWebContent(String(detail).slice(0, 1_000), "web_fetch");
144+
const safeDetail = wrapWebContent(detail.slice(0, 1_000), "web_fetch");
145145
throw new Error(`${params.errorLabel} API error (${response.status}): ${safeDetail}`);
146146
}
147147
return await parse(response);

extensions/msteams/src/monitor-handler/access.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export async function resolveMSTeamsSenderAccess(params: {
4343
dmPolicy,
4444
readStore: pairing.readStoreForDmPolicy,
4545
});
46-
const configuredDmAllowFrom = (msteamsCfg?.allowFrom ?? []).map((entry) => String(entry));
46+
const configuredDmAllowFrom = msteamsCfg?.allowFrom ?? [];
4747
const groupAllowFrom = msteamsCfg?.groupAllowFrom;
4848
const resolvedAllowFromLists = resolveEffectiveAllowFromLists({
4949
allowFrom: configuredDmAllowFrom,

extensions/msteams/src/monitor.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,17 +103,16 @@ export async function monitorMSTeamsProvider(
103103

104104
try {
105105
const allowEntries =
106-
allowFrom
107-
?.map((entry) => cleanAllowEntry(String(entry)))
108-
.filter((entry) => entry && entry !== "*") ?? [];
106+
allowFrom?.map((entry) => cleanAllowEntry(entry)).filter((entry) => entry && entry !== "*") ??
107+
[];
109108
if (allowEntries.length > 0) {
110109
const { additions } = await resolveAllowlistUsers("msteams users", allowEntries);
111110
allowFrom = mergeAllowlist({ existing: allowFrom, additions });
112111
}
113112

114113
if (Array.isArray(groupAllowFrom) && groupAllowFrom.length > 0) {
115114
const groupEntries = groupAllowFrom
116-
.map((entry) => cleanAllowEntry(String(entry)))
115+
.map((entry) => cleanAllowEntry(entry))
117116
.filter((entry) => entry && entry !== "*");
118117
if (groupEntries.length > 0) {
119118
const { additions } = await resolveAllowlistUsers("msteams group users", groupEntries);

extensions/nextcloud-talk/src/monitor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ function payloadToInboundMessage(
171171
const isGroupChat = true;
172172

173173
return {
174-
messageId: String(payload.object.id),
174+
messageId: payload.object.id,
175175
roomToken: payload.target.id,
176176
roomName: payload.target.name,
177177
senderId: payload.actor.id,

extensions/nextcloud-talk/src/setup-core.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ async function promptNextcloudTalkAllowFrom(params: {
123123
message: "Nextcloud Talk allowFrom (user id)",
124124
placeholder: "username",
125125
parseEntries: (raw) => ({
126-
entries: String(raw)
126+
entries: raw
127127
.split(/[\n,;]+/g)
128128
.map(normalizeLowercaseStringOrEmpty)
129129
.filter(Boolean),

extensions/synology-chat/src/setup-surface.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,24 @@ function parseSynologyUserId(value: string): string | null {
127127
return /^\d+$/.test(cleaned) ? cleaned : null;
128128
}
129129

130+
function normalizeSynologyAllowedUserId(value: unknown): string {
131+
if (
132+
typeof value === "string" ||
133+
typeof value === "number" ||
134+
typeof value === "boolean" ||
135+
typeof value === "bigint"
136+
) {
137+
return `${value}`.trim();
138+
}
139+
return "";
140+
}
141+
130142
function resolveExistingAllowedUserIds(cfg: OpenClawConfig, accountId: string): string[] {
131143
const raw = getRawAccountConfig(cfg, accountId).allowedUserIds;
132144
if (Array.isArray(raw)) {
133-
return raw.map((value) => String(value).trim()).filter(Boolean);
145+
return raw.map(normalizeSynologyAllowedUserId).filter(Boolean);
134146
}
135-
return String(raw ?? "")
147+
return normalizeSynologyAllowedUserId(raw)
136148
.split(",")
137149
.map((value) => value.trim())
138150
.filter(Boolean);

extensions/tlon/src/setup-core.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export function createTlonSetupWizardBase(params: TlonSetupWizardBaseParams): Ch
9999
placeholder: "https://your-ship-host",
100100
currentValue: ({ cfg, accountId }) => resolveTlonAccount(cfg, accountId).url ?? undefined,
101101
validate: ({ value }) => {
102-
const next = validateUrbitBaseUrl(String(value ?? ""));
102+
const next = validateUrbitBaseUrl(value ?? "");
103103
if (!next.ok) {
104104
return next.error;
105105
}

0 commit comments

Comments
 (0)