From 7062f4c94ea83ff45f5ca79612137f2f86fdf7f6 Mon Sep 17 00:00:00 2001 From: Hammy <58985301+sgoudham@users.noreply.github.com> Date: Wed, 2 Oct 2024 23:40:38 +0100 Subject: [PATCH] feat: add `pull_request_review_comment` event (#32) --- .../pull_request_review_comment/created.json | 607 ++++++++++++++++++ .../pull_request_review_comment/created.snap | 17 + src/events.rs | 4 + src/events/pull_request_review_comment.rs | 64 ++ 4 files changed, 692 insertions(+) create mode 100644 fixtures/pull_request_review_comment/created.json create mode 100644 snapshots/pull_request_review_comment/created.snap create mode 100644 src/events/pull_request_review_comment.rs diff --git a/fixtures/pull_request_review_comment/created.json b/fixtures/pull_request_review_comment/created.json new file mode 100644 index 0000000..d7b1413 --- /dev/null +++ b/fixtures/pull_request_review_comment/created.json @@ -0,0 +1,607 @@ +{ + "action": "created", + "comment": { + "url": "https://api.github.com/repos/catppuccin/discord/pulls/comments/1785288051", + "pull_request_review_id": 2344164779, + "id": 1785288051, + "node_id": "PRRC_kwDOGuo7B85qaVVz", + "diff_hunk": "@@ -34,60 +36,43 @@\n \n ## Usage\n \n-### [BetterDiscord](https://betterdiscord.app)\n-\n-1. Download your preferred flavour:\n-\n-- 🌻 [Latte](./themes/latte.theme.css?raw=1)\n-- 🪴 [Frappe](./themes/frappe.theme.css?raw=1)\n-- 🌺 [Macchiato](./themes/macchiato.theme.css?raw=1)\n-- 🌿 [Mocha](./themes/mocha.theme.css?raw=1)\n-\n-2. Copy the downloaded file to your BetterDiscord themes folder.\n-3. Enable the theme in BetterDiscord settings.\n-\n-### Clients/Mods with custom CSS support\n+### Custom CSS ([Vencord](https://vencord.dev/), [BetterDiscord](https://betterdiscord.app/))\n \n-1. Simply add your preferred flavour into your discord clients CustomCSS file/editor.\n+Add `@import url(\"https://catppuccin.github.io/discord/dist/catppuccin--.theme.css\");` to your Discord client's custom CSS file/editor, where `` are your preferred flavor and accent, respectively. To simply go with the default accent color, omit the `-` part. For example:\n \n ```css\n-/* latte */\n-@import url(\"https://catppuccin.github.io/discord/dist/catppuccin-latte.theme.css\");\n-/* frappe */\n-@import url(\"https://catppuccin.github.io/discord/dist/catppuccin-frappe.theme.css\");\n-/* macchiato */\n-@import url(\"https://catppuccin.github.io/discord/dist/catppuccin-macchiato.theme.css\");\n-/* mocha */\n+/* Mocha, with the default accent: */\n @import url(\"https://catppuccin.github.io/discord/dist/catppuccin-mocha.theme.css\");\n \n-/* You can also append Catppuccin colors to customize the accent, e.g. */\n-/* mocha (pink accent)*/\n+/* Mocha, with a custom pink accent: */\n @import url(\"https://catppuccin.github.io/discord/dist/catppuccin-mocha-pink.theme.css\");\n-/* frappe (maroon accent) */\n-@import url(\"https://catppuccin.github.io/discord/dist/catppuccin-frappe-maroon.theme.css\");\n+\n+/* Of course, you can do the same with any flavor and any accent - not just mocha or pink: */\n+@import url(\"https://catppuccin.github.io/discord/dist/catppuccin-latte.theme.css\");\n+@import url(\"https://catppuccin.github.io/discord/dist/catppuccin-latte-blue.theme.css\");\n ```\n \n-### [Stylus](https://github.com/openstyles/stylus)\n+> [!TIP]\n+> You can also have Discord automatically switch themes depending on your system theme preference. The following snippet showcases a configuration that switches between latte in light mode and mocha in dark mode by adding an inline [`prefers-color-scheme` media feature](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme), `(prefers-color-scheme: )`, after each `@import` statement (see [\"Importing CSS rules conditional on media queries\" - MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/@import#importing_css_rules_conditional_on_media_queries)).\n+>\n+> ```css\n+> @import url(\"https://catppuccin.github.io/discord/dist/catppuccin-mocha.theme.css\")\n+> (prefers-color-scheme: dark);\n+> @import url(\"https://catppuccin.github.io/discord/dist/catppuccin-latte.theme.css\")\n+> (prefers-color-scheme: light);\n+> ```\n+\n+### [Stylus](https://github.com/openstyles/stylus) (Web)\n \n 1. Enable CSP Patching from Stylus Settings > Advanced.\n-2. [Click here to install](https://github.com/catppuccin/discord/raw/main/discord.user.css).\n-3. Choose your preferred flavour and accent color from the Stylus preference dropdown.\n+2. Visit the following URL to bring up the Stylus install page for the Discord userstyle: https://github.com/catppuccin/discord/raw/main/discord.user.css.", + "path": "README.md", + "commit_id": "76d07d022737399943a8fee029888e101370cff6", + "original_commit_id": "76d07d022737399943a8fee029888e101370cff6", + "user": { + "login": "uncenter", + "id": 47499684, + "node_id": "MDQ6VXNlcjQ3NDk5Njg0", + "avatar_url": "https://avatars.githubusercontent.com/u/47499684?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/uncenter", + "html_url": "https://github.com/uncenter", + "followers_url": "https://api.github.com/users/uncenter/followers", + "following_url": "https://api.github.com/users/uncenter/following{/other_user}", + "gists_url": "https://api.github.com/users/uncenter/gists{/gist_id}", + "starred_url": "https://api.github.com/users/uncenter/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/uncenter/subscriptions", + "organizations_url": "https://api.github.com/users/uncenter/orgs", + "repos_url": "https://api.github.com/users/uncenter/repos", + "events_url": "https://api.github.com/users/uncenter/events{/privacy}", + "received_events_url": "https://api.github.com/users/uncenter/received_events", + "type": "User", + "site_admin": false + }, + "body": "More clarity about what you are clicking on, why it would install it. ", + "created_at": "2024-10-02T21:52:55Z", + "updated_at": "2024-10-02T21:52:55Z", + "html_url": "https://github.com/catppuccin/discord/pull/325#discussion_r1785288051", + "pull_request_url": "https://api.github.com/repos/catppuccin/discord/pulls/325", + "author_association": "MEMBER", + "_links": { + "self": { + "href": "https://api.github.com/repos/catppuccin/discord/pulls/comments/1785288051" + }, + "html": { + "href": "https://github.com/catppuccin/discord/pull/325#discussion_r1785288051" + }, + "pull_request": { + "href": "https://api.github.com/repos/catppuccin/discord/pulls/325" + } + }, + "reactions": { + "url": "https://api.github.com/repos/catppuccin/discord/pulls/comments/1785288051/reactions", + "total_count": 0, + "+1": 0, + "-1": 0, + "laugh": 0, + "hooray": 0, + "confused": 0, + "heart": 0, + "rocket": 0, + "eyes": 0 + }, + "start_line": null, + "original_start_line": null, + "start_side": null, + "line": 68, + "original_line": 68, + "side": "RIGHT", + "in_reply_to_id": 1785137260, + "original_position": 72, + "position": 72, + "subject_type": "line" + }, + "pull_request": { + "url": "https://api.github.com/repos/catppuccin/discord/pulls/325", + "id": 2059433626, + "node_id": "PR_kwDOGuo7B856wHaa", + "html_url": "https://github.com/catppuccin/discord/pull/325", + "diff_url": "https://github.com/catppuccin/discord/pull/325.diff", + "patch_url": "https://github.com/catppuccin/discord/pull/325.patch", + "issue_url": "https://api.github.com/repos/catppuccin/discord/issues/325", + "number": 325, + "state": "open", + "locked": false, + "title": "docs(README): update and improve usage steps", + "user": { + "login": "uncenter", + "id": 47499684, + "node_id": "MDQ6VXNlcjQ3NDk5Njg0", + "avatar_url": "https://avatars.githubusercontent.com/u/47499684?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/uncenter", + "html_url": "https://github.com/uncenter", + "followers_url": "https://api.github.com/users/uncenter/followers", + "following_url": "https://api.github.com/users/uncenter/following{/other_user}", + "gists_url": "https://api.github.com/users/uncenter/gists{/gist_id}", + "starred_url": "https://api.github.com/users/uncenter/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/uncenter/subscriptions", + "organizations_url": "https://api.github.com/users/uncenter/orgs", + "repos_url": "https://api.github.com/users/uncenter/repos", + "events_url": "https://api.github.com/users/uncenter/events{/privacy}", + "received_events_url": "https://api.github.com/users/uncenter/received_events", + "type": "User", + "site_admin": false + }, + "body": "This PR removes the custom BetterDiscord theme files in favor of including BetterDiscord under the Custom CSS step. BetterDiscord supports custom CSS, and now users of BetterDiscord can utilize the automatic system theme switching tip as well as reducing the complexity of this repository. I updated the custom CSS usage language in a way that I think makes it more clear and understandable how to use the default accent for a flavor, or a custom one. I also realized that the automatic system theme switching FAQ question only works for one of the installation methods, so I moved it to be a tip callout there. (In the future we can add this capability to the Stylus/userstyle version as well.)", + "created_at": "2024-09-07T19:18:47Z", + "updated_at": "2024-10-02T21:52:55Z", + "closed_at": null, + "merged_at": null, + "merge_commit_sha": "1efeaf873f3f2adb968a5986678496f881e0039d", + "assignee": null, + "assignees": [ + + ], + "requested_reviewers": [ + + ], + "requested_teams": [ + + ], + "labels": [ + + ], + "milestone": null, + "draft": false, + "commits_url": "https://api.github.com/repos/catppuccin/discord/pulls/325/commits", + "review_comments_url": "https://api.github.com/repos/catppuccin/discord/pulls/325/comments", + "review_comment_url": "https://api.github.com/repos/catppuccin/discord/pulls/comments{/number}", + "comments_url": "https://api.github.com/repos/catppuccin/discord/issues/325/comments", + "statuses_url": "https://api.github.com/repos/catppuccin/discord/statuses/76d07d022737399943a8fee029888e101370cff6", + "head": { + "label": "uncenter:docs/update", + "ref": "docs/update", + "sha": "76d07d022737399943a8fee029888e101370cff6", + "user": { + "login": "uncenter", + "id": 47499684, + "node_id": "MDQ6VXNlcjQ3NDk5Njg0", + "avatar_url": "https://avatars.githubusercontent.com/u/47499684?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/uncenter", + "html_url": "https://github.com/uncenter", + "followers_url": "https://api.github.com/users/uncenter/followers", + "following_url": "https://api.github.com/users/uncenter/following{/other_user}", + "gists_url": "https://api.github.com/users/uncenter/gists{/gist_id}", + "starred_url": "https://api.github.com/users/uncenter/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/uncenter/subscriptions", + "organizations_url": "https://api.github.com/users/uncenter/orgs", + "repos_url": "https://api.github.com/users/uncenter/repos", + "events_url": "https://api.github.com/users/uncenter/events{/privacy}", + "received_events_url": "https://api.github.com/users/uncenter/received_events", + "type": "User", + "site_admin": false + }, + "repo": { + "id": 823810110, + "node_id": "R_kgDOMRpYPg", + "name": "ctp-discord", + "full_name": "uncenter/ctp-discord", + "private": false, + "owner": { + "login": "uncenter", + "id": 47499684, + "node_id": "MDQ6VXNlcjQ3NDk5Njg0", + "avatar_url": "https://avatars.githubusercontent.com/u/47499684?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/uncenter", + "html_url": "https://github.com/uncenter", + "followers_url": "https://api.github.com/users/uncenter/followers", + "following_url": "https://api.github.com/users/uncenter/following{/other_user}", + "gists_url": "https://api.github.com/users/uncenter/gists{/gist_id}", + "starred_url": "https://api.github.com/users/uncenter/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/uncenter/subscriptions", + "organizations_url": "https://api.github.com/users/uncenter/orgs", + "repos_url": "https://api.github.com/users/uncenter/repos", + "events_url": "https://api.github.com/users/uncenter/events{/privacy}", + "received_events_url": "https://api.github.com/users/uncenter/received_events", + "type": "User", + "site_admin": false + }, + "html_url": "https://github.com/uncenter/ctp-discord", + "description": "🎮 Soothing pastel theme for Discord", + "fork": true, + "url": "https://api.github.com/repos/uncenter/ctp-discord", + "forks_url": "https://api.github.com/repos/uncenter/ctp-discord/forks", + "keys_url": "https://api.github.com/repos/uncenter/ctp-discord/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/uncenter/ctp-discord/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/uncenter/ctp-discord/teams", + "hooks_url": "https://api.github.com/repos/uncenter/ctp-discord/hooks", + "issue_events_url": "https://api.github.com/repos/uncenter/ctp-discord/issues/events{/number}", + "events_url": "https://api.github.com/repos/uncenter/ctp-discord/events", + "assignees_url": "https://api.github.com/repos/uncenter/ctp-discord/assignees{/user}", + "branches_url": "https://api.github.com/repos/uncenter/ctp-discord/branches{/branch}", + "tags_url": "https://api.github.com/repos/uncenter/ctp-discord/tags", + "blobs_url": "https://api.github.com/repos/uncenter/ctp-discord/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/uncenter/ctp-discord/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/uncenter/ctp-discord/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/uncenter/ctp-discord/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/uncenter/ctp-discord/statuses/{sha}", + "languages_url": "https://api.github.com/repos/uncenter/ctp-discord/languages", + "stargazers_url": "https://api.github.com/repos/uncenter/ctp-discord/stargazers", + "contributors_url": "https://api.github.com/repos/uncenter/ctp-discord/contributors", + "subscribers_url": "https://api.github.com/repos/uncenter/ctp-discord/subscribers", + "subscription_url": "https://api.github.com/repos/uncenter/ctp-discord/subscription", + "commits_url": "https://api.github.com/repos/uncenter/ctp-discord/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/uncenter/ctp-discord/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/uncenter/ctp-discord/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/uncenter/ctp-discord/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/uncenter/ctp-discord/contents/{+path}", + "compare_url": "https://api.github.com/repos/uncenter/ctp-discord/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/uncenter/ctp-discord/merges", + "archive_url": "https://api.github.com/repos/uncenter/ctp-discord/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/uncenter/ctp-discord/downloads", + "issues_url": "https://api.github.com/repos/uncenter/ctp-discord/issues{/number}", + "pulls_url": "https://api.github.com/repos/uncenter/ctp-discord/pulls{/number}", + "milestones_url": "https://api.github.com/repos/uncenter/ctp-discord/milestones{/number}", + "notifications_url": "https://api.github.com/repos/uncenter/ctp-discord/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/uncenter/ctp-discord/labels{/name}", + "releases_url": "https://api.github.com/repos/uncenter/ctp-discord/releases{/id}", + "deployments_url": "https://api.github.com/repos/uncenter/ctp-discord/deployments", + "created_at": "2024-07-03T19:06:18Z", + "updated_at": "2024-09-07T16:01:04Z", + "pushed_at": "2024-09-16T13:56:14Z", + "git_url": "git://github.com/uncenter/ctp-discord.git", + "ssh_url": "git@github.com:uncenter/ctp-discord.git", + "clone_url": "https://github.com/uncenter/ctp-discord.git", + "svn_url": "https://github.com/uncenter/ctp-discord", + "homepage": "", + "size": 905, + "stargazers_count": 0, + "watchers_count": 0, + "language": "SCSS", + "has_issues": false, + "has_projects": true, + "has_downloads": true, + "has_wiki": false, + "has_pages": false, + "has_discussions": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 0, + "license": { + "key": "mit", + "name": "MIT License", + "spdx_id": "MIT", + "url": "https://api.github.com/licenses/mit", + "node_id": "MDc6TGljZW5zZTEz" + }, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [ + + ], + "visibility": "public", + "forks": 0, + "open_issues": 0, + "watchers": 0, + "default_branch": "main", + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "allow_auto_merge": false, + "delete_branch_on_merge": false, + "allow_update_branch": false, + "use_squash_pr_title_as_default": false, + "squash_merge_commit_message": "COMMIT_MESSAGES", + "squash_merge_commit_title": "COMMIT_OR_PR_TITLE", + "merge_commit_message": "PR_TITLE", + "merge_commit_title": "MERGE_MESSAGE" + } + }, + "base": { + "label": "catppuccin:main", + "ref": "main", + "sha": "80c0fcb02f9704aeb70545bed4ebefff61837275", + "user": { + "login": "catppuccin", + "id": 93489351, + "node_id": "O_kgDOBZKIxw", + "avatar_url": "https://avatars.githubusercontent.com/u/93489351?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/catppuccin", + "html_url": "https://github.com/catppuccin", + "followers_url": "https://api.github.com/users/catppuccin/followers", + "following_url": "https://api.github.com/users/catppuccin/following{/other_user}", + "gists_url": "https://api.github.com/users/catppuccin/gists{/gist_id}", + "starred_url": "https://api.github.com/users/catppuccin/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/catppuccin/subscriptions", + "organizations_url": "https://api.github.com/users/catppuccin/orgs", + "repos_url": "https://api.github.com/users/catppuccin/repos", + "events_url": "https://api.github.com/users/catppuccin/events{/privacy}", + "received_events_url": "https://api.github.com/users/catppuccin/received_events", + "type": "Organization", + "site_admin": false + }, + "repo": { + "id": 451558151, + "node_id": "R_kgDOGuo7Bw", + "name": "discord", + "full_name": "catppuccin/discord", + "private": false, + "owner": { + "login": "catppuccin", + "id": 93489351, + "node_id": "O_kgDOBZKIxw", + "avatar_url": "https://avatars.githubusercontent.com/u/93489351?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/catppuccin", + "html_url": "https://github.com/catppuccin", + "followers_url": "https://api.github.com/users/catppuccin/followers", + "following_url": "https://api.github.com/users/catppuccin/following{/other_user}", + "gists_url": "https://api.github.com/users/catppuccin/gists{/gist_id}", + "starred_url": "https://api.github.com/users/catppuccin/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/catppuccin/subscriptions", + "organizations_url": "https://api.github.com/users/catppuccin/orgs", + "repos_url": "https://api.github.com/users/catppuccin/repos", + "events_url": "https://api.github.com/users/catppuccin/events{/privacy}", + "received_events_url": "https://api.github.com/users/catppuccin/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/catppuccin/discord", + "description": "🎮 Soothing pastel theme for Discord", + "fork": false, + "url": "https://api.github.com/repos/catppuccin/discord", + "forks_url": "https://api.github.com/repos/catppuccin/discord/forks", + "keys_url": "https://api.github.com/repos/catppuccin/discord/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/catppuccin/discord/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/catppuccin/discord/teams", + "hooks_url": "https://api.github.com/repos/catppuccin/discord/hooks", + "issue_events_url": "https://api.github.com/repos/catppuccin/discord/issues/events{/number}", + "events_url": "https://api.github.com/repos/catppuccin/discord/events", + "assignees_url": "https://api.github.com/repos/catppuccin/discord/assignees{/user}", + "branches_url": "https://api.github.com/repos/catppuccin/discord/branches{/branch}", + "tags_url": "https://api.github.com/repos/catppuccin/discord/tags", + "blobs_url": "https://api.github.com/repos/catppuccin/discord/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/catppuccin/discord/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/catppuccin/discord/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/catppuccin/discord/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/catppuccin/discord/statuses/{sha}", + "languages_url": "https://api.github.com/repos/catppuccin/discord/languages", + "stargazers_url": "https://api.github.com/repos/catppuccin/discord/stargazers", + "contributors_url": "https://api.github.com/repos/catppuccin/discord/contributors", + "subscribers_url": "https://api.github.com/repos/catppuccin/discord/subscribers", + "subscription_url": "https://api.github.com/repos/catppuccin/discord/subscription", + "commits_url": "https://api.github.com/repos/catppuccin/discord/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/catppuccin/discord/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/catppuccin/discord/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/catppuccin/discord/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/catppuccin/discord/contents/{+path}", + "compare_url": "https://api.github.com/repos/catppuccin/discord/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/catppuccin/discord/merges", + "archive_url": "https://api.github.com/repos/catppuccin/discord/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/catppuccin/discord/downloads", + "issues_url": "https://api.github.com/repos/catppuccin/discord/issues{/number}", + "pulls_url": "https://api.github.com/repos/catppuccin/discord/pulls{/number}", + "milestones_url": "https://api.github.com/repos/catppuccin/discord/milestones{/number}", + "notifications_url": "https://api.github.com/repos/catppuccin/discord/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/catppuccin/discord/labels{/name}", + "releases_url": "https://api.github.com/repos/catppuccin/discord/releases{/id}", + "deployments_url": "https://api.github.com/repos/catppuccin/discord/deployments", + "created_at": "2022-01-24T17:11:38Z", + "updated_at": "2024-10-02T20:29:14Z", + "pushed_at": "2024-10-02T19:46:11Z", + "git_url": "git://github.com/catppuccin/discord.git", + "ssh_url": "git@github.com:catppuccin/discord.git", + "clone_url": "https://github.com/catppuccin/discord.git", + "svn_url": "https://github.com/catppuccin/discord", + "homepage": "", + "size": 15176, + "stargazers_count": 753, + "watchers_count": 753, + "language": "SCSS", + "has_issues": true, + "has_projects": false, + "has_downloads": true, + "has_wiki": false, + "has_pages": true, + "has_discussions": false, + "forks_count": 173, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 10, + "license": { + "key": "mit", + "name": "MIT License", + "spdx_id": "MIT", + "url": "https://api.github.com/licenses/mit", + "node_id": "MDc6TGljZW5zZTEz" + }, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [ + "betterdiscord-theme", + "catppuccin", + "discord", + "discord-theme", + "hacktoberfest", + "powercord-theme", + "stylus", + "vencord-theme" + ], + "visibility": "public", + "forks": 173, + "open_issues": 10, + "watchers": 753, + "default_branch": "main", + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "allow_auto_merge": false, + "delete_branch_on_merge": false, + "allow_update_branch": false, + "use_squash_pr_title_as_default": false, + "squash_merge_commit_message": "COMMIT_MESSAGES", + "squash_merge_commit_title": "COMMIT_OR_PR_TITLE", + "merge_commit_message": "PR_TITLE", + "merge_commit_title": "MERGE_MESSAGE" + } + }, + "_links": { + "self": { + "href": "https://api.github.com/repos/catppuccin/discord/pulls/325" + }, + "html": { + "href": "https://github.com/catppuccin/discord/pull/325" + }, + "issue": { + "href": "https://api.github.com/repos/catppuccin/discord/issues/325" + }, + "comments": { + "href": "https://api.github.com/repos/catppuccin/discord/issues/325/comments" + }, + "review_comments": { + "href": "https://api.github.com/repos/catppuccin/discord/pulls/325/comments" + }, + "review_comment": { + "href": "https://api.github.com/repos/catppuccin/discord/pulls/comments{/number}" + }, + "commits": { + "href": "https://api.github.com/repos/catppuccin/discord/pulls/325/commits" + }, + "statuses": { + "href": "https://api.github.com/repos/catppuccin/discord/statuses/76d07d022737399943a8fee029888e101370cff6" + } + }, + "author_association": "MEMBER", + "auto_merge": null, + "active_lock_reason": null + }, + "repository": { + "id": 451558151, + "node_id": "R_kgDOGuo7Bw", + "name": "discord", + "full_name": "catppuccin/discord", + "private": false, + "owner": { + "login": "catppuccin", + "id": 93489351, + "node_id": "O_kgDOBZKIxw", + "avatar_url": "https://avatars.githubusercontent.com/u/93489351?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/catppuccin", + "html_url": "https://github.com/catppuccin", + "followers_url": "https://api.github.com/users/catppuccin/followers", + "following_url": "https://api.github.com/users/catppuccin/following{/other_user}", + "gists_url": "https://api.github.com/users/catppuccin/gists{/gist_id}", + "starred_url": "https://api.github.com/users/catppuccin/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/catppuccin/subscriptions", + "organizations_url": "https://api.github.com/users/catppuccin/orgs", + "repos_url": "https://api.github.com/users/catppuccin/repos", + "events_url": "https://api.github.com/users/catppuccin/events{/privacy}", + "received_events_url": "https://api.github.com/users/catppuccin/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/catppuccin/discord", + "description": "🎮 Soothing pastel theme for Discord", + "fork": false, + "url": "https://api.github.com/repos/catppuccin/discord", + "forks_url": "https://api.github.com/repos/catppuccin/discord/forks", + "keys_url": "https://api.github.com/repos/catppuccin/discord/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/catppuccin/discord/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/catppuccin/discord/teams", + "hooks_url": "https://api.github.com/repos/catppuccin/discord/hooks", + "issue_events_url": "https://api.github.com/repos/catppuccin/discord/issues/events{/number}", + "events_url": "https://api.github.com/repos/catppuccin/discord/events", + "assignees_url": "https://api.github.com/repos/catppuccin/discord/assignees{/user}", + "branches_url": "https://api.github.com/repos/catppuccin/discord/branches{/branch}", + "tags_url": "https://api.github.com/repos/catppuccin/discord/tags", + "blobs_url": "https://api.github.com/repos/catppuccin/discord/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/catppuccin/discord/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/catppuccin/discord/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/catppuccin/discord/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/catppuccin/discord/statuses/{sha}", + "languages_url": "https://api.github.com/repos/catppuccin/discord/languages", + "stargazers_url": "https://api.github.com/repos/catppuccin/discord/stargazers", + "contributors_url": "https://api.github.com/repos/catppuccin/discord/contributors", + "subscribers_url": "https://api.github.com/repos/catppuccin/discord/subscribers", + "subscription_url": "https://api.github.com/repos/catppuccin/discord/subscription", + "commits_url": "https://api.github.com/repos/catppuccin/discord/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/catppuccin/discord/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/catppuccin/discord/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/catppuccin/discord/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/catppuccin/discord/contents/{+path}", + "compare_url": "https://api.github.com/repos/catppuccin/discord/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/catppuccin/discord/merges", + "archive_url": "https://api.github.com/repos/catppuccin/discord/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/catppuccin/discord/downloads", + "issues_url": "https://api.github.com/repos/catppuccin/discord/issues{/number}", + "pulls_url": "https://api.github.com/repos/catppuccin/discord/pulls{/number}", + "milestones_url": "https://api.github.com/repos/catppuccin/discord/milestones{/number}", + "notifications_url": "https://api.github.com/repos/catppuccin/discord/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/catppuccin/discord/labels{/name}", + "releases_url": "https://api.github.com/repos/catppuccin/discord/releases{/id}", + "deployments_url": "https://api.github.com/repos/catppuccin/discord/deployments", + "created_at": "2022-01-24T17:11:38Z", + "updated_at": "2024-10-02T20:29:14Z", + "pushed_at": "2024-10-02T19:46:11Z", + "git_url": "git://github.com/catppuccin/discord.git", + "ssh_url": "git@github.com:catppuccin/discord.git", + "clone_url": "https://github.com/catppuccin/discord.git", + "svn_url": "https://github.com/catppuccin/discord", + "homepage": "", + "size": 15176, + "stargazers_count": 753, + "watchers_count": 753, + "language": "SCSS", + "has_issues": true, + "has_projects": false, + "has_downloads": true, + "has_wiki": false, + "has_pages": true, + "has_discussions": false, + "forks_count": 173, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 10, + "license": { + "key": "mit", + "name": "MIT License", + "spdx_id": "MIT", + "url": "https://api.github.com/licenses/mit", + "node_id": "MDc6TGljZW5zZTEz" + }, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [ + "betterdiscord-theme", + "catppuccin", + "discord", + "discord-theme", + "hacktoberfest", + "powercord-theme", + "stylus", + "vencord-theme" + ], + "visibility": "public", + "forks": 173, + "open_issues": 10, + "watchers": 753, + "default_branch": "main", + "custom_properties": { + "whiskers": "not_applicable" + } + }, + "organization": { + "login": "catppuccin", + "id": 93489351, + "node_id": "O_kgDOBZKIxw", + "url": "https://api.github.com/orgs/catppuccin", + "repos_url": "https://api.github.com/orgs/catppuccin/repos", + "events_url": "https://api.github.com/orgs/catppuccin/events", + "hooks_url": "https://api.github.com/orgs/catppuccin/hooks", + "issues_url": "https://api.github.com/orgs/catppuccin/issues", + "members_url": "https://api.github.com/orgs/catppuccin/members{/member}", + "public_members_url": "https://api.github.com/orgs/catppuccin/public_members{/member}", + "avatar_url": "https://avatars.githubusercontent.com/u/93489351?v=4", + "description": "Soothing pastel theme for the high-spirited!" + }, + "sender": { + "login": "uncenter", + "id": 47499684, + "node_id": "MDQ6VXNlcjQ3NDk5Njg0", + "avatar_url": "https://avatars.githubusercontent.com/u/47499684?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/uncenter", + "html_url": "https://github.com/uncenter", + "followers_url": "https://api.github.com/users/uncenter/followers", + "following_url": "https://api.github.com/users/uncenter/following{/other_user}", + "gists_url": "https://api.github.com/users/uncenter/gists{/gist_id}", + "starred_url": "https://api.github.com/users/uncenter/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/uncenter/subscriptions", + "organizations_url": "https://api.github.com/users/uncenter/orgs", + "repos_url": "https://api.github.com/users/uncenter/repos", + "events_url": "https://api.github.com/users/uncenter/events{/privacy}", + "received_events_url": "https://api.github.com/users/uncenter/received_events", + "type": "User", + "site_admin": false + } +} \ No newline at end of file diff --git a/snapshots/pull_request_review_comment/created.snap b/snapshots/pull_request_review_comment/created.snap new file mode 100644 index 0000000..081042e --- /dev/null +++ b/snapshots/pull_request_review_comment/created.snap @@ -0,0 +1,17 @@ +--- +source: src/events/pull_request_review_comment.rs +info: + author_name_length: 8 + colour_hex: "#89B4FA" + description_length: 70 + title_length: 106 +--- +embeds: + - author: + icon_url: "https://avatars.githubusercontent.com/u/47499684?v=4" + name: uncenter + url: "https://github.com/uncenter" + color: 9024762 + description: "More clarity about what you are clicking on, why it would install it. " + title: "[catppuccin/discord] New review comment on pull request #325: docs(README): update and improve usage steps" + url: "https://github.com/catppuccin/discord/pull/325#discussion_r1785288051" diff --git a/src/events.rs b/src/events.rs index be7343f..94293b9 100644 --- a/src/events.rs +++ b/src/events.rs @@ -14,6 +14,7 @@ mod issues; mod membership; mod pull_request; mod pull_request_review; +mod pull_request_review_comment; mod release; mod repository; @@ -53,6 +54,9 @@ fn begin_embed(event: WebhookEvent) -> RockdoveResult> { WebhookEventPayload::PullRequestReview(specifics) => { pull_request_review::make_embed(event, &specifics) } + WebhookEventPayload::PullRequestReviewComment(specifics) => { + pull_request_review_comment::make_embed(event, &specifics) + } WebhookEventPayload::Release(specifics) => release::make_embed(event, &specifics), WebhookEventPayload::Membership(specifics) => membership::make_embed(event, &specifics), _ => Ok(None), diff --git a/src/events/pull_request_review_comment.rs b/src/events/pull_request_review_comment.rs new file mode 100644 index 0000000..33750a0 --- /dev/null +++ b/src/events/pull_request_review_comment.rs @@ -0,0 +1,64 @@ +use octocrab::models::webhook_events::{ + payload::{ + PullRequestReviewCommentWebhookEventAction, PullRequestReviewCommentWebhookEventPayload, + }, + WebhookEvent, +}; + +use crate::{ + colors::PULL_REQUEST_COLOR, + embed_builder::EmbedBuilder, + errors::{RockdoveError, RockdoveResult}, +}; + +pub fn make_embed( + event: WebhookEvent, + specifics: &PullRequestReviewCommentWebhookEventPayload, +) -> RockdoveResult> { + if !matches!( + specifics.action, + PullRequestReviewCommentWebhookEventAction::Created + ) { + return Ok(None); + } + + let repo = event + .repository + .ok_or_else(|| RockdoveError::MissingField { + event_type: event.kind.clone(), + field: "repository", + })?; + + let mut embed = EmbedBuilder::default(); + + let repo_name = repo.full_name.unwrap_or(repo.name); + + embed.title(&format!( + "[{}] New review comment on pull request #{}: {}", + repo_name, + specifics.pull_request.number, + specifics + .pull_request + .title + .as_ref() + .ok_or_else(|| RockdoveError::MissingField { + event_type: event.kind.clone(), + field: "pull_request.title", + })?, + )); + embed.url(specifics.comment.html_url.as_str()); + embed.description(specifics.comment.body.as_str()); + embed.color(PULL_REQUEST_COLOR); + + Ok(Some(embed)) +} + +#[cfg(test)] +mod tests { + use crate::snapshot_test; + + #[test] + fn created() { + snapshot_test!("pull_request_review_comment", "created"); + } +}