feat(core): add process facts to ordered account notifications (#539)
* feat(core): carry hook process status in notifications `offline` alone cannot tell an external supervisor whether the QQ session dropped (log back in) or the process is gone (restart the client). Resolve the hook process behind a UIN at notify time and expose `status`, `pid` and `error` as template variables; a failing lookup degrades to empty values so delivery is never blocked. The default webhook/email templates gain a process-status line; existing channels keep their stored template untouched. * fix(core): preserve notification lifecycle ordering and simplify state --------- Co-authored-by: zhngzhu <[email protected]> Co-authored-by: 手瓜一十雪 <[email protected]>
This commit is contained in:
19 files changed
+616
-387
No files matched your search
@@ -3,10 +3,12 @@ import fs from 'fs';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
import {
|
||||
DEFAULT_BODY_TEMPLATE,
|
||||
DEFAULT_WEBHOOK_BODY,
|
||||
DEFAULT_EMAIL_BODY,
|
||||
DEFAULT_EMAIL_SUBJECT,
|
||||
} from '@snowluma/common/notification-templates';
|
||||
import {
|
||||
DEFAULT_DEBOUNCE_SECONDS,
|
||||
DEFAULT_EMAIL_BODY_TEMPLATE,
|
||||
DEFAULT_SUBJECT_TEMPLATE,
|
||||
defaultNotificationsConfig,
|
||||
normalizeNotificationsConfig,
|
||||
renderTemplate,
|
||||
@@ -145,7 +147,7 @@ describe('normalizeNotificationsConfig — total normalize', () => {
|
||||
expect(channels[0].enabled).toBe(true);
|
||||
expect(channels[0].name).toBe('c1');
|
||||
expect(channels[0].type).toBe('webhook');
|
||||
expect(channels[0].bodyTemplate).toBe(DEFAULT_BODY_TEMPLATE);
|
||||
expect(channels[0].bodyTemplate).toBe(DEFAULT_WEBHOOK_BODY);
|
||||
expect(channels[0].headers).toBeUndefined();
|
||||
});
|
||||
|
||||
@@ -198,14 +200,14 @@ describe('normalizeNotificationsConfig — total normalize', () => {
|
||||
name: 'ops-mail',
|
||||
type: 'email',
|
||||
url: '',
|
||||
bodyTemplate: DEFAULT_EMAIL_BODY_TEMPLATE,
|
||||
bodyTemplate: DEFAULT_EMAIL_BODY,
|
||||
enabled: true,
|
||||
smtpHost: 'smtp.qq.com',
|
||||
smtpPort: 465,
|
||||
smtpSecure: true,
|
||||
from: 'SnowLuma <[email protected]>',
|
||||
to: '[email protected], [email protected]',
|
||||
subjectTemplate: DEFAULT_SUBJECT_TEMPLATE,
|
||||
subjectTemplate: DEFAULT_EMAIL_SUBJECT,
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user