fix(scheduled-task): deliver verified WeChat links only after page is ready
Memind CI / Test, build, and release guards (push) Successful in 8m42s
Memind CI / Test, build, and release guards (push) Successful in 8m42s
Wait for HTML materialization before releasing delivery contracts, pass verified MindSpace URLs through proactive WeChat sends, resend on reconcile when pages land late, and report deferred customer-service delivery as unsent. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import crypto from 'node:crypto';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
|
||||
export function normalizeDeliveryRelativePath(value) {
|
||||
const path = String(value ?? '').replace(/\\/g, '/').replace(/^\/+/, '');
|
||||
@@ -65,17 +67,27 @@ export async function markPageDeliveryContractFailed({
|
||||
return Number(result?.affectedRows ?? 0) > 0;
|
||||
}
|
||||
|
||||
export function scheduledTaskPublicHtmlExists(publishDir, relativePath) {
|
||||
const workspaceRelativePath = normalizeDeliveryRelativePath(relativePath);
|
||||
if (!publishDir || !workspaceRelativePath) return false;
|
||||
return fs.existsSync(path.join(publishDir, workspaceRelativePath));
|
||||
}
|
||||
|
||||
export async function releaseMaterializedPageDeliveryContracts({
|
||||
pool,
|
||||
userId,
|
||||
relativePaths = [],
|
||||
allowPgRequired = false,
|
||||
publishDir = null,
|
||||
} = {}) {
|
||||
if (!pool || !userId) return [];
|
||||
const released = [];
|
||||
for (const rawPath of relativePaths) {
|
||||
const workspaceRelativePath = normalizeDeliveryRelativePath(rawPath);
|
||||
if (!workspaceRelativePath) continue;
|
||||
if (publishDir && !scheduledTaskPublicHtmlExists(publishDir, workspaceRelativePath)) {
|
||||
continue;
|
||||
}
|
||||
const contract = await getPageDeliveryContract({
|
||||
pool,
|
||||
userId,
|
||||
|
||||
Reference in New Issue
Block a user