mirror of https://github.com/openclaw/openclaw.git
telegram: harden delete fallback and bump googlechat peer floor
This commit is contained in:
parent
f70d58cd9d
commit
8d2eb609e8
|
|
@ -214,7 +214,11 @@ export const telegramMessageActions: ChannelMessageActionAdapter = {
|
|||
|
||||
if (action === "delete") {
|
||||
const chatId = readTelegramChatIdParam(params);
|
||||
const hasMessageIdParam = Object.hasOwn(params, "messageId");
|
||||
const messageId = readTelegramMessageIdParam(params, { required: false });
|
||||
if (hasMessageIdParam && typeof messageId !== "number") {
|
||||
throw new Error("messageId must be a valid number for action=delete.");
|
||||
}
|
||||
if (typeof messageId === "number") {
|
||||
return await handleTelegramAction(
|
||||
{
|
||||
|
|
|
|||
|
|
@ -869,6 +869,29 @@ describe("telegramMessageActions", () => {
|
|||
expect(handleTelegramAction).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("rejects invalid delete messageId instead of falling back to topic deletion", async () => {
|
||||
const cfg = telegramCfg();
|
||||
const handleAction = telegramMessageActions.handleAction;
|
||||
if (!handleAction) {
|
||||
throw new Error("telegram handleAction unavailable");
|
||||
}
|
||||
|
||||
await expect(
|
||||
handleAction({
|
||||
channel: "telegram",
|
||||
action: "delete",
|
||||
params: {
|
||||
to: "-1001234567890",
|
||||
messageId: "oops",
|
||||
topicId: 271,
|
||||
},
|
||||
cfg,
|
||||
}),
|
||||
).rejects.toThrow(/messageId must be a valid number for action=delete/i);
|
||||
|
||||
expect(handleTelegramAction).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("rejects topic-delete when threadId/topicId is missing", async () => {
|
||||
const cfg = telegramCfg();
|
||||
const handleAction = telegramMessageActions.handleAction;
|
||||
|
|
|
|||
Loading…
Reference in New Issue