Skip to content

Commit a80e489

Browse files
committed
don't log errors in subroutines
1 parent b05e9bb commit a80e489

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

lib/slack.ml

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ open Common
55
open Github_j
66
open Slack_j
77

8-
let log = Log.from "slack"
9-
108
let empty_attachments =
119
{
1210
mrkdwn_in = None;
@@ -361,23 +359,19 @@ let generate_commit_comment_notification api_commit notification channel =
361359
in
362360
{ channel; text = None; attachments = Some [ attachment ]; blocks = None }
363361

364-
let has_valid_signature ?(version = "v0") ?signing_key ~headers body =
362+
let validate_signature ?(version = "v0") ?signing_key ~headers body =
365363
match signing_key with
366-
| None -> true
364+
| None -> Ok ()
367365
| Some key ->
368366
match List.Assoc.find headers "x-slack-signature" ~equal:String.equal with
369-
| None ->
370-
log#error "unable to find header X-Slack-Signature";
371-
false
367+
| None -> Error "unable to find header X-Slack-Signature"
372368
| Some signature ->
373369
match List.Assoc.find headers "x-slack-request-timestamp" ~equal:String.equal with
374-
| None ->
375-
log#error "unable to find header X-Slack-Request-Timestamp";
376-
false
370+
| None -> Error "unable to find header X-Slack-Request-Timestamp"
377371
| Some timestamp ->
378372
let basestring = Printf.sprintf "%s:%s:%s" version timestamp body in
379373
let expected_signature = Printf.sprintf "%s=%s" version (Common.sign_string_sha256 ~key ~basestring) in
380-
String.equal expected_signature signature
374+
if String.equal expected_signature signature then Ok () else Error "signatures don't match"
381375

382376
let has_valid_state ?oauth_state ~args =
383377
match oauth_state with

0 commit comments

Comments
 (0)