diff --git a/go/chat/utils/utils.go b/go/chat/utils/utils.go index f853da548ad2..d6b6b1d5ca46 100644 --- a/go/chat/utils/utils.go +++ b/go/chat/utils/utils.go @@ -1699,16 +1699,32 @@ func AddUserToTLFName(g *globals.Context, tlfName string, vis keybase1.TLFVisibi switch membersType { case chat1.ConversationMembersType_IMPTEAMNATIVE, chat1.ConversationMembersType_IMPTEAMUPGRADE, chat1.ConversationMembersType_KBFS: + if vis == keybase1.TLFVisibility_PUBLIC { + return tlfName + } + username := g.Env.GetUsername().String() - if vis != keybase1.TLFVisibility_PUBLIC { - if len(tlfName) == 0 { - tlfName = username - } else { - tlfName += "," + username - } + if len(tlfName) == 0 { + return username } + + split1 := strings.SplitN(tlfName, " ", 2) // split off suffix + split2 := strings.Split(split1[0], "#") // split off readers + // Add the name to the writers list (assume the current user + // is a writer). + tlfName = split2[0] + "," + username + if len(split2) > 1 { + // Re-append any readers. + tlfName += "#" + split2[1] + } + if len(split1) > 1 { + // Re-append any suffix. + tlfName += " " + split1[1] + } + return tlfName + default: + return tlfName } - return tlfName } func ForceReloadUPAKsForUIDs(ctx context.Context, g *globals.Context, uids []keybase1.UID) error {