Fix failed to to cannot

Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
Bryan Frimin
2025-10-29 19:28:02 +01:00
parent 2766f8e423
commit 6f2bd9c92f
39 changed files with 198 additions and 192 deletions

View File

@@ -91,7 +91,7 @@ func (c *Client) CreateMessage(ctx context.Context, accessToken string, channelI
responseBody, err := io.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("failed to read response body: %w", err)
return nil, fmt.Errorf("cannot read response body: %w", err)
}
if resp.StatusCode != http.StatusOK {
@@ -101,7 +101,7 @@ func (c *Client) CreateMessage(ctx context.Context, accessToken string, channelI
var slackResponse SlackResponse
if err := json.Unmarshal(responseBody, &slackResponse); err != nil {
return nil, fmt.Errorf("failed to parse Slack response: %w (body: %s)", err, string(responseBody))
return nil, fmt.Errorf("cannot parse Slack response: %w (body: %s)", err, string(responseBody))
}
if !slackResponse.OK {
@@ -142,7 +142,7 @@ func (c *Client) UpdateInteractiveMessage(ctx context.Context, responseURL strin
responseBody, err := io.ReadAll(resp.Body)
if err != nil {
return fmt.Errorf("failed to read response body: %w", err)
return fmt.Errorf("cannot read response body: %w", err)
}
if resp.StatusCode != http.StatusOK {
@@ -197,7 +197,7 @@ func (c *Client) UpdateMessage(ctx context.Context, accessToken string, channelI
responseBody, err := io.ReadAll(resp.Body)
if err != nil {
return fmt.Errorf("failed to read response body: %w", err)
return fmt.Errorf("cannot read response body: %w", err)
}
if resp.StatusCode != http.StatusOK {
@@ -206,7 +206,7 @@ func (c *Client) UpdateMessage(ctx context.Context, accessToken string, channelI
var slackResponse SlackResponse
if err := json.NewDecoder(bytes.NewReader(responseBody)).Decode(&slackResponse); err != nil {
return fmt.Errorf("failed to parse Slack response: %w (body: %s)", err, string(responseBody))
return fmt.Errorf("cannot parse Slack response: %w (body: %s)", err, string(responseBody))
}
if !slackResponse.OK {
@@ -242,7 +242,7 @@ func (c *Client) JoinChannel(ctx context.Context, accessToken string, channelID
responseBody, err := io.ReadAll(resp.Body)
if err != nil {
return fmt.Errorf("failed to read response body: %w", err)
return fmt.Errorf("cannot read response body: %w", err)
}
if resp.StatusCode != http.StatusOK {
@@ -252,7 +252,7 @@ func (c *Client) JoinChannel(ctx context.Context, accessToken string, channelID
var slackResponse SlackJoinResponse
if err := json.Unmarshal(responseBody, &slackResponse); err != nil {
return fmt.Errorf("failed to parse Slack response: %w (body: %s)", err, string(responseBody))
return fmt.Errorf("cannot parse Slack response: %w (body: %s)", err, string(responseBody))
}
if !slackResponse.OK {

View File

@@ -187,14 +187,14 @@ func (s *Sender) sendMessage(ctx context.Context, tx pg.Conn, message *coredata.
if message.Type == coredata.SlackMessageTypeWelcome {
if err := client.JoinChannel(ctx, slackConn.AccessToken, slackConn.Settings.ChannelID); err != nil {
s.logger.ErrorCtx(ctx, "failed to join Slack channel", log.Error(err))
s.logger.ErrorCtx(ctx, "cannot join Slack channel", log.Error(err))
}
}
slackResp, err := client.CreateMessage(ctx, slackConn.AccessToken, slackConn.Settings.ChannelID, message.Body)
if err != nil {
s.logger.ErrorCtx(ctx, "failed to post message to Slack", log.Error(err))
return nil, nil, fmt.Errorf("failed to post message to Slack: %w", err)
s.logger.ErrorCtx(ctx, "cannot post message to Slack", log.Error(err))
return nil, nil, fmt.Errorf("cannot post message to Slack: %w", err)
}
return &slackResp.Channel, &slackResp.TS, nil
@@ -309,8 +309,8 @@ func (s *Sender) updateMessage(ctx context.Context, tx pg.Conn, updateMessage *c
client := NewClient(s.logger)
if err := client.UpdateMessage(ctx, slackConn.AccessToken, *updateMessage.ChannelID, *updateMessage.MessageTS, updateMessage.Body); err != nil {
s.logger.ErrorCtx(ctx, "failed to update message on Slack", log.Error(err))
return fmt.Errorf("failed to update message on Slack: %w", err)
s.logger.ErrorCtx(ctx, "cannot update message on Slack", log.Error(err))
return fmt.Errorf("cannot update message on Slack: %w", err)
}
return nil