mindspace: close authority boundaries
This commit is contained in:
@@ -8,6 +8,9 @@ export function isStubPublicHtmlContent(content) {
|
||||
}
|
||||
|
||||
export function artifactFileExists(artifact) {
|
||||
if (typeof artifact?.exists === 'boolean') {
|
||||
return artifact.exists;
|
||||
}
|
||||
const localPath = String(artifact?.localPath ?? '').trim();
|
||||
if (!localPath) return false;
|
||||
try {
|
||||
@@ -18,6 +21,9 @@ export function artifactFileExists(artifact) {
|
||||
}
|
||||
|
||||
export function isStubPublicHtmlArtifact(artifact) {
|
||||
if (typeof artifact?.isStub === 'boolean') {
|
||||
return artifact.isStub;
|
||||
}
|
||||
const localPath = String(artifact?.localPath ?? '').trim();
|
||||
if (!localPath) return false;
|
||||
try {
|
||||
@@ -44,6 +50,24 @@ export function verifyPageArtifactContent(artifact, { minBytes = 512 } = {}) {
|
||||
if (isStubPublicHtmlArtifact(artifact)) {
|
||||
return { ok: false, reason: 'stub_placeholder' };
|
||||
}
|
||||
if (!String(artifact?.localPath ?? '').trim()) {
|
||||
if (
|
||||
Number(artifact?.sizeBytes ?? 0) <
|
||||
minBytes
|
||||
) {
|
||||
return {
|
||||
ok: false,
|
||||
reason: 'too_small',
|
||||
};
|
||||
}
|
||||
if (artifact?.isHtmlDocument !== true) {
|
||||
return {
|
||||
ok: false,
|
||||
reason: 'not_html_document',
|
||||
};
|
||||
}
|
||||
return { ok: true, reason: null };
|
||||
}
|
||||
const size = fs.statSync(artifact.localPath).size;
|
||||
if (size < minBytes) {
|
||||
return { ok: false, reason: 'too_small' };
|
||||
|
||||
@@ -61,6 +61,18 @@ export function verifyArtifactSharePreview(artifact) {
|
||||
if (!artifactFileExists(artifact)) {
|
||||
return { ok: false, reason: 'missing_file' };
|
||||
}
|
||||
if (!String(artifact?.localPath ?? '').trim()) {
|
||||
if (
|
||||
typeof artifact?.sharePreview?.ok ===
|
||||
'boolean'
|
||||
) {
|
||||
return artifact.sharePreview;
|
||||
}
|
||||
return {
|
||||
ok: false,
|
||||
reason: 'missing_share_preview_evaluation',
|
||||
};
|
||||
}
|
||||
const content = fs.readFileSync(artifact.localPath, 'utf8');
|
||||
return verifySharePreviewMeta(content);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user