From 110fc713499e1ac8bf09ad5e7d8e3bcca390c5a0 Mon Sep 17 00:00:00 2001 From: Meng Zhuo Date: Mon, 9 Mar 2026 22:45:01 +0800 Subject: [PATCH] chore: drop unnessary crypto/rand (#1267) --- pkg/channels/feishu/feishu_64.go | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/pkg/channels/feishu/feishu_64.go b/pkg/channels/feishu/feishu_64.go index 5217dd4e9..5dbbcf0af 100644 --- a/pkg/channels/feishu/feishu_64.go +++ b/pkg/channels/feishu/feishu_64.go @@ -4,11 +4,10 @@ package feishu import ( "context" - "crypto/rand" "encoding/json" "fmt" "io" - "math/big" + "math/rand" "net/http" "os" "path/filepath" @@ -201,18 +200,13 @@ func (c *FeishuChannel) SendPlaceholder(ctx context.Context, chatID string) (str func (c *FeishuChannel) ReactToMessage(ctx context.Context, chatID, messageID string) (func(), error) { // Get emoji list from config emojiList := c.config.RandomReactionEmoji + var chosenEmoji string if len(emojiList) == 0 { // Default to "Pin" if no config - emojiList = []string{"Pin"} - } - - // Randomly choose one from the list using crypto/rand for better distribution - idx, err := rand.Int(rand.Reader, big.NewInt(int64(len(emojiList)))) - var chosenEmoji string - if err != nil { - chosenEmoji = emojiList[0] + chosenEmoji = "Pin" } else { - chosenEmoji = emojiList[idx.Int64()] + idx := rand.Intn(len(emojiList)) + chosenEmoji = emojiList[idx] } req := larkim.NewCreateMessageReactionReqBuilder().