Merge branch 'feature/social-post'
This commit is contained in:
commit
46171b4f24
55 files changed
+2872
-7
No files matched your search
@@ -131,6 +131,21 @@ export function sanitizePayloadForPublish(payload: SitePayload): SitePayload {
|
||||
// 대체 텍스트 없는 이미지는 어차피 렌더하지 않는다 — 목록에서도 뺀다.
|
||||
media: payload.media.filter((item) => item.alt?.trim()),
|
||||
// 재생 주소가 없는 곡은 버튼만 있고 소리가 없다. 목록에서 뺀다.
|
||||
// 생성 결과를 고유 콘텐츠로 세면 우리 출력으로 발행 게이트를 우회하게 된다.
|
||||
// 명시적 허용 필드만 복사해 승인 토큰이 하이드레이션 블롭에 끼어들지 못하게 한다.
|
||||
socialPosts: (payload.socialPosts ?? []).filter((post) => post.body?.trim() && Number.isFinite(Date.parse(post.postedAt))).slice(0, 3).map((post) => ({
|
||||
postId: post.postId, provider: post.provider, body: post.body, postedAt: post.postedAt,
|
||||
permalink: safeSocialPermalink(post.permalink),
|
||||
})),
|
||||
songs: (payload.songs ?? []).filter((song) => song.audioUrl?.trim()),
|
||||
};
|
||||
}
|
||||
|
||||
function safeSocialPermalink(value?: string | null): string | undefined {
|
||||
if (!value) return undefined;
|
||||
try {
|
||||
const url = new URL(value);
|
||||
if (url.protocol === 'https:' && ['threads.net', 'www.threads.net', 'threads.com', 'www.threads.com'].includes(url.hostname) && !url.username && !url.password) return url.href;
|
||||
} catch { /* 손으로 만든 payload도 공개 링크 경계를 지켜야 한다. */ }
|
||||
return undefined;
|
||||
}
|
||||
Reference in new issue
Block a user