Allow relay requests through, fix positional e/a replies when mixed with q tags

This commit is contained in:
Jon Staab
2024-03-21 08:49:39 -07:00
parent 7b00e169fb
commit c6c8806b0c
3 changed files with 15 additions and 7 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "paravel",
"version": "0.5.4",
"version": "0.5.5",
"description": "Yet another toolkit for nostr",
"author": "hodlbod",
"license": "MIT",
+6 -1
View File
@@ -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
+8 -5
View File
@@ -85,15 +85,15 @@ export class Tags extends (Fluent<Tag> as OmitStatics<typeof Fluent<Tag>, '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<Tag> as OmitStatics<typeof Fluent<Tag>, '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),