Complete instant diplomacy response parity

This commit is contained in:
Hide_D committed 2026-07-26 03:10:41 +00:00
1 parent b3f4734e80
commit 9885bf6905
23 files changed
+2072 -305

No files matched your search

+19
View File
@@ -140,6 +140,25 @@ export const fetchMessageById = async (db: DatabaseClient, id: number): Promise<
};
};
export const fetchMessageByIdForUpdate = async (db: DatabaseClient, id: number): Promise<StoredMessage | null> => {
const rows = await db.$queryRaw<MessageRow[]>`
SELECT id, mailbox, type, src, dest, time, valid_until, message
FROM message
WHERE id = ${id} AND valid_until > NOW()
LIMIT 1
FOR UPDATE
`;
const row = rows[0];
if (!row) return null;
return {
id: row.id,
mailbox: row.mailbox,
msgType: row.type,
time: new Date(row.time),
payload: parsePayload(row.message),
};
};
export const invalidateMessages = async (db: DatabaseClient, ids: number[]): Promise<void> => {
const uniqueIds = Array.from(new Set(ids.filter((id) => Number.isInteger(id) && id > 0)));
if (uniqueIds.length === 0) return;