-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for Slack mentions #143
Support for Slack mentions #143
Conversation
Rolled back mentions in push/commit notifications @yasunariw @tysg. Now things look like this: |
lib/slack_message.ml
Outdated
let ({ sha; commit; author; files; _ } : api_commit) = api_commit in | ||
let title = Slack.pp_api_commit api_commit in | ||
let slack_mention = | ||
match author with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Option.map_default ? or is it done like this for readability ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't remember, but I suppose the current match statement would look a bit cleaner since using Option.map_default
would look something like this:
let slack_mention =
author
|> Option.map_default
(fun gh_user -> gh_user |> match_github_user_to_slack_id |> Slack.format_slack_mention)
""
(please cleanup the commits / squash before merge) |
@@ -105,6 +105,7 @@ let () = | |||
| Ok config -> | |||
match Context.refresh_secrets ctx with | |||
| Ok ctx -> | |||
let%lwt () = Action_local.refresh_username_to_slack_id_tbl ~ctx in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the test harness should be modified to refresh the context with a handcrafted mapping (in OCaml, not from file) for some github/slack profiles in the existing test cases
I would prefer to update the output of the existing test cases with the changes from this feature, not to create new ones
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's probably a good idea to have a separate file for Slack profiles, since we'd probably want to test with an actual Slack users.list
payload. I don't think the existing test cases have any message body with GitHub user mentions either, so we should keep some of the new test files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks! lgtm, let's cleanup commits and merge
3d45ae8
to
60866f4
Compare
60866f4
to
94d723f
Compare
this behaviour should be mentioned in readme please |
Description of the task
Basic support for Slack mentions. When a GitHub handle can be matched with a Slack email, the Slack user is mentioned in Monorobot's messages and unfurled links (only links from supported repos).
The matching is done by
Monorobot keeps a cache of the Slack user list that's refreshed every 24 hours. Alternatively, GitHub handle to Slack email mapping can also be manually injected in
.monorobot.json
underuser_mappings
- in the case of conflicting mappings, the mapping in.monorobot.json
takes precedence.If Monorobot can't match a Slack user in the cached mapping, they are not mentioned.
How to test
Some basic tests were added. Test with
Old tests should remain the same, as the GitHub handles there are not present in the Slack user list cache file.
References