88 "crypto/sha256"
99 "encoding/hex"
1010 "encoding/json"
11+ "errors"
1112 "fmt"
1213 "io"
1314 "log/slog"
@@ -24,6 +25,12 @@ import (
2425 "github.com/slack-go/slack/slackevents"
2526)
2627
28+ // Errors
29+ var (
30+ // ErrNoDMToUpdate indicates no DM exists to update.
31+ ErrNoDMToUpdate = errors .New ("no DM found to update" )
32+ )
33+
2734// Constants for input validation.
2835const (
2936 maxCommandInputLength = 200
@@ -460,9 +467,14 @@ func (c *Client) SendDirectMessage(ctx context.Context, userID, text string) (dm
460467
461468 var msgTS string
462469 // Then send message with retry
470+ // Disable unfurling for GitHub links in DMs.
471+ options := []slack.MsgOption {
472+ slack .MsgOptionText (text , false ),
473+ slack .MsgOptionDisableLinkUnfurl (),
474+ }
463475 err = retry .Do (
464476 func () error {
465- _ , ts , err := c .api .PostMessageContext (ctx , channelID , slack . MsgOptionText ( text , false ) )
477+ _ , ts , err := c .api .PostMessageContext (ctx , channelID , options ... )
466478 if err != nil {
467479 if isRateLimitError (err ) {
468480 slog .Warn ("rate limited sending DM, backing off" , "user" , userID )
@@ -522,14 +534,15 @@ func (c *Client) SaveDMMessageInfo(ctx context.Context, userID, prURL, channelID
522534}
523535
524536// UpdateDMMessage updates a previously sent DM message.
537+ // Returns nil and logs debug if no DM exists, returns error if update fails.
525538func (c * Client ) UpdateDMMessage (ctx context.Context , userID , prURL , newText string ) error {
526539 c .stateStoreMu .RLock ()
527540 store := c .stateStore
528541 c .stateStoreMu .RUnlock ()
529542
530543 if store == nil {
531544 slog .Debug ("no state store configured, cannot update DM" , "user" , userID , "pr_url" , prURL )
532- return nil
545+ return ErrNoDMToUpdate
533546 }
534547
535548 // Get stored DM message info
@@ -539,7 +552,7 @@ func (c *Client) UpdateDMMessage(ctx context.Context, userID, prURL, newText str
539552 "user" , userID ,
540553 "pr_url" , prURL ,
541554 "reason" , "never sent or too old" )
542- return nil
555+ return ErrNoDMToUpdate
543556 }
544557
545558 // Update the message using Slack API
0 commit comments