Improve WeChat MP replies and ship MindSpace/H5 production updates.

Add WeChat service account routing with sync acks, connectivity tests, and context isolation; document deploy runbooks; and bundle related MindSpace, voice, Plaza, and server gateway changes for production rollout.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
john
2026-06-19 23:06:43 +08:00
parent b0f5d6a51c
commit 229805a070
241 changed files with 13190 additions and 902 deletions
+39 -4
View File
@@ -32,7 +32,10 @@ function clampLimit(value, fallback = 20, max = 50) {
}
function normalizeSort(value) {
return String(value ?? 'hot') === 'new' ? 'new' : 'hot';
const raw = String(value ?? 'recommend').trim().toLowerCase();
if (raw === 'new') return 'new';
if (raw === 'hot') return 'hot';
return 'recommend';
}
function formatStats(row) {
@@ -45,6 +48,23 @@ function formatStats(row) {
};
}
const FRESH_POST_WINDOW_MS = 24 * 60 * 60 * 1000;
function promoteFreshPosts(items, now = Date.now()) {
const fresh = [];
const stable = [];
for (const post of items) {
const publishedAt = Date.parse(post.published_at);
if (Number.isFinite(publishedAt) && now - publishedAt <= FRESH_POST_WINDOW_MS) {
fresh.push(post);
} else {
stable.push(post);
}
}
fresh.sort((a, b) => Date.parse(b.published_at) - Date.parse(a.published_at));
return [...fresh, ...stable];
}
function formatPostRow(row, { category, viewerReacted = null, publicationUrl = null } = {}) {
return {
id: row.id,
@@ -88,6 +108,7 @@ export function createPlazaPostService(
algorithmConfig = null,
onPostPublished = null,
loadFeaturedPosts = null,
recommendService = null,
} = {},
) {
const autoApprove = String(process.env.PLAZA_AUTO_APPROVE ?? '').toLowerCase() === 'true';
@@ -358,17 +379,28 @@ export function createPlazaPostService(
};
const listFeed = async ({
sort = 'hot',
sort = 'recommend',
categorySlug = null,
cursor = null,
limit = 20,
viewerId = null,
sessionId = null,
} = {}) => {
await ensureCategories();
const normalizedSort = normalizeSort(sort);
const pageLimit = clampLimit(limit);
if (!cursor && plazaRedis?.getFeedCache) {
if (normalizedSort === 'recommend' && recommendService) {
return recommendService.listRecommendedFeed({
viewerId,
sessionId,
categorySlug,
cursor,
limit: pageLimit,
});
}
if (!cursor && normalizedSort !== 'recommend' && plazaRedis?.getFeedCache) {
const cached = await plazaRedis.getFeedCache(normalizedSort, categorySlug, null);
if (cached?.posts) {
if (viewerId && loadViewerReactions) {
@@ -471,6 +503,9 @@ export function createPlazaPostService(
pageLimit,
);
}
if (!cursor && normalizedSort === 'hot') {
mergedPosts = promoteFreshPosts(mergedPosts).slice(0, pageLimit);
}
const result = {
posts: mergedPosts,
@@ -486,7 +521,7 @@ export function createPlazaPostService(
categorySlug,
null,
{
posts: pageRows.map((row) => formatPostRow(row)),
posts: mergedPosts,
featured: result.featured,
next_cursor: result.next_cursor,
has_more: result.has_more,