Fix Discord session routing continuity (enable lastRoute for groups)\n\nPreviously, 'updateLastRoute' was only enabled for Direct Messages.\nThis meant that group/channel sessions did not update their routing\nmetadata (last channel/to/accountId) in 'session-meta.json'.\n\nIf the bot restarted or a proactive cron job tried to send a message\nto a group session using 'sessions_send' without an explicit 'to' field,\nit would fail because 'lastRoute' was missing or stale.\n\nFix: Enable 'updateLastRoute' for all Discord messages (Group + DM),\nensuring the session store always has the latest valid routing target.

This commit is contained in:
Rain
2026-02-16 20:58:30 +08:00
committed by Peter Steinberger
parent dbe2ab6f62
commit b90d7625e5
2 changed files with 76 additions and 8 deletions

View File

@@ -557,14 +557,12 @@ export async function processDiscordMessage(ctx: DiscordMessagePreflightContext)
storePath,
sessionKey: ctxPayload.SessionKey ?? route.sessionKey,
ctx: ctxPayload,
updateLastRoute: isDirectMessage
? {
sessionKey: route.mainSessionKey,
channel: "discord",
to: `user:${author.id}`,
accountId: route.accountId,
}
: undefined,
updateLastRoute: {
sessionKey: ctxPayload.SessionKey ?? route.sessionKey,
channel: "discord",
to: effectiveTo,
accountId: route.accountId,
},
onRecordError: (err) => {
logVerbose(`discord: failed updating session meta: ${String(err)}`);
},