From 1295ddd69a9c6a52c059cd097096fc2e7bd69946 Mon Sep 17 00:00:00 2001 From: rissrice2105-agent Date: Mon, 15 Jun 2026 14:58:23 -0600 Subject: [PATCH] fix(mailbox): honor uppercase flag bot command --- internal/mailbox/bot.go | 5 +++-- internal/mailbox/mailbox_test.go | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/internal/mailbox/bot.go b/internal/mailbox/bot.go index db12c52..69dda72 100644 --- a/internal/mailbox/bot.go +++ b/internal/mailbox/bot.go @@ -38,7 +38,8 @@ func RunBot(ctx context.Context, c *Client, args []string, in io.Reader, out io. return err } - switch strings.ToLower(args[0]) { + cmd := strings.ToLower(args[0]) + switch cmd { case "mailboxes": v, err := c.Mailboxes(ctx) if err != nil { @@ -135,7 +136,7 @@ func RunBot(ctx context.Context, c *Client, args []string, in io.Reader, out io. if len(args) > 3 { on = !strings.EqualFold(args[3], "off") && args[3] != "false" && args[3] != "0" } - if args[0] == "flag" { + if cmd == "flag" { err = c.Flag(ctx, mailbox, uid, on) } else { err = c.MarkSeen(ctx, mailbox, uid, on) diff --git a/internal/mailbox/mailbox_test.go b/internal/mailbox/mailbox_test.go index 09da9f1..f99cd4a 100644 --- a/internal/mailbox/mailbox_test.go +++ b/internal/mailbox/mailbox_test.go @@ -1,8 +1,10 @@ package mailbox import ( + "bytes" "context" "errors" + "strings" "testing" "time" ) @@ -142,3 +144,21 @@ func TestFlagAndDelete(t *testing.T) { t.Fatal("uid 1 should be deleted") } } + +func TestRunBotFlagCommandIsCaseInsensitive(t *testing.T) { + tr := seeded() + c := paidClient(tr) + var out bytes.Buffer + + if err := RunBot(context.Background(), c, []string{"FLAG", Inbox, "1"}, strings.NewReader(""), &out); err != nil { + t.Fatal(err) + } + + msg, _, _ := tr.ReadMessage(context.Background(), Inbox, 1) + if !msg.Flagged { + t.Fatal("uppercase FLAG should set the flagged flag") + } + if msg.Seen { + t.Fatal("uppercase FLAG should not mark the message seen") + } +}