@aight-cool/aight-utils 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/src/push-hook.ts +10 -10
- package/src/push.ts +2 -0
package/openclaw.plugin.json
CHANGED
package/package.json
CHANGED
package/src/push-hook.ts
CHANGED
|
@@ -62,31 +62,31 @@ export function registerPushHook(api: OpenClawPluginApi) {
|
|
|
62
62
|
const agent = agents.find((a: any) => a.id === agentId);
|
|
63
63
|
const displayName = agent?.name ?? agent?.identity?.name ?? agentId;
|
|
64
64
|
|
|
65
|
-
// Resolve group chat name for push
|
|
65
|
+
// Resolve group chat name for push subtitle (WhatsApp-style layout)
|
|
66
66
|
let pushTitle = displayName;
|
|
67
|
+
let pushSubtitle: string | undefined;
|
|
67
68
|
const sessionKey = ctx.sessionKey ?? "";
|
|
68
69
|
if (sessionKey.includes(":group-chat:")) {
|
|
69
70
|
const groupId = sessionKey.split(":group-chat:")[1];
|
|
70
71
|
if (groupId) {
|
|
71
|
-
// Look up friendly name from plugin data store
|
|
72
72
|
const groupName = loadGroupName(api, groupId);
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
pushTitle = groupName
|
|
77
|
-
? `${displayName} — ${groupName}`
|
|
78
|
-
: displayName;
|
|
73
|
+
if (groupName) {
|
|
74
|
+
pushSubtitle = groupName;
|
|
75
|
+
}
|
|
79
76
|
}
|
|
80
77
|
}
|
|
81
78
|
|
|
79
|
+
const cleanBody = preview.trim().replace(/\n+/g, " ").trim();
|
|
80
|
+
|
|
82
81
|
for (const device of tokens) {
|
|
83
82
|
if (!device.sendKey) continue;
|
|
84
83
|
try {
|
|
85
84
|
await sendPush(
|
|
86
85
|
device.deviceId,
|
|
87
86
|
{
|
|
88
|
-
title: pushTitle,
|
|
89
|
-
|
|
87
|
+
title: pushTitle.trim(),
|
|
88
|
+
subtitle: pushSubtitle,
|
|
89
|
+
body: cleanBody,
|
|
90
90
|
data: { sessionKey: ctx.sessionKey, agentId },
|
|
91
91
|
},
|
|
92
92
|
freshConfig,
|
package/src/push.ts
CHANGED
|
@@ -87,6 +87,7 @@ async function obtainSendKey(relayUrl: string, pushToken: string): Promise<strin
|
|
|
87
87
|
|
|
88
88
|
export interface PushPayload {
|
|
89
89
|
title?: string;
|
|
90
|
+
subtitle?: string;
|
|
90
91
|
body?: string;
|
|
91
92
|
data?: Record<string, unknown>;
|
|
92
93
|
silent?: boolean;
|
|
@@ -118,6 +119,7 @@ export async function sendPush(
|
|
|
118
119
|
|
|
119
120
|
if (mode === "rich" && !payload.silent) {
|
|
120
121
|
pushBody.title = payload.title;
|
|
122
|
+
if (payload.subtitle) pushBody.subtitle = payload.subtitle;
|
|
121
123
|
pushBody.body = payload.body;
|
|
122
124
|
}
|
|
123
125
|
|