fix(page-data): deliver MindSpace workspace URLs instead of /u/.../pages/ routes.
Page Data questionnaires were returning publication slugs to users; password-mode pages always fell back to /u/ routes. Prefer MindSpace paths at publish time and rewrite mistaken delivery links in WeChat and Portal chat. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+15
-2
@@ -23,7 +23,10 @@ import { createImgproxySigner } from './imgproxy-signer.mjs';
|
||||
import { isDirectChatSessionId } from './direct-chat-service.mjs';
|
||||
import { ensureGooseUserMessageMetadata } from './goose-message.mjs';
|
||||
import { filterMemoriesByQuery, resolveMemoriesWithLegacyFallback } from './memory-legacy-fallback.mjs';
|
||||
import { consumeSessionEventsUntilFinish } from './session-reply-wait.mjs';
|
||||
import {
|
||||
collectPageDataDeliveryArtifacts,
|
||||
rewritePageDataDeliveryLinks,
|
||||
} from './mindspace-page-data-finish-guard.mjs';
|
||||
import { extractAttachmentText } from './mindspace-attachment-text.mjs';
|
||||
import {
|
||||
buildCurrentTurnImageScopeNote,
|
||||
@@ -569,6 +572,15 @@ function sanitizeOwnPublicHtmlRelativePath(rawRelativePath, currentUser) {
|
||||
};
|
||||
}
|
||||
|
||||
function rewriteOwnPublicationRouteLinks(text, currentUser) {
|
||||
const owner = String(currentUser?.id ?? currentUser?.username ?? '').trim();
|
||||
if (!owner) return String(text ?? '');
|
||||
const publishDir = path.resolve(process.cwd(), PUBLISH_ROOT_DIR, owner);
|
||||
const artifacts = collectPageDataDeliveryArtifacts(publishDir);
|
||||
if (!artifacts.length) return String(text ?? '');
|
||||
return rewritePageDataDeliveryLinks(text, artifacts);
|
||||
}
|
||||
|
||||
export function sanitizePublicHtmlLinksInText(text, currentUser) {
|
||||
let next = String(text ?? '').replace(
|
||||
PUBLIC_HTML_MARKDOWN_LINK_PATTERN,
|
||||
@@ -590,10 +602,11 @@ export function sanitizePublicHtmlLinksInText(text, currentUser) {
|
||||
next = next.replace(PLAIN_HTML_URL_PATTERN, (match) => (
|
||||
sanitizeMissingMindSpacePublicHtmlUrl(match, currentUser) ?? match
|
||||
));
|
||||
return next.replace(INLINE_PUBLIC_HTML_PATH_PATTERN, (match, rawRelativePath) => {
|
||||
next = next.replace(INLINE_PUBLIC_HTML_PATH_PATTERN, (match, rawRelativePath) => {
|
||||
const result = sanitizeOwnPublicHtmlRelativePath(rawRelativePath, currentUser);
|
||||
return result ? `[${result.label}](${result.url})` : match;
|
||||
});
|
||||
return rewriteOwnPublicationRouteLinks(next, currentUser);
|
||||
}
|
||||
|
||||
export function sanitizeUserVisibleMessageText(text, currentUser) {
|
||||
|
||||
Reference in New Issue
Block a user