mirror of
https://github.com/Elysola/WebHooker.git
synced 2026-11-21 01:23:40 +00:00
fix(telegram): report unreadable send results
An unreadable successful response may already have sent the message. Report an explicit uncertain result instead of retrying a create without an idempotency key or pretending it succeeded.
This commit is contained in:
1 parent
b212989c05
commit
867d2af6ac
1 file changed
+16
-1
@@ -76,10 +76,25 @@ async function post(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Accepted, but the answer is unreadable (cut off, timed out): the
|
||||||
|
// message may well exist, and Telegram has no idempotency key, so a
|
||||||
|
// retry could post it twice — a visible failure, not retried (and not
|
||||||
|
// a success without a message id, which an update chain would lose).
|
||||||
|
if (data?.ok !== true) {
|
||||||
|
log.error({ status: res.status, chatId }, "Unreadable Telegram response");
|
||||||
|
return {
|
||||||
|
ok: false,
|
||||||
|
error: "Telegram accepted the request, but its answer could not be read",
|
||||||
|
errorCode: "TELEGRAM_UNCERTAIN",
|
||||||
|
status: res.status,
|
||||||
|
attempts: attempt + 1,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
ok: true,
|
ok: true,
|
||||||
status: res.status,
|
status: res.status,
|
||||||
messageId: data?.result?.message_id != null ? String(data.result.message_id) : undefined,
|
messageId: data.result?.message_id != null ? String(data.result.message_id) : undefined,
|
||||||
attempts: attempt + 1,
|
attempts: attempt + 1,
|
||||||
};
|
};
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
Reference in new issue
Block a user