telegram: strict topic ids in tool action and relax peer pins

This commit is contained in:
Alexander Bolshakov 2026-03-09 23:21:37 +01:00 committed by OpenClaw Agent
parent a280f31a43
commit b5bdfd8b6a
3 changed files with 34 additions and 96 deletions

View File

@ -942,102 +942,6 @@ public struct NodeEventParams: Codable, Sendable {
}
}
public struct NodePendingDrainParams: Codable, Sendable {
public let maxitems: Int?
public init(
maxitems: Int?)
{
self.maxitems = maxitems
}
private enum CodingKeys: String, CodingKey {
case maxitems = "maxItems"
}
}
public struct NodePendingDrainResult: Codable, Sendable {
public let nodeid: String
public let revision: Int
public let items: [[String: AnyCodable]]
public let hasmore: Bool
public init(
nodeid: String,
revision: Int,
items: [[String: AnyCodable]],
hasmore: Bool)
{
self.nodeid = nodeid
self.revision = revision
self.items = items
self.hasmore = hasmore
}
private enum CodingKeys: String, CodingKey {
case nodeid = "nodeId"
case revision
case items
case hasmore = "hasMore"
}
}
public struct NodePendingEnqueueParams: Codable, Sendable {
public let nodeid: String
public let type: String
public let priority: String?
public let expiresinms: Int?
public let wake: Bool?
public init(
nodeid: String,
type: String,
priority: String?,
expiresinms: Int?,
wake: Bool?)
{
self.nodeid = nodeid
self.type = type
self.priority = priority
self.expiresinms = expiresinms
self.wake = wake
}
private enum CodingKeys: String, CodingKey {
case nodeid = "nodeId"
case type
case priority
case expiresinms = "expiresInMs"
case wake
}
}
public struct NodePendingEnqueueResult: Codable, Sendable {
public let nodeid: String
public let revision: Int
public let queued: [String: AnyCodable]
public let waketriggered: Bool
public init(
nodeid: String,
revision: Int,
queued: [String: AnyCodable],
waketriggered: Bool)
{
self.nodeid = nodeid
self.revision = revision
self.queued = queued
self.waketriggered = waketriggered
}
private enum CodingKeys: String, CodingKey {
case nodeid = "nodeId"
case revision
case queued
case waketriggered = "wakeTriggered"
}
}
public struct NodeInvokeRequestEvent: Codable, Sendable {
public let id: String
public let nodeid: String

View File

@ -598,6 +598,22 @@ describe("handleTelegramAction", () => {
);
});
it("rejects malformed message ids for deleteMessage", async () => {
const cfg = {
channels: { telegram: { botToken: "tok" } },
} as OpenClawConfig;
await expect(
handleTelegramAction(
{
action: "deleteMessage",
chatId: "123",
messageId: "456oops",
},
cfg,
),
).rejects.toThrow(/messageId required/);
});
it("deletes a forum topic", async () => {
const cfg = {
channels: { telegram: { botToken: "tok" } },
@ -617,6 +633,22 @@ describe("handleTelegramAction", () => {
);
});
it("rejects malformed topic ids for deleteForumTopic", async () => {
const cfg = {
channels: { telegram: { botToken: "tok" } },
} as OpenClawConfig;
await expect(
handleTelegramAction(
{
action: "deleteForumTopic",
chatId: "-100123",
topicId: "271abc",
},
cfg,
),
).rejects.toThrow(/topicId required/);
});
it("respects deleteMessage gating for deleteForumTopic", async () => {
const cfg = {
channels: {

View File

@ -327,6 +327,7 @@ export async function handleTelegramAction(
const messageId = readNumberParam(params, "messageId", {
required: true,
integer: true,
strict: true,
});
const token = resolveTelegramToken(cfg, { accountId }).token;
if (!token) {
@ -354,6 +355,7 @@ export async function handleTelegramAction(
const topicId = readNumberParam(params, "topicId", {
required: true,
integer: true,
strict: true,
});
const token = resolveTelegramToken(cfg, { accountId }).token;
if (!token) {