Allow relay requests through, fix positional e/a replies when mixed with q tags
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "paravel",
|
"name": "paravel",
|
||||||
"version": "0.5.4",
|
"version": "0.5.5",
|
||||||
"description": "Yet another toolkit for nostr",
|
"description": "Yet another toolkit for nostr",
|
||||||
"author": "hodlbod",
|
"author": "hodlbod",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|||||||
@@ -14,12 +14,17 @@ class SendQueue extends Queue {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
const [verb] = asMessage(message)
|
const [verb, ...extra] = asMessage(message)
|
||||||
|
|
||||||
if (['AUTH', 'CLOSE'].includes(verb)) {
|
if (['AUTH', 'CLOSE'].includes(verb)) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Allow relay requests through
|
||||||
|
if (verb === 'EVENT' && extra[0].kind === 28934) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
// Only defer for auth if we're not multiplexing
|
// Only defer for auth if we're not multiplexing
|
||||||
if (isMessage(message) && ![AuthStatus.Ok, AuthStatus.Pending].includes(this.cxn.meta.authStatus)) {
|
if (isMessage(message) && ![AuthStatus.Ok, AuthStatus.Pending].includes(this.cxn.meta.authStatus)) {
|
||||||
return false
|
return false
|
||||||
|
|||||||
+8
-5
@@ -85,15 +85,15 @@ export class Tags extends (Fluent<Tag> as OmitStatics<typeof Fluent<Tag>, 'from'
|
|||||||
|
|
||||||
ancestors = () => {
|
ancestors = () => {
|
||||||
const tags = this.filter(t => ["a", "e", "q"].includes(t.key()) && !t.isContext())
|
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 roots: string[][] = []
|
||||||
const replies: string[][] = []
|
const replies: string[][] = []
|
||||||
const mentions: string[][] = []
|
const mentions: string[][] = []
|
||||||
|
|
||||||
tags
|
parentTags
|
||||||
.forEach((t: Tag, i: number) => {
|
.forEach((t: Tag, i: number) => {
|
||||||
if (t.key() === "q") {
|
if (t.mark() === 'root') {
|
||||||
mentions.push(t.valueOf())
|
|
||||||
} else if (t.mark() === 'root') {
|
|
||||||
roots.push(t.valueOf())
|
roots.push(t.valueOf())
|
||||||
} else if (t.mark() === 'reply') {
|
} else if (t.mark() === 'reply') {
|
||||||
replies.push(t.valueOf())
|
replies.push(t.valueOf())
|
||||||
@@ -101,13 +101,16 @@ export class Tags extends (Fluent<Tag> as OmitStatics<typeof Fluent<Tag>, 'from'
|
|||||||
mentions.push(t.valueOf())
|
mentions.push(t.valueOf())
|
||||||
} else if (i === 0) {
|
} else if (i === 0) {
|
||||||
roots.push(t.valueOf())
|
roots.push(t.valueOf())
|
||||||
} else if (i === tags.count() - 1) {
|
} else if (i === parentTags.count() - 1) {
|
||||||
replies.push(t.valueOf())
|
replies.push(t.valueOf())
|
||||||
} else {
|
} else {
|
||||||
mentions.push(t.valueOf())
|
mentions.push(t.valueOf())
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Add quotes as mentions separately so positional logic above works
|
||||||
|
mentionTags.forEach((t: Tag) => mentions.push(t.valueOf()))
|
||||||
|
|
||||||
return {
|
return {
|
||||||
roots: Tags.from(roots),
|
roots: Tags.from(roots),
|
||||||
replies: Tags.from(replies),
|
replies: Tags.from(replies),
|
||||||
|
|||||||
Reference in New Issue
Block a user