@unicitylabs/openclaw-unicity 0.3.1 → 0.3.2
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/package.json +1 -1
- package/src/channel.ts +9 -2
package/package.json
CHANGED
package/src/channel.ts
CHANGED
|
@@ -13,6 +13,7 @@ const DEFAULT_ACCOUNT_ID = "default";
|
|
|
13
13
|
/** How long (ms) to wait after the last group message before declaring backfill complete. */
|
|
14
14
|
export const GROUP_BACKFILL_DEBOUNCE_MS = 3_000;
|
|
15
15
|
|
|
16
|
+
|
|
16
17
|
interface GroupBackfillState {
|
|
17
18
|
phase: "buffering" | "live";
|
|
18
19
|
latestMsg: {
|
|
@@ -508,14 +509,20 @@ export const unicityChannelPlugin = {
|
|
|
508
509
|
});
|
|
509
510
|
}
|
|
510
511
|
|
|
512
|
+
// Nostr pubkey for self-message detection. Group messages use the 32-byte
|
|
513
|
+
// x-only Nostr pubkey (event.pubkey), NOT the 33-byte compressed chainPubkey.
|
|
514
|
+
// sphere.groupChat.getMyPublicKey() returns the correct Nostr-format key.
|
|
515
|
+
const myNostrPubkey = sphere.groupChat?.getMyPublicKey?.() ?? null;
|
|
516
|
+
|
|
511
517
|
// Per-group backfill state: buffer messages during the initial burst, then
|
|
512
518
|
// switch to live dispatch once the burst settles.
|
|
513
519
|
const groupBackfillStates = new Map<string, GroupBackfillState>();
|
|
514
520
|
|
|
515
521
|
// Subscribe to incoming group messages
|
|
516
522
|
const unsubGroupMessage = sphere.groupChat?.onMessage?.((msg: GroupMsg) => {
|
|
517
|
-
// Skip messages from self
|
|
518
|
-
|
|
523
|
+
// Skip messages from self (echoed back by the relay).
|
|
524
|
+
// Compare against the Nostr x-only pubkey, not chainPubkey.
|
|
525
|
+
if (myNostrPubkey && msg.senderPubkey === myNostrPubkey) return;
|
|
519
526
|
|
|
520
527
|
// Lookup or create per-group backfill state
|
|
521
528
|
let state = groupBackfillStates.get(msg.groupId);
|