Skip to content

Commit 7f797f8

Browse files
committed
better dm experience, /commands in dms, nostr dm :domain to show the list of users on that domain
1 parent 9360870 commit 7f797f8

9 files changed

Lines changed: 826 additions & 192 deletions

File tree

cmd/dm.go

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package cmd
33
import (
44
"context"
55
"encoding/json"
6+
"errors"
67
"fmt"
78
"io"
89
"net/http"
@@ -283,7 +284,7 @@ func runDM(cmd *cobra.Command, args []string) error {
283284
if len(args) == 0 {
284285
// Interactive mode: show conversation picker if terminal
285286
if term.IsTerminal(int(os.Stdin.Fd())) {
286-
return runDMPicker(npub)
287+
return runDMPicker(npub, "")
287288
}
288289
return showDMAliases(npub)
289290
}
@@ -292,29 +293,38 @@ func runDM(cmd *cobra.Command, args []string) error {
292293
var targetHex string
293294
if isDomainArg(args[0]) {
294295
domain := args[0]
296+
// If no further args, show picker with domain users merged in
297+
if len(args) == 1 && !dmWatchFlag && term.IsTerminal(int(os.Stdin.Fd())) {
298+
return runDMPicker(npub, domain)
299+
}
300+
// One-shot or watch mode with domain: resolve to a single user
295301
names, err := fetchDomainNostrJSON(domain)
296302
if err != nil {
297-
// Show our custom error for domain fetch failures
298303
return showDomainError(domain)
299304
}
300-
301-
// Domain nostr.json found - handle based on number of users
302305
if len(names) == 0 {
303306
return fmt.Errorf("domain %s has a nostr.json but no users in 'names'", domain)
304307
} else if len(names) == 1 {
305-
// Single user - resolve directly
306-
for _, hex := range names {
308+
for name, hex := range names {
307309
targetHex = hex
310+
// Replace bare domain arg with full NIP-05 for display
311+
args[0] = fmt.Sprintf("%s@%s", name, domain)
308312
break
309313
}
310314
} else {
311-
// Multiple users - show picker
312315
targetHex, err = runDomainUserPicker(domain, names)
313316
if err != nil {
314317
return err
315318
}
316319
if targetHex == "" {
317-
return nil // User cancelled
320+
return nil
321+
}
322+
// Find the selected user's name for display
323+
for name, hex := range names {
324+
if hex == targetHex {
325+
args[0] = fmt.Sprintf("%s@%s", name, domain)
326+
break
327+
}
318328
}
319329
}
320330
} else {
@@ -369,7 +379,11 @@ func runDM(cmd *cobra.Command, args []string) error {
369379
}
370380

371381
// Interactive mode
372-
return interactiveDM(npub, skHex, myHex, targetHex, args[0], relays)
382+
err = interactiveDM(npub, skHex, myHex, targetHex, args[0], relays)
383+
if errors.Is(err, errBackToPicker) {
384+
return nil // no picker to return to in direct mode
385+
}
386+
return err
373387
}
374388

375389
func sendDM(npub, skHex, myHex, targetHex, message string, relays []string) error {

0 commit comments

Comments
 (0)