Skip to content

Commit

Permalink
automod: small fixes (#469)
Browse files Browse the repository at this point in the history
didn't want to clutter other PRs with these
  • Loading branch information
bnewbold authored Dec 11, 2023
2 parents b805dee + c479e33 commit 4bfee6d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions automod/slack.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ type SlackWebhookBody struct {
func (e *Engine) SendSlackMsg(ctx context.Context, msg string) error {
// loosely based on: https://golangcode.com/send-slack-messages-without-a-library/

body, _ := json.Marshal(SlackWebhookBody{Text: msg})
body, err := json.Marshal(SlackWebhookBody{Text: msg})
if err != nil {
return err
}
req, err := http.NewRequestWithContext(ctx, http.MethodPost, e.SlackWebhookURL, bytes.NewBuffer(body))
if err != nil {
return err
Expand All @@ -35,7 +38,6 @@ func (e *Engine) SendSlackMsg(ctx context.Context, msg string) error {
buf := new(bytes.Buffer)
buf.ReadFrom(resp.Body)
if resp.StatusCode != 200 || buf.String() != "ok" {
// TODO: in some cases print body? eg, if short and text
return fmt.Errorf("failed slack webhook POST request. status=%d", resp.StatusCode)
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion cmd/hepa/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func NewServer(dir identity.Directory, config Config) (*Server, error) {
return nil, fmt.Errorf("specified bgs host must include 'ws://' or 'wss://'")
}

// TODO: this isn't a very robust way to handle a peristent client
// TODO: this isn't a very robust way to handle a persistent client
var xrpcc *xrpc.Client
if config.ModAdminToken != "" {
xrpcc = &xrpc.Client{
Expand Down

0 comments on commit 4bfee6d

Please sign in to comment.