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 {
4949
5050 // scope topic to user by prefixing name.
5151 func toTopic(userName, topic string) string {
52+ if strings.HasPrefix(topic, userName+"/") {
53+ return topic
54+ }
5255 return fmt.Sprintf("%s/%s", userName, topic)
5356 }
5457
5558 func toPublicTopic(topic string) string {
59+ if strings.HasPrefix(topic, "public/") {
60+ return topic
61+ }
5662 return fmt.Sprintf("public/%s", topic)
5763 }
5864
......@@ -403,12 +409,17 @@ func Middleware(handler *CliHandler) pssh.SSHServerMiddleware {
403409 }
404410
405411 if !*clean {
412+ fmtTopic := topic
413+ if *access != "" {
414+ fmtTopic = fmt.Sprintf("%s/%s", userName, topic)
415+ }
416+
406417 _, _ = fmt.Fprintf(
407418 sesh,
408419 "subscribe to this channel:\n ssh %s sub %s%s\n",
409420 toSshCmd(handler.Cfg),
410421 msgFlag,
411- topic,
422+ fmtTopic,
412423 )
413424 }
414425
......@@ -684,12 +695,17 @@ func Middleware(handler *CliHandler) pssh.SSHServerMiddleware {
684695 }
685696
686697 if isCreator && !*clean {
698+ fmtTopic := topic
699+ if *access != "" {
700+ fmtTopic = fmt.Sprintf("%s/%s", userName, topic)
701+ }
702+
687703 _, _ = fmt.Fprintf(
688704 sesh,
689705 "subscribe to this topic:\n ssh %s sub %s%s\n",
690706 toSshCmd(handler.Cfg),
691707 flagMsg,
692- topic,
708+ fmtTopic,
693709 )
694710 }
695711