diff --git a/fixtures/discussion/closed.json b/fixtures/discussion/closed.json new file mode 100644 index 0000000..a661981 --- /dev/null +++ b/fixtures/discussion/closed.json @@ -0,0 +1,210 @@ +{ + "action": "closed", + "discussion": { + "repository_url": "https://api.github.com/repos/catppuccin-rfc/polybar", + "category": { + "id": 42644248, + "node_id": "DIC_kwDOIVi3Lc4CirMY", + "repository_id": 559462189, + "emoji": ":speech_balloon:", + "name": "General", + "description": "Chat about anything and everything here", + "created_at": "2024-09-22T00:26:21.000+01:00", + "updated_at": "2024-09-22T00:26:21.000+01:00", + "slug": "general", + "is_answerable": false + }, + "answer_html_url": null, + "answer_chosen_at": null, + "answer_chosen_by": null, + "html_url": "https://github.com/catppuccin-rfc/polybar/discussions/19", + "id": 7215678, + "node_id": "D_kwDOIVi3Lc4Abho-", + "number": 19, + "title": "another test", + "user": { + "login": "sgoudham", + "id": 58985301, + "node_id": "MDQ6VXNlcjU4OTg1MzAx", + "avatar_url": "https://avatars.githubusercontent.com/u/58985301?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/sgoudham", + "html_url": "https://github.com/sgoudham", + "followers_url": "https://api.github.com/users/sgoudham/followers", + "following_url": "https://api.github.com/users/sgoudham/following{/other_user}", + "gists_url": "https://api.github.com/users/sgoudham/gists{/gist_id}", + "starred_url": "https://api.github.com/users/sgoudham/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/sgoudham/subscriptions", + "organizations_url": "https://api.github.com/users/sgoudham/orgs", + "repos_url": "https://api.github.com/users/sgoudham/repos", + "events_url": "https://api.github.com/users/sgoudham/events{/privacy}", + "received_events_url": "https://api.github.com/users/sgoudham/received_events", + "type": "User", + "site_admin": false + }, + "labels": [], + "state": "closed", + "state_reason": "resolved", + "locked": false, + "comments": 0, + "created_at": "2024-09-22T00:14:58Z", + "updated_at": "2024-09-22T00:25:46Z", + "author_association": "NONE", + "active_lock_reason": null, + "body": "test", + "reactions": { + "url": "https://api.github.com/repos/catppuccin-rfc/polybar/discussions/19/reactions", + "total_count": 0, + "+1": 0, + "-1": 0, + "laugh": 0, + "hooray": 0, + "confused": 0, + "heart": 0, + "rocket": 0, + "eyes": 0 + }, + "timeline_url": "https://api.github.com/repos/catppuccin-rfc/polybar/discussions/19/timeline" + }, + "repository": { + "id": 559462189, + "node_id": "R_kgDOIVi3LQ", + "name": "polybar", + "full_name": "catppuccin-rfc/polybar", + "private": false, + "owner": { + "login": "catppuccin-rfc", + "id": 111534585, + "node_id": "O_kgDOBqXh-Q", + "avatar_url": "https://avatars.githubusercontent.com/u/111534585?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/catppuccin-rfc", + "html_url": "https://github.com/catppuccin-rfc", + "followers_url": "https://api.github.com/users/catppuccin-rfc/followers", + "following_url": "https://api.github.com/users/catppuccin-rfc/following{/other_user}", + "gists_url": "https://api.github.com/users/catppuccin-rfc/gists{/gist_id}", + "starred_url": "https://api.github.com/users/catppuccin-rfc/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/catppuccin-rfc/subscriptions", + "organizations_url": "https://api.github.com/users/catppuccin-rfc/orgs", + "repos_url": "https://api.github.com/users/catppuccin-rfc/repos", + "events_url": "https://api.github.com/users/catppuccin-rfc/events{/privacy}", + "received_events_url": "https://api.github.com/users/catppuccin-rfc/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/catppuccin-rfc/polybar", + "description": "Demo repository for Catppuccin cli ", + "fork": false, + "url": "https://api.github.com/repos/catppuccin-rfc/polybar", + "forks_url": "https://api.github.com/repos/catppuccin-rfc/polybar/forks", + "keys_url": "https://api.github.com/repos/catppuccin-rfc/polybar/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/catppuccin-rfc/polybar/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/catppuccin-rfc/polybar/teams", + "hooks_url": "https://api.github.com/repos/catppuccin-rfc/polybar/hooks", + "issue_events_url": "https://api.github.com/repos/catppuccin-rfc/polybar/issues/events{/number}", + "events_url": "https://api.github.com/repos/catppuccin-rfc/polybar/events", + "assignees_url": "https://api.github.com/repos/catppuccin-rfc/polybar/assignees{/user}", + "branches_url": "https://api.github.com/repos/catppuccin-rfc/polybar/branches{/branch}", + "tags_url": "https://api.github.com/repos/catppuccin-rfc/polybar/tags", + "blobs_url": "https://api.github.com/repos/catppuccin-rfc/polybar/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/catppuccin-rfc/polybar/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/catppuccin-rfc/polybar/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/catppuccin-rfc/polybar/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/catppuccin-rfc/polybar/statuses/{sha}", + "languages_url": "https://api.github.com/repos/catppuccin-rfc/polybar/languages", + "stargazers_url": "https://api.github.com/repos/catppuccin-rfc/polybar/stargazers", + "contributors_url": "https://api.github.com/repos/catppuccin-rfc/polybar/contributors", + "subscribers_url": "https://api.github.com/repos/catppuccin-rfc/polybar/subscribers", + "subscription_url": "https://api.github.com/repos/catppuccin-rfc/polybar/subscription", + "commits_url": "https://api.github.com/repos/catppuccin-rfc/polybar/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/catppuccin-rfc/polybar/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/catppuccin-rfc/polybar/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/catppuccin-rfc/polybar/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/catppuccin-rfc/polybar/contents/{+path}", + "compare_url": "https://api.github.com/repos/catppuccin-rfc/polybar/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/catppuccin-rfc/polybar/merges", + "archive_url": "https://api.github.com/repos/catppuccin-rfc/polybar/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/catppuccin-rfc/polybar/downloads", + "issues_url": "https://api.github.com/repos/catppuccin-rfc/polybar/issues{/number}", + "pulls_url": "https://api.github.com/repos/catppuccin-rfc/polybar/pulls{/number}", + "milestones_url": "https://api.github.com/repos/catppuccin-rfc/polybar/milestones{/number}", + "notifications_url": "https://api.github.com/repos/catppuccin-rfc/polybar/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/catppuccin-rfc/polybar/labels{/name}", + "releases_url": "https://api.github.com/repos/catppuccin-rfc/polybar/releases{/id}", + "deployments_url": "https://api.github.com/repos/catppuccin-rfc/polybar/deployments", + "created_at": "2022-10-30T07:24:37Z", + "updated_at": "2024-09-19T21:08:02Z", + "pushed_at": "2024-09-21T23:24:09Z", + "git_url": "git://github.com/catppuccin-rfc/polybar.git", + "ssh_url": "git@github.com:catppuccin-rfc/polybar.git", + "clone_url": "https://github.com/catppuccin-rfc/polybar.git", + "svn_url": "https://github.com/catppuccin-rfc/polybar", + "homepage": null, + "size": 22, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "has_discussions": true, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 5, + "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": 5, + "watchers": 0, + "default_branch": "main", + "custom_properties": {} + }, + "organization": { + "login": "catppuccin-rfc", + "id": 111534585, + "node_id": "O_kgDOBqXh-Q", + "url": "https://api.github.com/orgs/catppuccin-rfc", + "repos_url": "https://api.github.com/orgs/catppuccin-rfc/repos", + "events_url": "https://api.github.com/orgs/catppuccin-rfc/events", + "hooks_url": "https://api.github.com/orgs/catppuccin-rfc/hooks", + "issues_url": "https://api.github.com/orgs/catppuccin-rfc/issues", + "members_url": "https://api.github.com/orgs/catppuccin-rfc/members{/member}", + "public_members_url": "https://api.github.com/orgs/catppuccin-rfc/public_members{/member}", + "avatar_url": "https://avatars.githubusercontent.com/u/111534585?v=4", + "description": "Soothing pastel experiments for the high-spirited!" + }, + "sender": { + "login": "sgoudham", + "id": 58985301, + "node_id": "MDQ6VXNlcjU4OTg1MzAx", + "avatar_url": "https://avatars.githubusercontent.com/u/58985301?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/sgoudham", + "html_url": "https://github.com/sgoudham", + "followers_url": "https://api.github.com/users/sgoudham/followers", + "following_url": "https://api.github.com/users/sgoudham/following{/other_user}", + "gists_url": "https://api.github.com/users/sgoudham/gists{/gist_id}", + "starred_url": "https://api.github.com/users/sgoudham/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/sgoudham/subscriptions", + "organizations_url": "https://api.github.com/users/sgoudham/orgs", + "repos_url": "https://api.github.com/users/sgoudham/repos", + "events_url": "https://api.github.com/users/sgoudham/events{/privacy}", + "received_events_url": "https://api.github.com/users/sgoudham/received_events", + "type": "User", + "site_admin": false + } +} \ No newline at end of file diff --git a/fixtures/discussion/created.json b/fixtures/discussion/created.json new file mode 100644 index 0000000..2f9388c --- /dev/null +++ b/fixtures/discussion/created.json @@ -0,0 +1,210 @@ +{ + "action": "created", + "discussion": { + "repository_url": "https://api.github.com/repos/catppuccin-rfc/polybar", + "category": { + "id": 42644248, + "node_id": "DIC_kwDOIVi3Lc4CirMY", + "repository_id": 559462189, + "emoji": ":speech_balloon:", + "name": "General", + "description": "Chat about anything and everything here", + "created_at": "2024-09-22T00:26:21.000+01:00", + "updated_at": "2024-09-22T00:26:21.000+01:00", + "slug": "general", + "is_answerable": false + }, + "answer_html_url": null, + "answer_chosen_at": null, + "answer_chosen_by": null, + "html_url": "https://github.com/catppuccin-rfc/polybar/discussions/19", + "id": 7215678, + "node_id": "D_kwDOIVi3Lc4Abho-", + "number": 19, + "title": "another test", + "user": { + "login": "sgoudham", + "id": 58985301, + "node_id": "MDQ6VXNlcjU4OTg1MzAx", + "avatar_url": "https://avatars.githubusercontent.com/u/58985301?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/sgoudham", + "html_url": "https://github.com/sgoudham", + "followers_url": "https://api.github.com/users/sgoudham/followers", + "following_url": "https://api.github.com/users/sgoudham/following{/other_user}", + "gists_url": "https://api.github.com/users/sgoudham/gists{/gist_id}", + "starred_url": "https://api.github.com/users/sgoudham/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/sgoudham/subscriptions", + "organizations_url": "https://api.github.com/users/sgoudham/orgs", + "repos_url": "https://api.github.com/users/sgoudham/repos", + "events_url": "https://api.github.com/users/sgoudham/events{/privacy}", + "received_events_url": "https://api.github.com/users/sgoudham/received_events", + "type": "User", + "site_admin": false + }, + "labels": [], + "state": "open", + "state_reason": null, + "locked": false, + "comments": 0, + "created_at": "2024-09-22T00:14:58Z", + "updated_at": "2024-09-22T00:14:58Z", + "author_association": "NONE", + "active_lock_reason": null, + "body": "test", + "reactions": { + "url": "https://api.github.com/repos/catppuccin-rfc/polybar/discussions/19/reactions", + "total_count": 0, + "+1": 0, + "-1": 0, + "laugh": 0, + "hooray": 0, + "confused": 0, + "heart": 0, + "rocket": 0, + "eyes": 0 + }, + "timeline_url": "https://api.github.com/repos/catppuccin-rfc/polybar/discussions/19/timeline" + }, + "repository": { + "id": 559462189, + "node_id": "R_kgDOIVi3LQ", + "name": "polybar", + "full_name": "catppuccin-rfc/polybar", + "private": false, + "owner": { + "login": "catppuccin-rfc", + "id": 111534585, + "node_id": "O_kgDOBqXh-Q", + "avatar_url": "https://avatars.githubusercontent.com/u/111534585?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/catppuccin-rfc", + "html_url": "https://github.com/catppuccin-rfc", + "followers_url": "https://api.github.com/users/catppuccin-rfc/followers", + "following_url": "https://api.github.com/users/catppuccin-rfc/following{/other_user}", + "gists_url": "https://api.github.com/users/catppuccin-rfc/gists{/gist_id}", + "starred_url": "https://api.github.com/users/catppuccin-rfc/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/catppuccin-rfc/subscriptions", + "organizations_url": "https://api.github.com/users/catppuccin-rfc/orgs", + "repos_url": "https://api.github.com/users/catppuccin-rfc/repos", + "events_url": "https://api.github.com/users/catppuccin-rfc/events{/privacy}", + "received_events_url": "https://api.github.com/users/catppuccin-rfc/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/catppuccin-rfc/polybar", + "description": "Demo repository for Catppuccin cli ", + "fork": false, + "url": "https://api.github.com/repos/catppuccin-rfc/polybar", + "forks_url": "https://api.github.com/repos/catppuccin-rfc/polybar/forks", + "keys_url": "https://api.github.com/repos/catppuccin-rfc/polybar/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/catppuccin-rfc/polybar/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/catppuccin-rfc/polybar/teams", + "hooks_url": "https://api.github.com/repos/catppuccin-rfc/polybar/hooks", + "issue_events_url": "https://api.github.com/repos/catppuccin-rfc/polybar/issues/events{/number}", + "events_url": "https://api.github.com/repos/catppuccin-rfc/polybar/events", + "assignees_url": "https://api.github.com/repos/catppuccin-rfc/polybar/assignees{/user}", + "branches_url": "https://api.github.com/repos/catppuccin-rfc/polybar/branches{/branch}", + "tags_url": "https://api.github.com/repos/catppuccin-rfc/polybar/tags", + "blobs_url": "https://api.github.com/repos/catppuccin-rfc/polybar/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/catppuccin-rfc/polybar/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/catppuccin-rfc/polybar/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/catppuccin-rfc/polybar/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/catppuccin-rfc/polybar/statuses/{sha}", + "languages_url": "https://api.github.com/repos/catppuccin-rfc/polybar/languages", + "stargazers_url": "https://api.github.com/repos/catppuccin-rfc/polybar/stargazers", + "contributors_url": "https://api.github.com/repos/catppuccin-rfc/polybar/contributors", + "subscribers_url": "https://api.github.com/repos/catppuccin-rfc/polybar/subscribers", + "subscription_url": "https://api.github.com/repos/catppuccin-rfc/polybar/subscription", + "commits_url": "https://api.github.com/repos/catppuccin-rfc/polybar/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/catppuccin-rfc/polybar/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/catppuccin-rfc/polybar/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/catppuccin-rfc/polybar/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/catppuccin-rfc/polybar/contents/{+path}", + "compare_url": "https://api.github.com/repos/catppuccin-rfc/polybar/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/catppuccin-rfc/polybar/merges", + "archive_url": "https://api.github.com/repos/catppuccin-rfc/polybar/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/catppuccin-rfc/polybar/downloads", + "issues_url": "https://api.github.com/repos/catppuccin-rfc/polybar/issues{/number}", + "pulls_url": "https://api.github.com/repos/catppuccin-rfc/polybar/pulls{/number}", + "milestones_url": "https://api.github.com/repos/catppuccin-rfc/polybar/milestones{/number}", + "notifications_url": "https://api.github.com/repos/catppuccin-rfc/polybar/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/catppuccin-rfc/polybar/labels{/name}", + "releases_url": "https://api.github.com/repos/catppuccin-rfc/polybar/releases{/id}", + "deployments_url": "https://api.github.com/repos/catppuccin-rfc/polybar/deployments", + "created_at": "2022-10-30T07:24:37Z", + "updated_at": "2024-09-19T21:08:02Z", + "pushed_at": "2024-09-21T23:24:09Z", + "git_url": "git://github.com/catppuccin-rfc/polybar.git", + "ssh_url": "git@github.com:catppuccin-rfc/polybar.git", + "clone_url": "https://github.com/catppuccin-rfc/polybar.git", + "svn_url": "https://github.com/catppuccin-rfc/polybar", + "homepage": null, + "size": 22, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "has_discussions": true, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 5, + "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": 5, + "watchers": 0, + "default_branch": "main", + "custom_properties": {} + }, + "organization": { + "login": "catppuccin-rfc", + "id": 111534585, + "node_id": "O_kgDOBqXh-Q", + "url": "https://api.github.com/orgs/catppuccin-rfc", + "repos_url": "https://api.github.com/orgs/catppuccin-rfc/repos", + "events_url": "https://api.github.com/orgs/catppuccin-rfc/events", + "hooks_url": "https://api.github.com/orgs/catppuccin-rfc/hooks", + "issues_url": "https://api.github.com/orgs/catppuccin-rfc/issues", + "members_url": "https://api.github.com/orgs/catppuccin-rfc/members{/member}", + "public_members_url": "https://api.github.com/orgs/catppuccin-rfc/public_members{/member}", + "avatar_url": "https://avatars.githubusercontent.com/u/111534585?v=4", + "description": "Soothing pastel experiments for the high-spirited!" + }, + "sender": { + "login": "sgoudham", + "id": 58985301, + "node_id": "MDQ6VXNlcjU4OTg1MzAx", + "avatar_url": "https://avatars.githubusercontent.com/u/58985301?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/sgoudham", + "html_url": "https://github.com/sgoudham", + "followers_url": "https://api.github.com/users/sgoudham/followers", + "following_url": "https://api.github.com/users/sgoudham/following{/other_user}", + "gists_url": "https://api.github.com/users/sgoudham/gists{/gist_id}", + "starred_url": "https://api.github.com/users/sgoudham/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/sgoudham/subscriptions", + "organizations_url": "https://api.github.com/users/sgoudham/orgs", + "repos_url": "https://api.github.com/users/sgoudham/repos", + "events_url": "https://api.github.com/users/sgoudham/events{/privacy}", + "received_events_url": "https://api.github.com/users/sgoudham/received_events", + "type": "User", + "site_admin": false + } +} \ No newline at end of file diff --git a/fixtures/discussion/reopened.json b/fixtures/discussion/reopened.json new file mode 100644 index 0000000..fef3399 --- /dev/null +++ b/fixtures/discussion/reopened.json @@ -0,0 +1,210 @@ +{ + "action": "reopened", + "discussion": { + "repository_url": "https://api.github.com/repos/catppuccin-rfc/polybar", + "category": { + "id": 42644248, + "node_id": "DIC_kwDOIVi3Lc4CirMY", + "repository_id": 559462189, + "emoji": ":speech_balloon:", + "name": "General", + "description": "Chat about anything and everything here", + "created_at": "2024-09-22T00:26:21.000+01:00", + "updated_at": "2024-09-22T00:26:21.000+01:00", + "slug": "general", + "is_answerable": false + }, + "answer_html_url": null, + "answer_chosen_at": null, + "answer_chosen_by": null, + "html_url": "https://github.com/catppuccin-rfc/polybar/discussions/19", + "id": 7215678, + "node_id": "D_kwDOIVi3Lc4Abho-", + "number": 19, + "title": "another test", + "user": { + "login": "sgoudham", + "id": 58985301, + "node_id": "MDQ6VXNlcjU4OTg1MzAx", + "avatar_url": "https://avatars.githubusercontent.com/u/58985301?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/sgoudham", + "html_url": "https://github.com/sgoudham", + "followers_url": "https://api.github.com/users/sgoudham/followers", + "following_url": "https://api.github.com/users/sgoudham/following{/other_user}", + "gists_url": "https://api.github.com/users/sgoudham/gists{/gist_id}", + "starred_url": "https://api.github.com/users/sgoudham/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/sgoudham/subscriptions", + "organizations_url": "https://api.github.com/users/sgoudham/orgs", + "repos_url": "https://api.github.com/users/sgoudham/repos", + "events_url": "https://api.github.com/users/sgoudham/events{/privacy}", + "received_events_url": "https://api.github.com/users/sgoudham/received_events", + "type": "User", + "site_admin": false + }, + "labels": [], + "state": "open", + "state_reason": "reopened", + "locked": false, + "comments": 0, + "created_at": "2024-09-22T00:14:58Z", + "updated_at": "2024-09-22T00:25:55Z", + "author_association": "NONE", + "active_lock_reason": null, + "body": "test", + "reactions": { + "url": "https://api.github.com/repos/catppuccin-rfc/polybar/discussions/19/reactions", + "total_count": 0, + "+1": 0, + "-1": 0, + "laugh": 0, + "hooray": 0, + "confused": 0, + "heart": 0, + "rocket": 0, + "eyes": 0 + }, + "timeline_url": "https://api.github.com/repos/catppuccin-rfc/polybar/discussions/19/timeline" + }, + "repository": { + "id": 559462189, + "node_id": "R_kgDOIVi3LQ", + "name": "polybar", + "full_name": "catppuccin-rfc/polybar", + "private": false, + "owner": { + "login": "catppuccin-rfc", + "id": 111534585, + "node_id": "O_kgDOBqXh-Q", + "avatar_url": "https://avatars.githubusercontent.com/u/111534585?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/catppuccin-rfc", + "html_url": "https://github.com/catppuccin-rfc", + "followers_url": "https://api.github.com/users/catppuccin-rfc/followers", + "following_url": "https://api.github.com/users/catppuccin-rfc/following{/other_user}", + "gists_url": "https://api.github.com/users/catppuccin-rfc/gists{/gist_id}", + "starred_url": "https://api.github.com/users/catppuccin-rfc/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/catppuccin-rfc/subscriptions", + "organizations_url": "https://api.github.com/users/catppuccin-rfc/orgs", + "repos_url": "https://api.github.com/users/catppuccin-rfc/repos", + "events_url": "https://api.github.com/users/catppuccin-rfc/events{/privacy}", + "received_events_url": "https://api.github.com/users/catppuccin-rfc/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/catppuccin-rfc/polybar", + "description": "Demo repository for Catppuccin cli ", + "fork": false, + "url": "https://api.github.com/repos/catppuccin-rfc/polybar", + "forks_url": "https://api.github.com/repos/catppuccin-rfc/polybar/forks", + "keys_url": "https://api.github.com/repos/catppuccin-rfc/polybar/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/catppuccin-rfc/polybar/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/catppuccin-rfc/polybar/teams", + "hooks_url": "https://api.github.com/repos/catppuccin-rfc/polybar/hooks", + "issue_events_url": "https://api.github.com/repos/catppuccin-rfc/polybar/issues/events{/number}", + "events_url": "https://api.github.com/repos/catppuccin-rfc/polybar/events", + "assignees_url": "https://api.github.com/repos/catppuccin-rfc/polybar/assignees{/user}", + "branches_url": "https://api.github.com/repos/catppuccin-rfc/polybar/branches{/branch}", + "tags_url": "https://api.github.com/repos/catppuccin-rfc/polybar/tags", + "blobs_url": "https://api.github.com/repos/catppuccin-rfc/polybar/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/catppuccin-rfc/polybar/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/catppuccin-rfc/polybar/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/catppuccin-rfc/polybar/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/catppuccin-rfc/polybar/statuses/{sha}", + "languages_url": "https://api.github.com/repos/catppuccin-rfc/polybar/languages", + "stargazers_url": "https://api.github.com/repos/catppuccin-rfc/polybar/stargazers", + "contributors_url": "https://api.github.com/repos/catppuccin-rfc/polybar/contributors", + "subscribers_url": "https://api.github.com/repos/catppuccin-rfc/polybar/subscribers", + "subscription_url": "https://api.github.com/repos/catppuccin-rfc/polybar/subscription", + "commits_url": "https://api.github.com/repos/catppuccin-rfc/polybar/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/catppuccin-rfc/polybar/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/catppuccin-rfc/polybar/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/catppuccin-rfc/polybar/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/catppuccin-rfc/polybar/contents/{+path}", + "compare_url": "https://api.github.com/repos/catppuccin-rfc/polybar/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/catppuccin-rfc/polybar/merges", + "archive_url": "https://api.github.com/repos/catppuccin-rfc/polybar/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/catppuccin-rfc/polybar/downloads", + "issues_url": "https://api.github.com/repos/catppuccin-rfc/polybar/issues{/number}", + "pulls_url": "https://api.github.com/repos/catppuccin-rfc/polybar/pulls{/number}", + "milestones_url": "https://api.github.com/repos/catppuccin-rfc/polybar/milestones{/number}", + "notifications_url": "https://api.github.com/repos/catppuccin-rfc/polybar/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/catppuccin-rfc/polybar/labels{/name}", + "releases_url": "https://api.github.com/repos/catppuccin-rfc/polybar/releases{/id}", + "deployments_url": "https://api.github.com/repos/catppuccin-rfc/polybar/deployments", + "created_at": "2022-10-30T07:24:37Z", + "updated_at": "2024-09-19T21:08:02Z", + "pushed_at": "2024-09-21T23:24:09Z", + "git_url": "git://github.com/catppuccin-rfc/polybar.git", + "ssh_url": "git@github.com:catppuccin-rfc/polybar.git", + "clone_url": "https://github.com/catppuccin-rfc/polybar.git", + "svn_url": "https://github.com/catppuccin-rfc/polybar", + "homepage": null, + "size": 22, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "has_discussions": true, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 5, + "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": 5, + "watchers": 0, + "default_branch": "main", + "custom_properties": {} + }, + "organization": { + "login": "catppuccin-rfc", + "id": 111534585, + "node_id": "O_kgDOBqXh-Q", + "url": "https://api.github.com/orgs/catppuccin-rfc", + "repos_url": "https://api.github.com/orgs/catppuccin-rfc/repos", + "events_url": "https://api.github.com/orgs/catppuccin-rfc/events", + "hooks_url": "https://api.github.com/orgs/catppuccin-rfc/hooks", + "issues_url": "https://api.github.com/orgs/catppuccin-rfc/issues", + "members_url": "https://api.github.com/orgs/catppuccin-rfc/members{/member}", + "public_members_url": "https://api.github.com/orgs/catppuccin-rfc/public_members{/member}", + "avatar_url": "https://avatars.githubusercontent.com/u/111534585?v=4", + "description": "Soothing pastel experiments for the high-spirited!" + }, + "sender": { + "login": "sgoudham", + "id": 58985301, + "node_id": "MDQ6VXNlcjU4OTg1MzAx", + "avatar_url": "https://avatars.githubusercontent.com/u/58985301?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/sgoudham", + "html_url": "https://github.com/sgoudham", + "followers_url": "https://api.github.com/users/sgoudham/followers", + "following_url": "https://api.github.com/users/sgoudham/following{/other_user}", + "gists_url": "https://api.github.com/users/sgoudham/gists{/gist_id}", + "starred_url": "https://api.github.com/users/sgoudham/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/sgoudham/subscriptions", + "organizations_url": "https://api.github.com/users/sgoudham/orgs", + "repos_url": "https://api.github.com/users/sgoudham/repos", + "events_url": "https://api.github.com/users/sgoudham/events{/privacy}", + "received_events_url": "https://api.github.com/users/sgoudham/received_events", + "type": "User", + "site_admin": false + } +} \ No newline at end of file diff --git a/snapshots/discussion/closed.snap b/snapshots/discussion/closed.snap new file mode 100644 index 0000000..d70fcb9 --- /dev/null +++ b/snapshots/discussion/closed.snap @@ -0,0 +1,17 @@ +--- +source: src/events/discussion.rs +info: + author_name_length: 8 + colour_hex: "#FAB387" + description_length: 4 + title_length: 60 +--- +embeds: + - author: + icon_url: "https://avatars.githubusercontent.com/u/58985301?v=4" + name: sgoudham + url: "https://github.com/sgoudham" + color: 16429959 + description: test + title: "[catppuccin-rfc/polybar] Discussion closed: #19 another test" + url: "https://github.com/catppuccin-rfc/polybar/discussions/19" diff --git a/snapshots/discussion/created.snap b/snapshots/discussion/created.snap new file mode 100644 index 0000000..bd71276 --- /dev/null +++ b/snapshots/discussion/created.snap @@ -0,0 +1,17 @@ +--- +source: src/events/discussion.rs +info: + author_name_length: 8 + colour_hex: "#FAB387" + description_length: 4 + title_length: 61 +--- +embeds: + - author: + icon_url: "https://avatars.githubusercontent.com/u/58985301?v=4" + name: sgoudham + url: "https://github.com/sgoudham" + color: 16429959 + description: test + title: "[catppuccin-rfc/polybar] Discussion created: #19 another test" + url: "https://github.com/catppuccin-rfc/polybar/discussions/19" diff --git a/snapshots/discussion/reopened.snap b/snapshots/discussion/reopened.snap new file mode 100644 index 0000000..2a52b4a --- /dev/null +++ b/snapshots/discussion/reopened.snap @@ -0,0 +1,17 @@ +--- +source: src/events/discussion.rs +info: + author_name_length: 8 + colour_hex: "#FAB387" + description_length: 4 + title_length: 62 +--- +embeds: + - author: + icon_url: "https://avatars.githubusercontent.com/u/58985301?v=4" + name: sgoudham + url: "https://github.com/sgoudham" + color: 16429959 + description: test + title: "[catppuccin-rfc/polybar] Discussion reopened: #19 another test" + url: "https://github.com/catppuccin-rfc/polybar/discussions/19" diff --git a/src/events.rs b/src/events.rs index ce11d3b..8d84665 100644 --- a/src/events.rs +++ b/src/events.rs @@ -1,4 +1,5 @@ pub mod commit_comment; +pub mod discussion; pub mod issue_comment; pub mod issues; pub mod membership; diff --git a/src/events/discussion.rs b/src/events/discussion.rs new file mode 100644 index 0000000..1f1ee12 --- /dev/null +++ b/src/events/discussion.rs @@ -0,0 +1,120 @@ +use octocrab::models::webhook_events::{ + payload::{DiscussionWebhookEventAction, DiscussionWebhookEventPayload}, + WebhookEvent, +}; + +use crate::{embed_builder::EmbedBuilder, DISCUSSION_COLOR}; + +pub fn make_discussion_embed( + event: WebhookEvent, + specifics: &DiscussionWebhookEventPayload, +) -> Option { + let repo = event + .repository + .expect("discussion events should always have a repository"); + + let mut embed = EmbedBuilder::default(); + + let repo_name = repo.full_name.unwrap_or(repo.name); + + embed.title(&format!( + "[{}] Discussion {}: #{} {}", + repo_name, + match specifics.action { + DiscussionWebhookEventAction::Created => "created".to_string(), + DiscussionWebhookEventAction::Closed => "closed".to_string(), + DiscussionWebhookEventAction::Reopened => "reopened".to_string(), + _ => { + return None; + } + }, + specifics + .discussion + .get("number") + .expect("discussion should always have a number"), + specifics + .discussion + .get("title") + .expect("discussion should always have a title") + .as_str() + .expect("discussion title should always be a string"), + )); + + embed.url( + specifics + .discussion + .get("html_url") + .expect("discussion should always have an html url") + .as_str() + .expect("discussion html url should always be a string"), + ); + + embed.description( + specifics + .discussion + .get("body") + .expect("discussion should always have a body") + .as_str() + .expect("discussion body should always be a string"), + ); + + embed.color(DISCUSSION_COLOR); + + Some(embed) +} + +#[cfg(test)] +mod tests { + use crate::{ + make_embed, + tests::{embed_context, TestConfig}, + }; + + #[test] + fn created() { + let payload = include_str!("../../fixtures/discussion/created.json"); + let TestConfig { + event, + mut settings, + } = TestConfig::new("discussion", payload); + + let embed = make_embed(event) + .expect("make_embed should succeed") + .expect("event fixture can be turned into an embed"); + + settings.set_info(&embed_context(&embed)); + settings.bind(|| insta::assert_yaml_snapshot!(embed)); + } + + #[test] + fn closed() { + let payload = include_str!("../../fixtures/discussion/closed.json"); + let TestConfig { + event, + mut settings, + } = TestConfig::new("discussion", payload); + + let embed = make_embed(event) + .expect("make_embed should succeed") + .expect("event fixture can be turned into an embed"); + + settings.set_info(&embed_context(&embed)); + settings.bind(|| insta::assert_yaml_snapshot!(embed)); + } + + #[test] + fn reopened() { + let payload = include_str!("../../fixtures/discussion/reopened.json"); + let TestConfig { + event, + mut settings, + } = TestConfig::new("discussion", payload); + + let embed = make_embed(event) + .expect("make_embed should succeed") + .expect("event fixture can be turned into an embed"); + + settings.set_info(&embed_context(&embed)); + settings.bind(|| insta::assert_yaml_snapshot!(embed)); + } +} diff --git a/src/main.rs b/src/main.rs index 051c45a..7dfd18a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,10 +10,11 @@ use axum::{ }; use axum_github_webhook_extract::{GithubEvent, GithubToken}; use events::{ - commit_comment::make_commit_comment_embed, issue_comment::make_issue_comment_embed, - issues::make_issues_embed, membership::make_membership_embed, - pull_request::make_pull_request_embed, pull_request_review::make_pull_request_review_embed, - release::make_release_embed, repository::make_repository_embed, + commit_comment::make_commit_comment_embed, discussion::make_discussion_embed, + issue_comment::make_issue_comment_embed, issues::make_issues_embed, + membership::make_membership_embed, pull_request::make_pull_request_embed, + pull_request_review::make_pull_request_review_embed, release::make_release_embed, + repository::make_repository_embed, }; use octocrab::models::webhook_events::{WebhookEvent, WebhookEventPayload}; use tower_http::trace::{DefaultMakeSpan, DefaultOnResponse, TraceLayer}; @@ -23,6 +24,7 @@ mod embed_builder; const COLORS: catppuccin::FlavorColors = catppuccin::PALETTE.mocha.colors; pub const ISSUE_COLOR: catppuccin::Color = COLORS.green; +pub const DISCUSSION_COLOR: catppuccin::Color = COLORS.peach; pub const PULL_REQUEST_COLOR: catppuccin::Color = COLORS.blue; pub const REPO_COLOR: catppuccin::Color = COLORS.yellow; pub const RELEASE_COLOR: catppuccin::Color = COLORS.mauve; @@ -152,6 +154,7 @@ fn make_embed(event: WebhookEvent) -> anyhow::Result> let Some(mut embed) = (match event.specific.clone() { WebhookEventPayload::Repository(specifics) => make_repository_embed(event, &specifics), + WebhookEventPayload::Discussion(specifics) => make_discussion_embed(event, &specifics), WebhookEventPayload::Issues(specifics) => make_issues_embed(event, &specifics), WebhookEventPayload::PullRequest(specifics) => make_pull_request_embed(event, &specifics), WebhookEventPayload::IssueComment(specifics) => make_issue_comment_embed(event, &specifics),