feat(notifications): default body template → Server酱 JSON (title/desp) (#108)

- Change DEFAULT_BODY_TEMPLATE from plaintext to Server酱-style JSON
- Add JSON-safe escaping in renderTemplate for backslashes and quotes
- Update frontend DEFAULT_TEMPLATE to match backend
- Add tests for JSON escaping behavior

Fixes #106 (targets dev branch)
This commit is contained in:
渡辺鳩P authored and GitHub committed 2026-06-18 16:10:09 +08:00
1 parent c637329884
commit 06c8954881
3 files changed
+36 -7

No files matched your search

@@ -47,6 +47,15 @@ describe('renderTemplate — mechanical {key} substitution', () => {
// to a recursive/loop replace would break this while passing every other test.
expect(renderTemplate('{a}', { a: '{b}', b: 'NESTED' })).toBe('{b}');
});
it('escapes backslashes and quotes when template is JSON-like', () => {
const tmpl = '{"text": "{val}"}';
expect(renderTemplate(tmpl, { val: 'a"b\\c' })).toBe('{"text": "a\\"b\\\\c"}');
});
it('does NOT escape when template is plain text', () => {
expect(renderTemplate('{val}', { val: 'a"b\\c' })).toBe('a"b\\c');
});
});
describe('normalizeNotificationsConfig — total normalize', () => {