diff --git a/package.json b/package.json index 9ab1861..81cf69d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "paravel", - "version": "0.5.4", + "version": "0.5.5", "description": "Yet another toolkit for nostr", "author": "hodlbod", "license": "MIT", diff --git a/src/connect/Connection.ts b/src/connect/Connection.ts index b4a539a..476dbd2 100644 --- a/src/connect/Connection.ts +++ b/src/connect/Connection.ts @@ -14,12 +14,17 @@ class SendQueue extends Queue { return false } - const [verb] = asMessage(message) + const [verb, ...extra] = asMessage(message) if (['AUTH', 'CLOSE'].includes(verb)) { return true } + // Allow relay requests through + if (verb === 'EVENT' && extra[0].kind === 28934) { + return true + } + // Only defer for auth if we're not multiplexing if (isMessage(message) && ![AuthStatus.Ok, AuthStatus.Pending].includes(this.cxn.meta.authStatus)) { return false diff --git a/src/util/Tags.ts b/src/util/Tags.ts index 5d164e7..90f68e0 100644 --- a/src/util/Tags.ts +++ b/src/util/Tags.ts @@ -85,15 +85,15 @@ export class Tags extends (Fluent as OmitStatics, 'from' ancestors = () => { const tags = this.filter(t => ["a", "e", "q"].includes(t.key()) && !t.isContext()) + const parentTags = tags.filter(t => ["a", "e"].includes(t.key())) + const mentionTags = tags.whereKey("q") const roots: string[][] = [] const replies: string[][] = [] const mentions: string[][] = [] - tags + parentTags .forEach((t: Tag, i: number) => { - if (t.key() === "q") { - mentions.push(t.valueOf()) - } else if (t.mark() === 'root') { + if (t.mark() === 'root') { roots.push(t.valueOf()) } else if (t.mark() === 'reply') { replies.push(t.valueOf()) @@ -101,13 +101,16 @@ export class Tags extends (Fluent as OmitStatics, 'from' mentions.push(t.valueOf()) } else if (i === 0) { roots.push(t.valueOf()) - } else if (i === tags.count() - 1) { + } else if (i === parentTags.count() - 1) { replies.push(t.valueOf()) } else { mentions.push(t.valueOf()) } }) + // Add quotes as mentions separately so positional logic above works + mentionTags.forEach((t: Tag) => mentions.push(t.valueOf())) + return { roots: Tags.from(roots), replies: Tags.from(replies),