chore: enable consistent-return

This commit is contained in:
Peter Steinberger
2026-04-10 20:56:08 +01:00
parent bc27278d6d
commit 0ebeee8b0d
68 changed files with 223 additions and 107 deletions

View File

@@ -456,18 +456,18 @@ export function createMatrixRoomMessageHandler(params: MatrixMonitorHandlerParam
const readIngressPrefix = async () => {
const selfUserId = await client.getUserId();
if (senderId === selfUserId) {
return;
return undefined;
}
if (dropPreStartupMessages) {
if (typeof eventTs === "number" && eventTs < startupMs - startupGraceMs) {
return;
return undefined;
}
if (
typeof eventTs !== "number" &&
typeof eventAge === "number" &&
eventAge > startupGraceMs
) {
return;
return undefined;
}
}
@@ -481,7 +481,7 @@ export function createMatrixRoomMessageHandler(params: MatrixMonitorHandlerParam
})
) {
logVerboseMessage(`matrix: skip verification/system room message room=${roomId}`);
return;
return undefined;
}
const locationPayload: MatrixLocationPayload | null = resolveMatrixLocation({
@@ -491,13 +491,13 @@ export function createMatrixRoomMessageHandler(params: MatrixMonitorHandlerParam
const relates = content["m.relates_to"];
if (relates && "rel_type" in relates && relates.rel_type === RelationType.Replace) {
return;
return undefined;
}
if (eventId && inboundDeduper) {
claimedInboundEvent = inboundDeduper.claimEvent({ roomId, eventId });
if (!claimedInboundEvent) {
logVerboseMessage(`matrix: skip duplicate inbound event room=${roomId} id=${eventId}`);
return;
return undefined;
}
}
@@ -520,7 +520,7 @@ export function createMatrixRoomMessageHandler(params: MatrixMonitorHandlerParam
const { locationPayload, selfUserId } = params;
if (isRoom && groupPolicy === "disabled") {
await commitInboundEventIfClaimed();
return;
return undefined;
}
const roomInfoForConfig =
@@ -553,24 +553,24 @@ export function createMatrixRoomMessageHandler(params: MatrixMonitorHandlerParam
`matrix: drop configured bot sender=${senderId} (allowBots=false${isDirectMessage ? "" : `, ${roomMatchMeta}`})`,
);
await commitInboundEventIfClaimed();
return;
return undefined;
}
if (isRoom && roomConfig && !roomConfigInfo?.allowed) {
logVerboseMessage(`matrix: room disabled room=${roomId} (${roomMatchMeta})`);
await commitInboundEventIfClaimed();
return;
return undefined;
}
if (isRoom && groupPolicy === "allowlist") {
if (!roomConfigInfo?.allowlistConfigured) {
logVerboseMessage(`matrix: drop room message (no allowlist, ${roomMatchMeta})`);
await commitInboundEventIfClaimed();
return;
return undefined;
}
if (!roomConfig) {
logVerboseMessage(`matrix: drop room message (not in allowlist, ${roomMatchMeta})`);
await commitInboundEventIfClaimed();
return;
return undefined;
}
}
@@ -602,7 +602,7 @@ export function createMatrixRoomMessageHandler(params: MatrixMonitorHandlerParam
if (isDirectMessage) {
if (!dmEnabled || dmPolicy === "disabled") {
await commitInboundEventIfClaimed();
return;
return undefined;
}
if (dmPolicy !== "open") {
const allowMatchMeta = formatAllowlistMatchMeta(directAllowMatch);
@@ -643,7 +643,7 @@ export function createMatrixRoomMessageHandler(params: MatrixMonitorHandlerParam
logVerboseMessage(
`matrix pairing reply failed for ${senderId}: ${String(err)}`,
);
return;
return undefined;
}
} else {
logVerboseMessage(
@@ -658,7 +658,7 @@ export function createMatrixRoomMessageHandler(params: MatrixMonitorHandlerParam
);
await commitInboundEventIfClaimed();
}
return;
return undefined;
}
}
}
@@ -670,7 +670,7 @@ export function createMatrixRoomMessageHandler(params: MatrixMonitorHandlerParam
)})`,
);
await commitInboundEventIfClaimed();
return;
return undefined;
}
if (
isRoom &&
@@ -686,7 +686,7 @@ export function createMatrixRoomMessageHandler(params: MatrixMonitorHandlerParam
)})`,
);
await commitInboundEventIfClaimed();
return;
return undefined;
}
if (isRoom) {
logVerboseMessage(`matrix: allow room ${roomId} (${roomMatchMeta})`);
@@ -708,7 +708,7 @@ export function createMatrixRoomMessageHandler(params: MatrixMonitorHandlerParam
logVerboseMessage,
});
await commitInboundEventIfClaimed();
return;
return undefined;
}
let pollSnapshotPromise: Promise<MatrixPollSnapshot | null> | null = null;
@@ -748,7 +748,7 @@ export function createMatrixRoomMessageHandler(params: MatrixMonitorHandlerParam
: "";
if (!mentionPrecheckText && !mediaUrl && !isPollEvent) {
await commitInboundEventIfClaimed();
return;
return undefined;
}
const _messageId = event.event_id ?? "";
@@ -797,7 +797,7 @@ export function createMatrixRoomMessageHandler(params: MatrixMonitorHandlerParam
`matrix: drop configured bot sender=${senderId} (allowBots=mentions, missing mention, ${roomMatchMeta})`,
);
await commitInboundEventIfClaimed();
return;
return undefined;
}
const allowTextCommands = core.channel.commands.shouldHandleTextCommands({
cfg,
@@ -823,7 +823,7 @@ export function createMatrixRoomMessageHandler(params: MatrixMonitorHandlerParam
target: senderId,
});
await commitInboundEventIfClaimed();
return;
return undefined;
}
const shouldRequireMention = isRoom
? roomConfig?.autoReply === true
@@ -856,13 +856,13 @@ export function createMatrixRoomMessageHandler(params: MatrixMonitorHandlerParam
}
logger.info("skipping room message", { roomId, reason: "no-mention" });
await commitInboundEventIfClaimed();
return;
return undefined;
}
if (isPollEvent) {
const pollSnapshot = await getPollSnapshot();
if (!pollSnapshot) {
return;
return undefined;
}
content = {
msgtype: "m.text",
@@ -935,7 +935,7 @@ export function createMatrixRoomMessageHandler(params: MatrixMonitorHandlerParam
});
if (!bodyText) {
await commitInboundEventIfClaimed();
return;
return undefined;
}
const senderName = await getSenderName();
if (_configuredBinding) {
@@ -950,7 +950,7 @@ export function createMatrixRoomMessageHandler(params: MatrixMonitorHandlerParam
reason: "configured ACP binding unavailable",
target: _configuredBinding.spec.conversationId,
});
return;
return undefined;
}
}
if (_runtimeBindingId) {
@@ -997,7 +997,7 @@ export function createMatrixRoomMessageHandler(params: MatrixMonitorHandlerParam
? await runRoomIngress(roomId, async () => {
const prefix = await readIngressPrefix();
if (!prefix) {
return;
return undefined;
}
if (prefix.isDirectMessage) {
return { deferredPrefix: prefix } as const;
@@ -1013,7 +1013,7 @@ export function createMatrixRoomMessageHandler(params: MatrixMonitorHandlerParam
: await (async () => {
const prefix = await readIngressPrefix();
if (!prefix) {
return;
return undefined;
}
return await continueIngress(prefix);
})();