fix: harden telegram forum-service mention guard typing (#32262) (thanks @scoootscooob)

This commit is contained in:
Peter Steinberger
2026-03-02 23:32:40 +00:00
parent 58ad617e64
commit 28c88e9fa1
3 changed files with 27 additions and 3 deletions

View File

@@ -888,9 +888,10 @@ const FORUM_SERVICE_FIELDS = [
* `forum_topic_*` / `general_forum_topic_*` fields and should not count as
* regular bot replies for implicit-mention purposes.
*/
function isTelegramForumServiceMessage(msg: Record<string, unknown> | undefined | null): boolean {
if (!msg) {
function isTelegramForumServiceMessage(msg: unknown): boolean {
if (!msg || typeof msg !== "object") {
return false;
}
return FORUM_SERVICE_FIELDS.some((f) => msg[f] != null);
const record = msg as Record<string, unknown>;
return FORUM_SERVICE_FIELDS.some((f) => record[f] != null);
}