github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/chat/commands/hide.go (about) 1 package commands 2 3 import ( 4 "context" 5 6 "github.com/keybase/client/go/chat/globals" 7 "github.com/keybase/client/go/protocol/chat1" 8 "github.com/keybase/client/go/protocol/gregor1" 9 ) 10 11 type Hide struct { 12 *baseCommand 13 } 14 15 func NewHide(g *globals.Context) *Hide { 16 return &Hide{ 17 baseCommand: newBaseCommand(g, "hide", "[conversation]", 18 "Hides [conversation] or the current one", false), 19 } 20 } 21 22 func (h *Hide) Execute(ctx context.Context, uid gregor1.UID, inConvID chat1.ConversationID, 23 tlfName, text string, replyTo *chat1.MessageID) (err error) { 24 defer h.Trace(ctx, &err, "Execute")() 25 if !h.Match(ctx, text) { 26 return ErrInvalidCommand 27 } 28 var convID chat1.ConversationID 29 toks, err := h.tokenize(text, 1) 30 if err != nil { 31 return err 32 } 33 if len(toks) == 1 { 34 convID = inConvID 35 } else if len(toks) == 2 { 36 conv, err := getConvByName(ctx, h.G(), uid, toks[1]) 37 if err != nil { 38 return err 39 } 40 convID = conv.GetConvID() 41 } else { 42 return ErrInvalidArguments 43 } 44 if err = h.G().InboxSource.RemoteSetConversationStatus(ctx, uid, convID, 45 chat1.ConversationStatus_IGNORED); err != nil { 46 return err 47 } 48 return nil 49 }