antenna-openclaw-plugin 1.2.21 → 1.2.23

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.
Files changed (2) hide show
  1. package/index.ts +22 -5
  2. package/package.json +1 -1
package/index.ts CHANGED
@@ -124,24 +124,35 @@ function cronJobId(deviceA: string, deviceB: string): string {
124
124
  }
125
125
 
126
126
  /** Send a real-time notification to a user via openclaw message send */
127
- function notifyUser(
127
+ async function notifyUser(
128
128
  channel: string,
129
129
  userId: string,
130
130
  message: string,
131
131
  logger: any,
132
- ): void {
132
+ ): Promise<void> {
133
133
  const deviceId = `${channel}:${userId}`;
134
- const chatId = _channelContext.get(deviceId);
134
+ let chatId = _channelContext.get(deviceId);
135
+
136
+ // Fallback: read from DB if not in memory
137
+ if (!chatId) {
138
+ try {
139
+ const cfg = getConfig(api);
140
+ const sb = getSupabase(cfg);
141
+ const { data } = await sb.rpc("get_profile", { p_device_id: deviceId });
142
+ if (data?.last_chat_id) {
143
+ chatId = data.last_chat_id;
144
+ _channelContext.set(deviceId, chatId);
145
+ }
146
+ } catch {}
147
+ }
135
148
 
136
149
  try {
137
150
  if (chatId) {
138
- // Use message send with known chat context
139
151
  execSync(
140
152
  `openclaw message send --channel ${channel} --target ${chatId} -m ${JSON.stringify(message)}`,
141
153
  { timeout: 30_000, encoding: "utf-8" },
142
154
  );
143
155
  } else {
144
- // Fallback: try deliver
145
156
  execSync(
146
157
  `openclaw agent` +
147
158
  ` --message ${JSON.stringify(message)}` +
@@ -1412,6 +1423,12 @@ export default function register(api: any) {
1412
1423
  const deviceId = `${ch}:${senderId}`;
1413
1424
  _channelContext.set(deviceId, chatId);
1414
1425
  _knownDeviceIds.add(deviceId);
1426
+ // Persist to DB
1427
+ try {
1428
+ const cfg = getConfig(api);
1429
+ const sb = getSupabase(cfg);
1430
+ sb.rpc("upsert_profile", { p_device_id: deviceId, p_last_chat_id: chatId }).then(() => {}).catch(() => {});
1431
+ } catch {}
1415
1432
  }
1416
1433
 
1417
1434
  // --- Auto-scan on location ---
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "antenna-openclaw-plugin",
3
- "version": "1.2.21",
3
+ "version": "1.2.23",
4
4
  "description": "Antenna — agent-mediated nearby people discovery for OpenClaw",
5
5
  "openclaw": {
6
6
  "extensions": ["./index.ts"]