Skip to content
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

handle pr notifications on the same thread #161

Merged
merged 8 commits into from
Oct 18, 2024

Conversation

thatportugueseguy
Copy link
Collaborator

@thatportugueseguy thatportugueseguy commented Oct 7, 2024

This PR handles PR and PR-related github notifications on monorobot. Tackles #154 and #155.

When a PR is

  • created -> posts message to the channel with the PR info + labels info (this becomes a thread for the PR)
  • labeled -> will only show labels added post PR creation, will show them on the thread
  • commented -> will add complete notification to the thread + summary notification on the channel with link to the thread
  • reviewed -> same as above ☝️ + individual msg to the thread per comment in the review
  • closed/merged -> posts message to the thread + summary notification to the channel + deletes state for that thread for cleanup

* origin/master:
  Revert "DM only when user breaks a step (#160)"
* origin/master:
  dune: remove unused result dependency
  github: use ubuntu-22.04
  github: remove manual apt update
  github: add dependabot
  make status notifications minimal
  config_docs.md: clarify why GH handle matching is needed
  readme.md, config_docs.md: add documentation on slack mentions

let get_thread_permalink ~ctx:_ (thread : State_t.slack_thread) =
Lwt.return_some
@@ Printf.sprintf "https://monorobot.slack.com/archives/%s/p%s?thread_ts=%s&cid=%s" thread.cid
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it the correct url?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, this is a dummy url. The structure is correct, but the domain is not. i didn't want to use the real one. This is only used for tests, I don't think it matters.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can put as a comment in code please?

@Khady
Copy link
Contributor

Khady commented Oct 15, 2024

is it waiting on anything? Can you show how the messages will look like?

@thatportugueseguy
Copy link
Collaborator Author

thatportugueseguy commented Oct 15, 2024

This is how it looks:
Screenshot 2024-10-15 at 11 08 59

I've added these boxes and arrows to make it easier to connect the messages on the channel and the thread. The messages in boxes are independent messages, the messages with arrows are messages that are sent at the same time as the independent ones. It looks quite condensed, but we have to keep in mind that we'll have other messages in between, so these messages on the channel may/will be quite far apart.
Screenshot 2024-10-15 at 11 00 43

I've just noticed that I have an issue with the merge notification styles, I'm going to fix those

@thatportugueseguy
Copy link
Collaborator Author

@Khady can we merge this?

@thatportugueseguy thatportugueseguy merged commit 5a89c0c into master Oct 18, 2024
2 of 3 checks passed
@thatportugueseguy thatportugueseguy deleted the pr-reviews-in-threads branch October 18, 2024 09:52
Comment on lines -128 to +194
| Some a -> Some (sprintf "New comment by %s in <%s|%s>" sender.login comment.html_url a)
| Some a -> Some (sprintf "Commented in file <%s|%s>" comment.html_url a)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change is unrelated to the PR

Comment on lines -93 to +138
| "commented" -> "commented on"
| "commented" -> "reviewed"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the change is unrelated to the PR

Comment on lines +89 to +94
| Opened | Ready_for_review ->
let labels_banner = show_labels labels in
( "opened",
body
|> Option.map (fun body' ->
Option.map_default (fun labels' -> sprintf "%s\n%s" body' labels') body' labels_banner) )
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the change is unrelated to the PR

let url_args = Web.make_url_args [ "channel", thread.cid; "message_ts", thread.ts ] in
match%lwt
request_token_auth ~name:"retrieve message permalink" ~ctx `GET
(sprintf "chat.getPermalink?%s" url_args)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(sprintf "chat.getPermalink?%s" url_args)
"chat.getPermalink"

this is confusing, should pass url_args as another param to request_token_auth

@@ -144,6 +146,13 @@ type auth_test_res = {
user_id: string;
}

type permalink_res = {
ok: bool;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the field is unnecessary, it is handled by http_response below

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants