mirror of https://github.com/fiatjaf/nak.git
fs: use sdk/PrepareNoteEvent() when publishing.
This commit is contained in:
parent
f9033f778d
commit
83195d9a00
|
@ -2,15 +2,12 @@ package nostrfs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"slices"
|
|
||||||
"strings"
|
"strings"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"fiatjaf.com/lib/debouncer"
|
"fiatjaf.com/lib/debouncer"
|
||||||
"fiatjaf.com/nostr"
|
"fiatjaf.com/nostr"
|
||||||
"fiatjaf.com/nostr/nip27"
|
|
||||||
"fiatjaf.com/nostr/nip73"
|
|
||||||
"github.com/fatih/color"
|
"github.com/fatih/color"
|
||||||
"github.com/hanwen/go-fuse/v2/fs"
|
"github.com/hanwen/go-fuse/v2/fs"
|
||||||
"github.com/hanwen/go-fuse/v2/fuse"
|
"github.com/hanwen/go-fuse/v2/fuse"
|
||||||
|
@ -147,36 +144,9 @@ func (n *ViewDir) publishNote() {
|
||||||
relays = n.root.sys.FetchOutboxRelays(n.root.ctx, n.root.rootPubKey, 6)
|
relays = n.root.sys.FetchOutboxRelays(n.root.ctx, n.root.rootPubKey, 6)
|
||||||
}
|
}
|
||||||
|
|
||||||
// add "p" tags from people mentioned and "q" tags from events mentioned
|
// massage and extract tags from raw text
|
||||||
for ref := range nip27.Parse(evt.Content) {
|
targetRelays := n.root.sys.PrepareNoteEvent(n.root.ctx, &evt)
|
||||||
if _, isExternal := ref.Pointer.(nip73.ExternalPointer); isExternal {
|
relays = nostr.AppendUnique(relays, targetRelays...)
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
tag := ref.Pointer.AsTag()
|
|
||||||
key := tag[0]
|
|
||||||
val := tag[1]
|
|
||||||
if key == "e" || key == "a" {
|
|
||||||
key = "q"
|
|
||||||
}
|
|
||||||
if existing := evt.Tags.FindWithValue(key, val); existing == nil {
|
|
||||||
evt.Tags = append(evt.Tags, tag)
|
|
||||||
|
|
||||||
// add their "read" relays
|
|
||||||
if key == "p" {
|
|
||||||
pk, err := nostr.PubKeyFromHex(val)
|
|
||||||
if err != nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, r := range n.root.sys.FetchInboxRelays(n.root.ctx, pk, 4) {
|
|
||||||
if !slices.Contains(relays, r) {
|
|
||||||
relays = append(relays, r)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// sign and publish
|
// sign and publish
|
||||||
if err := n.root.signer.SignEvent(n.root.ctx, &evt); err != nil {
|
if err := n.root.signer.SignEvent(n.root.ctx, &evt); err != nil {
|
||||||
|
|
Loading…
Reference in New Issue