chore: test deploy snapshot
This commit is contained in:
@@ -66,6 +66,7 @@ import { getTokenSettingById, type TokenSettingRecord } from '../services/token-
|
||||
const CHAT_ATTACHMENT_FILE_SIZE_LIMIT = 300 * 1024 * 1024;
|
||||
const CHAT_ATTACHMENT_ROUTE_BODY_LIMIT = 450 * 1024 * 1024;
|
||||
const CHAT_PUBLIC_ROUTE_PREFIX = '/.codex_chat/';
|
||||
const CHAT_LEGACY_PUBLIC_ROUTE_PREFIX = '/public/.codex_chat/';
|
||||
const CHAT_API_RESOURCE_ROUTE_PREFIX = '/api/chat/resources';
|
||||
const CHAT_SHARE_ROUTE_PREFIX = '/api/chat/shares';
|
||||
const CHAT_SHARE_TOKEN_VERSION = 1;
|
||||
@@ -1235,7 +1236,11 @@ async function buildChatShareSnapshot(
|
||||
tokenPayload.kind === 'request-bundle' && normalizedSessionId.startsWith(MANAGED_CHAT_SHARE_SESSION_PREFIX);
|
||||
const useInitialManagedShareRoomView = isManagedShareRoomSession && detailLevel === 'initial';
|
||||
const detailPage = useInitialManagedShareRoomView
|
||||
? await listChatConversationDetailPage(normalizedSessionId, { limit: 12 })
|
||||
? await listChatConversationDetailPage(normalizedSessionId, {
|
||||
limit: 12,
|
||||
includeActivityLogs: false,
|
||||
includePagination: false,
|
||||
})
|
||||
: null;
|
||||
const [requests, messages] = detailPage
|
||||
? [detailPage.requests, detailPage.messages]
|
||||
@@ -1571,7 +1576,7 @@ async function ensureManagedShareAccessPin(
|
||||
});
|
||||
|
||||
if (pinStatus.status === 'ok' || pinStatus.status === 'not-configured') {
|
||||
return true;
|
||||
return pinStatus;
|
||||
}
|
||||
|
||||
if (pinStatus.status === 'required') {
|
||||
@@ -1579,7 +1584,7 @@ async function ensureManagedShareAccessPin(
|
||||
code: 'share_pin_required',
|
||||
message: '이 공유 채팅방은 4자리 비밀번호 입력이 필요합니다.',
|
||||
});
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
if (pinStatus.status === 'invalid') {
|
||||
@@ -1587,17 +1592,17 @@ async function ensureManagedShareAccessPin(
|
||||
code: 'share_pin_invalid',
|
||||
message: '공유 채팅방 비밀번호가 올바르지 않습니다.',
|
||||
});
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
if (pinStatus.status === 'missing') {
|
||||
reply.code(404).send({
|
||||
message: '공유 링크를 찾을 수 없습니다.',
|
||||
});
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
return true;
|
||||
return null;
|
||||
}
|
||||
|
||||
function hasManagedSharePermission(
|
||||
@@ -1641,6 +1646,11 @@ export async function registerChatRoutes(app: FastifyInstance) {
|
||||
return serveChatPublicResource(resolveChatAttachmentRepoPath(), wildcard, reply);
|
||||
});
|
||||
|
||||
app.get(`${CHAT_LEGACY_PUBLIC_ROUTE_PREFIX}*`, async (request, reply) => {
|
||||
const wildcard = String((request.params as { '*': string | undefined })['*'] ?? '').trim();
|
||||
return serveChatPublicResource(resolveChatAttachmentRepoPath(), wildcard, reply);
|
||||
});
|
||||
|
||||
app.get(`${CHAT_API_RESOURCE_ROUTE_PREFIX}/*`, async (request, reply) => {
|
||||
const wildcard = String((request.params as { '*': string | undefined })['*'] ?? '').trim();
|
||||
return serveChatPublicResource(resolveChatAttachmentRepoPath(), wildcard, reply);
|
||||
@@ -1668,7 +1678,9 @@ export async function registerChatRoutes(app: FastifyInstance) {
|
||||
});
|
||||
}
|
||||
|
||||
if (!(await ensureManagedShareAccessPin(request, reply, managedContext.sharePath))) {
|
||||
const accessPinStatus = await ensureManagedShareAccessPin(request, reply, managedContext.sharePath);
|
||||
|
||||
if (!accessPinStatus) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1898,7 +1910,9 @@ export async function registerChatRoutes(app: FastifyInstance) {
|
||||
});
|
||||
}
|
||||
|
||||
if (!(await ensureManagedShareAccessPin(request, reply, managedContext.sharePath))) {
|
||||
const accessPinStatus = await ensureManagedShareAccessPin(request, reply, managedContext.sharePath);
|
||||
|
||||
if (!accessPinStatus) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2033,7 +2047,9 @@ export async function registerChatRoutes(app: FastifyInstance) {
|
||||
});
|
||||
}
|
||||
|
||||
if (!(await ensureManagedShareAccessPin(request, reply, managedContext.sharePath))) {
|
||||
const accessPinStatus = await ensureManagedShareAccessPin(request, reply, managedContext.sharePath);
|
||||
|
||||
if (!accessPinStatus) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2467,7 +2483,9 @@ export async function registerChatRoutes(app: FastifyInstance) {
|
||||
});
|
||||
}
|
||||
|
||||
if (!(await ensureManagedShareAccessPin(request, reply, managedContext.sharePath))) {
|
||||
const accessPinStatus = await ensureManagedShareAccessPin(request, reply, managedContext.sharePath);
|
||||
|
||||
if (!accessPinStatus) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2497,15 +2515,19 @@ export async function registerChatRoutes(app: FastifyInstance) {
|
||||
});
|
||||
}
|
||||
|
||||
const accessPinStatus = await validateSharedResourceAccessPinBySharePath(managedContext.sharePath, getRequestChatSharePin(request), {
|
||||
clientId: getRequestClientId(request),
|
||||
});
|
||||
|
||||
if (managedContext.managedResource) {
|
||||
await recordSharedResourceTokenUsage(managedContext.managedResource.token.id, {
|
||||
void recordSharedResourceTokenUsage(managedContext.managedResource.token.id, {
|
||||
actorLabel: 'share-viewer',
|
||||
summary: '공유 채팅 링크를 열었습니다.',
|
||||
detail: managedContext.managedResource.token.resourceLabel,
|
||||
}).catch((error) => {
|
||||
request.log.warn(
|
||||
{
|
||||
err: error,
|
||||
managedResourceTokenId: managedContext.managedResource?.token.id,
|
||||
},
|
||||
'Failed to record shared chat view usage',
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user