From 6228e1e3204b2f33ec8f83d733a2fd181fb8f091 Mon Sep 17 00:00:00 2001 From: walnuts1018 Date: Thu, 18 Jan 2024 22:12:35 +0900 Subject: [PATCH] Refactor SetUserCustomStatus function to handle empty text parameter --- infra/slack/slack.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/infra/slack/slack.go b/infra/slack/slack.go index 1ea6661..f84f6b5 100644 --- a/infra/slack/slack.go +++ b/infra/slack/slack.go @@ -23,8 +23,10 @@ func (c *client) SetUserCustomStatus(emoji string, text string) error { if !(strings.HasPrefix(emoji, ":") && strings.HasSuffix(emoji, ":")) { emoji = ":" + emoji + ":" } - - err := c.slackClient.SetUserCustomStatus(fmt.Sprintf("now coding: %v", text), emoji, 0) + if text != "" { + text = fmt.Sprintf("now coding: %v", text) + } + err := c.slackClient.SetUserCustomStatus(text, emoji, 0) if err != nil { return fmt.Errorf("error setting status: %w", err) }