Commit 6be2726
Eric Bower
·
2025-11-28 13:00:24 -0500 EST
parent 72f6af9
fix(pipe): to topic fns should handle if user already incldued
1 files changed,
+18,
-2
+18,
-2
| ... | ... | @@ -49,10 +49,16 @@ func NewTabWriter(out io.Writer) *tabwriter.Writer { | |
| 49 | 49 | ||
| 50 | 50 | // scope topic to user by prefixing name. | |
| 51 | 51 | func toTopic(userName, topic string) string { | |
| 52 | + | if strings.HasPrefix(topic, userName+"/") { | |
| 53 | + | return topic | |
| 54 | + | } | |
| 52 | 55 | return fmt.Sprintf("%s/%s", userName, topic) | |
| 53 | 56 | } | |
| 54 | 57 | ||
| 55 | 58 | func toPublicTopic(topic string) string { | |
| 59 | + | if strings.HasPrefix(topic, "public/") { | |
| 60 | + | return topic | |
| 61 | + | } | |
| 56 | 62 | return fmt.Sprintf("public/%s", topic) | |
| 57 | 63 | } | |
| 58 | 64 |
| ... | ... | @@ -403,12 +409,17 @@ func Middleware(handler *CliHandler) pssh.SSHServerMiddleware { | |
| 403 | 409 | } | |
| 404 | 410 | ||
| 405 | 411 | if !*clean { | |
| 412 | + | fmtTopic := topic | |
| 413 | + | if *access != "" { | |
| 414 | + | fmtTopic = fmt.Sprintf("%s/%s", userName, topic) | |
| 415 | + | } | |
| 416 | + | ||
| 406 | 417 | _, _ = fmt.Fprintf( | |
| 407 | 418 | sesh, | |
| 408 | 419 | "subscribe to this channel:\n ssh %s sub %s%s\n", | |
| 409 | 420 | toSshCmd(handler.Cfg), | |
| 410 | 421 | msgFlag, | |
| 411 | - | topic, | |
| 422 | + | fmtTopic, | |
| 412 | 423 | ) | |
| 413 | 424 | } | |
| 414 | 425 |
| ... | ... | @@ -684,12 +695,17 @@ func Middleware(handler *CliHandler) pssh.SSHServerMiddleware { | |
| 684 | 695 | } | |
| 685 | 696 | ||
| 686 | 697 | if isCreator && !*clean { | |
| 698 | + | fmtTopic := topic | |
| 699 | + | if *access != "" { | |
| 700 | + | fmtTopic = fmt.Sprintf("%s/%s", userName, topic) | |
| 701 | + | } | |
| 702 | + | ||
| 687 | 703 | _, _ = fmt.Fprintf( | |
| 688 | 704 | sesh, | |
| 689 | 705 | "subscribe to this topic:\n ssh %s sub %s%s\n", | |
| 690 | 706 | toSshCmd(handler.Cfg), | |
| 691 | 707 | flagMsg, | |
| 692 | - | topic, | |
| 708 | + | fmtTopic, | |
| 693 | 709 | ) | |
| 694 | 710 | } | |
| 695 | 711 |