antenna-openclaw-plugin 0.3.0 → 0.3.1

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 +37 -8
  2. package/package.json +1 -1
package/index.ts CHANGED
@@ -302,31 +302,60 @@ export default function register(api: any) {
302
302
  const deviceId = deriveDeviceId(params.sender_id, params.channel);
303
303
 
304
304
  const { data: allMatches } = await supabase.rpc("get_my_matches", { p_device_id: deviceId });
305
- const myMatches = (allMatches || []).filter((m: any) => m.device_id_a === deviceId);
306
305
 
307
- if (myMatches.length === 0) {
308
- return ok({ mutual_matches: [], message: "目前没有进行中的匹配。" });
306
+ if (!allMatches?.length) {
307
+ return ok({ mutual_matches: [], incoming_accepts: [], message: "目前没有进行中的匹配。" });
309
308
  }
310
309
 
310
+ // Matches I initiated
311
+ const myMatches = allMatches.filter((m: any) => m.device_id_a === deviceId);
312
+ // Matches where someone else accepted me
313
+ const incomingMatches = allMatches.filter((m: any) => m.device_id_b === deviceId);
314
+
315
+ // --- Mutual matches (both sides accepted) ---
311
316
  const mutualMatches = [];
312
317
  for (const match of myMatches) {
313
- const reverse = (allMatches || []).find(
314
- (m: any) => m.device_id_a === match.device_id_b && m.device_id_b === deviceId
318
+ const reverse = incomingMatches.find(
319
+ (m: any) => m.device_id_a === match.device_id_b
315
320
  );
316
321
  if (reverse) {
317
322
  const { data: profile } = await supabase.rpc("get_profile", { p_device_id: match.device_id_b });
318
323
  mutualMatches.push({
324
+ device_id: match.device_id_b,
319
325
  name: profile?.display_name || "匿名", emoji: profile?.emoji || "👤",
326
+ line1: profile?.line1, line2: profile?.line2, line3: profile?.line3,
320
327
  their_contact: reverse.contact_info_a || null, you_shared: match.contact_info_a || null,
321
328
  });
322
329
  }
323
330
  }
324
331
 
325
- if (mutualMatches.length === 0) {
326
- return ok({ mutual_matches: [], message: "你接受了一些匹配,但对方还没有回应。耐心等等 ⏳" });
332
+ // --- Incoming accepts (someone accepted me but I haven't accepted them yet) ---
333
+ const incomingAccepts = [];
334
+ for (const match of incomingMatches) {
335
+ const iAccepted = myMatches.find(
336
+ (m: any) => m.device_id_b === match.device_id_a
337
+ );
338
+ if (!iAccepted) {
339
+ // They accepted me but I haven't responded
340
+ const { data: profile } = await supabase.rpc("get_profile", { p_device_id: match.device_id_a });
341
+ incomingAccepts.push({
342
+ device_id: match.device_id_a,
343
+ name: profile?.display_name || "匿名", emoji: profile?.emoji || "👤",
344
+ line1: profile?.line1, line2: profile?.line2, line3: profile?.line3,
345
+ });
346
+ }
327
347
  }
328
348
 
329
- return ok({ mutual_matches: mutualMatches });
349
+ const messages = [];
350
+ if (mutualMatches.length > 0) messages.push(`${mutualMatches.length} 个双向匹配!可以交换联系方式了`);
351
+ if (incomingAccepts.length > 0) messages.push(`${incomingAccepts.length} 个人想认识你,等你回应`);
352
+ if (messages.length === 0) messages.push("你接受了一些匹配,但对方还没有回应。耐心等等 ⏳");
353
+
354
+ return ok({
355
+ mutual_matches: mutualMatches,
356
+ incoming_accepts: incomingAccepts,
357
+ message: messages.join(";"),
358
+ });
330
359
  },
331
360
  });
332
361
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "antenna-openclaw-plugin",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Antenna — agent-mediated nearby people discovery for OpenClaw",
5
5
  "openclaw": {
6
6
  "extensions": ["./index.ts"]