mirror of
https://github.com/fiatjaf/nak.git
synced 2025-12-08 16:48:51 +00:00
fs: symlink from @me to ourselves.
This commit is contained in:
@@ -18,8 +18,8 @@ type NpubDir struct {
|
|||||||
fetched atomic.Bool
|
fetched atomic.Bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateNpubDir(ctx context.Context, parent fs.InodeEmbedder, pointer nostr.ProfilePointer) *fs.Inode {
|
func CreateNpubDir(ctx context.Context, sys *sdk.System, parent fs.InodeEmbedder, pointer nostr.ProfilePointer) *fs.Inode {
|
||||||
npubdir := &NpubDir{pointer: pointer}
|
npubdir := &NpubDir{ctx: ctx, sys: sys, pointer: pointer}
|
||||||
return parent.EmbeddedInode().NewPersistentInode(
|
return parent.EmbeddedInode().NewPersistentInode(
|
||||||
ctx,
|
ctx,
|
||||||
npubdir,
|
npubdir,
|
||||||
|
|||||||
@@ -39,17 +39,32 @@ func (r *NostrRoot) OnAdd(context.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// add our contacts
|
||||||
fl := r.sys.FetchFollowList(r.ctx, r.rootPubKey)
|
fl := r.sys.FetchFollowList(r.ctx, r.rootPubKey)
|
||||||
|
|
||||||
for _, f := range fl.Items {
|
for _, f := range fl.Items {
|
||||||
h := r.NewPersistentInode(
|
pointer := nostr.ProfilePointer{PublicKey: f.Pubkey, Relays: []string{f.Relay}}
|
||||||
r.ctx,
|
|
||||||
&NpubDir{sys: r.sys, pointer: nostr.ProfilePointer{PublicKey: f.Pubkey, Relays: []string{f.Relay}}},
|
|
||||||
fs.StableAttr{Mode: syscall.S_IFDIR},
|
|
||||||
)
|
|
||||||
npub, _ := nip19.EncodePublicKey(f.Pubkey)
|
npub, _ := nip19.EncodePublicKey(f.Pubkey)
|
||||||
r.AddChild(npub, h, true)
|
r.AddChild(
|
||||||
|
npub,
|
||||||
|
CreateNpubDir(r.ctx, r.sys, r, pointer),
|
||||||
|
true,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// add ourselves
|
||||||
|
npub, _ := nip19.EncodePublicKey(r.rootPubKey)
|
||||||
|
if r.GetChild(npub) == nil {
|
||||||
|
pointer := nostr.ProfilePointer{PublicKey: r.rootPubKey}
|
||||||
|
r.AddChild(
|
||||||
|
npub,
|
||||||
|
CreateNpubDir(r.ctx, r.sys, r, pointer),
|
||||||
|
true,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// add a link to ourselves
|
||||||
|
me := r.NewPersistentInode(r.ctx, &fs.MemSymlink{Data: []byte(npub)}, fs.StableAttr{Mode: syscall.S_IFLNK})
|
||||||
|
r.AddChild("@me", me, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *NostrRoot) Lookup(ctx context.Context, name string, out *fuse.EntryOut) (*fs.Inode, syscall.Errno) {
|
func (r *NostrRoot) Lookup(ctx context.Context, name string, out *fuse.EntryOut) (*fs.Inode, syscall.Errno) {
|
||||||
@@ -66,7 +81,7 @@ func (r *NostrRoot) Lookup(ctx context.Context, name string, out *fuse.EntryOut)
|
|||||||
|
|
||||||
switch p := pointer.(type) {
|
switch p := pointer.(type) {
|
||||||
case nostr.ProfilePointer:
|
case nostr.ProfilePointer:
|
||||||
npubdir := CreateNpubDir(ctx, r, p)
|
npubdir := CreateNpubDir(ctx, r.sys, r, p)
|
||||||
return npubdir, fs.OK
|
return npubdir, fs.OK
|
||||||
case nostr.EventPointer:
|
case nostr.EventPointer:
|
||||||
eventdir, err := FetchAndCreateEventDir(ctx, r, r.sys, p)
|
eventdir, err := FetchAndCreateEventDir(ctx, r, r.sys, p)
|
||||||
|
|||||||
Reference in New Issue
Block a user