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

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

+19 -5
View File
@@ -8,6 +8,7 @@ import {
resolvePostgresConfigFromEnv,
resolveRedisConfigFromEnv,
} from '@sammo-ts/infra';
import { asRecord } from '@sammo-ts/common';
import { resolveGameApiConfigFromEnv } from '../config.js';
import { createBestEffortResourceCloser } from '../services/bestEffortResourceCloser.js';
@@ -258,7 +259,7 @@ export const processDueAuctionId = async (options: {
}
const current = await transaction.auction.findUnique({
where: { id: auctionId },
select: { status: true, closeAt: true, closeTick: true },
select: { type: true, status: true, closeAt: true, closeTick: true },
});
if (!current) {
return { status: 'IGNORED' as const };
@@ -278,7 +279,8 @@ export const processDueAuctionId = async (options: {
if (current.closeTick === null) throw new Error(`Auction ${auctionId} has no GAME_TIME close authority.`);
const deadline = { closeAt: current.closeAt, closeTick: current.closeTick };
for (let retry = 0; retry <= AUCTION_FINALIZE_RECOVERY_LIMIT; retry += 1) {
let retryLimit = AUCTION_FINALIZE_RECOVERY_LIMIT;
for (let retry = 0; retry <= retryLimit; retry += 1) {
const requestId = buildAuctionFinalizeRequestId(auctionId, deadline, retry);
const existing = await transaction.inputEvent.findUnique({
where: { requestId },
@@ -304,9 +306,21 @@ export const processDueAuctionId = async (options: {
return { status: 'PENDING' as const };
}
if (existing.status === 'SUCCEEDED' && isSuccessfulAuctionFinalizeResult(existing.result, auctionId)) {
throw new Error(
`Auction remained ${current.status} after successful durable event: ${requestId}`
);
throw new Error(`Auction remained ${current.status} after successful durable event: ${requestId}`);
}
const result = asRecord(existing.result);
if (
retry === AUCTION_FINALIZE_RECOVERY_LIMIT &&
current.type === 'UNIQUE_ITEM' &&
current.status === 'FINALIZING' &&
existing.status === 'SUCCEEDED' &&
result.type === 'auctionFinalize' &&
result.auctionId === auctionId &&
result.ok === false &&
result.reason === '입찰자를 찾을 수 없습니다.'
) {
// Re-enqueue once for rows left behind by the previous finalizer.
retryLimit += 1;
}
}
throw new Error(`Auction finalization recovery exhausted: ${auctionId}`);
+13 -1
View File
@@ -1,7 +1,7 @@
import { TRPCError } from '@trpc/server';
import { z } from 'zod';
import { asRecord, ChangeJournal } from '@sammo-ts/common';
import { writeReadModelChangeJournal } from '@sammo-ts/infra';
import { publishPublicSystemMessage, writeReadModelChangeJournal } from '@sammo-ts/infra';
import type { UserSanctions } from '@sammo-ts/common/auth/gameToken';
import { isMessageAccessBlocked } from '@sammo-ts/common/auth/sanctions';
@@ -492,6 +492,18 @@ export const messagesRouter = router({
...messageBuckets,
};
}),
sendSystem: wallAuthedProcedure
.input(
z.object({ noticeId: z.string().regex(/^[a-zA-Z0-9._-]{1,100}$/), text: z.string().trim().min(1).max(500) })
)
.mutation(async ({ ctx, input }) => {
const roles = ctx.auth?.user.roles ?? [];
if (!roles.includes('superuser') && !roles.includes('admin.superuser')) {
throw new TRPCError({ code: 'FORBIDDEN', message: '시스템 메시지를 보낼 권한이 없습니다.' });
}
const msgId = await publishPublicSystemMessage(ctx.db, input);
return { msgId };
}),
send: accessWallAuthedInputProcedure(
z.object({
generalId: z.number().int().positive(),