Add smart ACK provider for WeChat MP replies

Replace fixed ackText with a rule-based AckProvider that picks
response templates by message type and intent (translate, summary,
rewrite, poster, ppt, mindmap, code, search, schedule). Pure sync,
zero I/O, auto-falls back to config.ackText on any error.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
john
2026-06-26 15:19:03 +08:00
parent 9ed4fd48d7
commit 9b4a25799f
162 changed files with 17276 additions and 2054 deletions
+20
View File
@@ -1,6 +1,7 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import {
allowPlazaEmbedFrame,
appendPlazaEmbedQuery,
injectPlazaEmbedBootstrap,
isPlazaEmbedRequest,
@@ -37,6 +38,16 @@ test('publishedPageCspForEmbed allows inline script', () => {
assert.match(publishedPageCspForEmbed(true), /script-src 'unsafe-inline'/);
});
test('allowPlazaEmbedFrame removes legacy X-Frame-Options header', () => {
let removed = null;
allowPlazaEmbedFrame({
removeHeader(name) {
removed = name;
},
});
assert.equal(removed, 'X-Frame-Options');
});
test('stripPublicationHtmlCspMeta removes inline CSP meta tags', () => {
const html =
'<html><head><meta http-equiv="Content-Security-Policy" content="script-src \'none\'"></head><body></body></html>';
@@ -52,4 +63,13 @@ test('preparePublicationHtmlForEmbed strips CSP and injects bootstrap', () => {
assert.doesNotMatch(out, /http-equiv="Content-Security-Policy"/);
assert.match(out, /plaza-embed-bootstrap/);
assert.match(out, /plaza-embed-overrides/);
assert.match(out, /\.hero\{height:auto!important;min-height:0!important/);
});
test('embed bootstrap does not cap tall publication height', () => {
const html = '<!doctype html><html><body><main style="height:24000px">Tall</main></body></html>';
const out = preparePublicationHtmlForEmbed(html);
assert.doesNotMatch(out, /Math\.min\(measured,\s*16000\)/);
assert.match(out, /body\.children\.length/);
assert.match(out, /MutationObserver/);
});