입찰 장수가 사라진 유니크 경매를 복구하고 시스템 공지를 지원한다

This commit is contained in:
Hide_D committed 2026-12-04 09:57:02 +09:00
1 parent 0ae14d5ee0
commit 3f51bec90a
6 files changed
+344 -23

No files matched your search

+48 -1
View File
@@ -1,6 +1,13 @@
import type { MessageRecordDraft } from '@sammo-ts/logic';
import {
MESSAGE_MAILBOX_PUBLIC,
resolveMessageTargetIcon,
sendMessage,
type MessageRecordDraft,
} from '@sammo-ts/logic';
import { GamePrisma } from './gamePrisma.js';
import { acquireGameSchemaAdvisoryXactLock } from './gameSchemaAdvisoryLock.js';
import { writeReadModelChangeJournal } from './readModelChangeJournal.js';
export interface MessageGameContext {
occurredGameTick: bigint;
@@ -96,3 +103,43 @@ export const persistMessageEnvelope = async (
if (!id) throw new Error('Failed to persist message envelope.');
return id;
};
export const publishPublicSystemMessage = async (
transaction: Pick<GamePrisma.TransactionClient, '$executeRaw' | '$queryRaw' | 'message'>,
notice: { noticeId: string; text: string }
): Promise<number> => {
await acquireGameSchemaAdvisoryXactLock(transaction, `public-system-message:${notice.noticeId}`);
const existing = await transaction.message.findFirst({
where: {
mailbox: MESSAGE_MAILBOX_PUBLIC,
type: 'public',
src: 0,
message: { path: ['option', 'noticeId'], equals: notice.noticeId },
},
select: { id: true },
});
if (existing) return existing.id;
const system = {
generalId: 0,
generalName: '시스템',
nationId: 0,
nationName: '',
color: '#000000',
icon: resolveMessageTargetIcon(),
};
const { receiverId } = await sendMessage(
{ insertMessage: (draft) => persistMessageEnvelope(transaction, draft) },
{
msgType: 'public',
src: system,
dest: system,
text: notice.text,
time: new Date(),
validUntil: new Date('9999-12-31T00:00:00Z'),
option: { noticeId: notice.noticeId },
}
);
await writeReadModelChangeJournal(transaction, [{ domain: 'messages.mailbox', entityId: MESSAGE_MAILBOX_PUBLIC }]);
return receiverId;
};