From 0af48bd9c295204f59d9c9c2a4e251442c377760 Mon Sep 17 00:00:00 2001 From: Jerboa-app Date: Sun, 4 Feb 2024 09:45:24 +0000 Subject: [PATCH 1/4] adds fork event --- src/web/github/response/github_filter.rs | 6 +- src/web/github/response/github_forked.rs | 76 +++++++ src/web/github/response/mod.rs | 1 + tests/common/mod.rs | 262 ++++++++++++++++++++++- tests/event_config.json | 20 ++ tests/test_fork_payload.rs | 22 ++ 6 files changed, 385 insertions(+), 2 deletions(-) create mode 100644 src/web/github/response/github_forked.rs create mode 100644 tests/test_fork_payload.rs diff --git a/src/web/github/response/github_filter.rs b/src/web/github/response/github_filter.rs index e00f4a2..b2226be 100644 --- a/src/web/github/response/github_filter.rs +++ b/src/web/github/response/github_filter.rs @@ -33,7 +33,7 @@ response:: use crate::web::is_authentic; -use super::github_ping; +use super::{github_forked, github_ping}; /// Middleware to detect, verify, and respond to a github POST request from a /// Github webhook @@ -147,6 +147,10 @@ where B: axum::body::HttpBody github_ping::X_GTIHUB_EVENT => { Box::new(github_ping::GithubPing::new()) + }, + github_forked::X_GTIHUB_EVENT => + { + Box::new(github_forked::GithubForked::new()) } _ => return Ok(StatusCode::CONTINUE.into_response()) } diff --git a/src/web/github/response/github_forked.rs b/src/web/github/response/github_forked.rs new file mode 100644 index 0000000..91a7eb0 --- /dev/null +++ b/src/web/github/response/github_forked.rs @@ -0,0 +1,76 @@ +use std::collections::HashMap; + +use axum::http::{HeaderMap, StatusCode}; +use axum::body::Bytes; + +use crate::web::discord; +use crate::web::event::{EventConfig, read_config, select_template, expand_template}; +use crate::web::event::Event; + +use super::github_filter::github_request_is_authentic; + +pub const X_GTIHUB_EVENT: &str = "fork"; + +pub struct GithubForked +{ + config: EventConfig +} + +impl GithubForked +{ + pub fn new() -> GithubForked + { + GithubForked { config: EventConfig::new() } + } +} + +impl Event for GithubForked +{ + fn get_token(&self) -> String + { + self.config.get_token() + } + + fn get_end_point(&self) -> discord::request::model::Webhook + { + self.config.get_end_point() + } + + fn load_config(&mut self) + { + self.config = read_config("github_forked"); + } + + fn is_authentic(&self, headers: HeaderMap, body: Bytes) -> StatusCode + { + return github_request_is_authentic(self.get_token(), headers, body); + } + + fn into_response(&self, data: HashMap) -> (Option, StatusCode) + { + + let template = select_template(self.config.get_templates(), data.clone()); + + let template = if data["repository"]["name"].is_string() + { + match data["repository"]["name"] == "Pulse" + { + true => template.replacen("", "Pulse (that's me!)", 1), + false => {template} + } + } + else + { + return (None, StatusCode::INTERNAL_SERVER_ERROR) + }; + + crate::debug(format!("Fork from {:?}", data["sender"]["login"]), None); + + if self.config.silent_on_private_repos() && data["repository"]["private"].as_bool().is_some_and(|x|x) + { + return (None, StatusCode::OK); + } + + (expand_template(template, data), StatusCode::OK) + } +} \ No newline at end of file diff --git a/src/web/github/response/mod.rs b/src/web/github/response/mod.rs index 7a351fb..3b273d0 100644 --- a/src/web/github/response/mod.rs +++ b/src/web/github/response/mod.rs @@ -3,4 +3,5 @@ pub mod github_release; pub mod github_starred; pub mod github_pushed; pub mod github_ping; +pub mod github_forked; pub mod model; \ No newline at end of file diff --git a/tests/common/mod.rs b/tests/common/mod.rs index 8d829cc..236e67f 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -995,4 +995,264 @@ pub const STAR_DELETED_PAYLOAD: &str = r#" "site_admin": false } } -"#; \ No newline at end of file +"#; + +pub const FORKED_PAYLOAD: &str = r#" +{ + "forkee": { + "id": 752584241, + "node_id": "R_kgDOLNuGMQ", + "name": "Pulse", + "full_name": "Jerboa-app/Pulse", + "private": false, + "owner": { + "login": "Jerboa-app", + "id": 84378622, + "node_id": "MDQ6VXNlcjg0Mzc4NjIy", + "avatar_url": "https://avatars.githubusercontent.com/u/84378622?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/Jerboa-app", + "html_url": "https://github.com/Jerboa-app", + "followers_url": "https://api.github.com/users/Jerboa-app/followers", + "following_url": "https://api.github.com/users/Jerboa-app/following{/other_user}", + "gists_url": "https://api.github.com/users/Jerboa-app/gists{/gist_id}", + "starred_url": "https://api.github.com/users/Jerboa-app/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/Jerboa-app/subscriptions", + "organizations_url": "https://api.github.com/users/Jerboa-app/orgs", + "repos_url": "https://api.github.com/users/Jerboa-app/repos", + "events_url": "https://api.github.com/users/Jerboa-app/events{/privacy}", + "received_events_url": "https://api.github.com/users/Jerboa-app/received_events", + "type": "User", + "site_admin": false + }, + "html_url": "https://github.com/Jerboa-app/Pulse", + "description": "Discord webhook bot posting messages on Github events | hot-loadable formatting templates; string interpolation in templates for arbitrary JSON bodies", + "fork": true, + "url": "https://api.github.com/repos/Jerboa-app/Pulse", + "forks_url": "https://api.github.com/repos/Jerboa-app/Pulse/forks", + "keys_url": "https://api.github.com/repos/Jerboa-app/Pulse/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/Jerboa-app/Pulse/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/Jerboa-app/Pulse/teams", + "hooks_url": "https://api.github.com/repos/Jerboa-app/Pulse/hooks", + "issue_events_url": "https://api.github.com/repos/Jerboa-app/Pulse/issues/events{/number}", + "events_url": "https://api.github.com/repos/Jerboa-app/Pulse/events", + "assignees_url": "https://api.github.com/repos/Jerboa-app/Pulse/assignees{/user}", + "branches_url": "https://api.github.com/repos/Jerboa-app/Pulse/branches{/branch}", + "tags_url": "https://api.github.com/repos/Jerboa-app/Pulse/tags", + "blobs_url": "https://api.github.com/repos/Jerboa-app/Pulse/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/Jerboa-app/Pulse/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/Jerboa-app/Pulse/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/Jerboa-app/Pulse/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/Jerboa-app/Pulse/statuses/{sha}", + "languages_url": "https://api.github.com/repos/Jerboa-app/Pulse/languages", + "stargazers_url": "https://api.github.com/repos/Jerboa-app/Pulse/stargazers", + "contributors_url": "https://api.github.com/repos/Jerboa-app/Pulse/contributors", + "subscribers_url": "https://api.github.com/repos/Jerboa-app/Pulse/subscribers", + "subscription_url": "https://api.github.com/repos/Jerboa-app/Pulse/subscription", + "commits_url": "https://api.github.com/repos/Jerboa-app/Pulse/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/Jerboa-app/Pulse/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/Jerboa-app/Pulse/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/Jerboa-app/Pulse/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/Jerboa-app/Pulse/contents/{+path}", + "compare_url": "https://api.github.com/repos/Jerboa-app/Pulse/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/Jerboa-app/Pulse/merges", + "archive_url": "https://api.github.com/repos/Jerboa-app/Pulse/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/Jerboa-app/Pulse/downloads", + "issues_url": "https://api.github.com/repos/Jerboa-app/Pulse/issues{/number}", + "pulls_url": "https://api.github.com/repos/Jerboa-app/Pulse/pulls{/number}", + "milestones_url": "https://api.github.com/repos/Jerboa-app/Pulse/milestones{/number}", + "notifications_url": "https://api.github.com/repos/Jerboa-app/Pulse/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/Jerboa-app/Pulse/labels{/name}", + "releases_url": "https://api.github.com/repos/Jerboa-app/Pulse/releases{/id}", + "deployments_url": "https://api.github.com/repos/Jerboa-app/Pulse/deployments", + "created_at": "2024-02-04T09:21:49Z", + "updated_at": "2024-02-04T09:21:50Z", + "pushed_at": "2024-01-26T11:20:24Z", + "git_url": "git://github.com/Jerboa-app/Pulse.git", + "ssh_url": "git@github.com:Jerboa-app/Pulse.git", + "clone_url": "https://github.com/Jerboa-app/Pulse.git", + "svn_url": "https://github.com/Jerboa-app/Pulse", + "homepage": "", + "size": 102, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "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": null, + "allow_forking": true, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [ + + ], + "visibility": "public", + "forks": 0, + "open_issues": 0, + "watchers": 0, + "default_branch": "main", + "public": true + }, + "repository": { + "id": 738663171, + "node_id": "R_kgDOLAcbAw", + "name": "Pulse", + "full_name": "JerboaBurrow/Pulse", + "private": false, + "owner": { + "login": "JerboaBurrow", + "id": 109722648, + "node_id": "O_kgDOBoo8GA", + "avatar_url": "https://avatars.githubusercontent.com/u/109722648?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/JerboaBurrow", + "html_url": "https://github.com/JerboaBurrow", + "followers_url": "https://api.github.com/users/JerboaBurrow/followers", + "following_url": "https://api.github.com/users/JerboaBurrow/following{/other_user}", + "gists_url": "https://api.github.com/users/JerboaBurrow/gists{/gist_id}", + "starred_url": "https://api.github.com/users/JerboaBurrow/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/JerboaBurrow/subscriptions", + "organizations_url": "https://api.github.com/users/JerboaBurrow/orgs", + "repos_url": "https://api.github.com/users/JerboaBurrow/repos", + "events_url": "https://api.github.com/users/JerboaBurrow/events{/privacy}", + "received_events_url": "https://api.github.com/users/JerboaBurrow/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/JerboaBurrow/Pulse", + "description": "Discord webhook bot posting messages on Github events | hot-loadable formatting templates; string interpolation in templates for arbitrary JSON bodies", + "fork": false, + "url": "https://api.github.com/repos/JerboaBurrow/Pulse", + "forks_url": "https://api.github.com/repos/JerboaBurrow/Pulse/forks", + "keys_url": "https://api.github.com/repos/JerboaBurrow/Pulse/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/JerboaBurrow/Pulse/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/JerboaBurrow/Pulse/teams", + "hooks_url": "https://api.github.com/repos/JerboaBurrow/Pulse/hooks", + "issue_events_url": "https://api.github.com/repos/JerboaBurrow/Pulse/issues/events{/number}", + "events_url": "https://api.github.com/repos/JerboaBurrow/Pulse/events", + "assignees_url": "https://api.github.com/repos/JerboaBurrow/Pulse/assignees{/user}", + "branches_url": "https://api.github.com/repos/JerboaBurrow/Pulse/branches{/branch}", + "tags_url": "https://api.github.com/repos/JerboaBurrow/Pulse/tags", + "blobs_url": "https://api.github.com/repos/JerboaBurrow/Pulse/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/JerboaBurrow/Pulse/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/JerboaBurrow/Pulse/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/JerboaBurrow/Pulse/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/JerboaBurrow/Pulse/statuses/{sha}", + "languages_url": "https://api.github.com/repos/JerboaBurrow/Pulse/languages", + "stargazers_url": "https://api.github.com/repos/JerboaBurrow/Pulse/stargazers", + "contributors_url": "https://api.github.com/repos/JerboaBurrow/Pulse/contributors", + "subscribers_url": "https://api.github.com/repos/JerboaBurrow/Pulse/subscribers", + "subscription_url": "https://api.github.com/repos/JerboaBurrow/Pulse/subscription", + "commits_url": "https://api.github.com/repos/JerboaBurrow/Pulse/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/JerboaBurrow/Pulse/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/JerboaBurrow/Pulse/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/JerboaBurrow/Pulse/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/JerboaBurrow/Pulse/contents/{+path}", + "compare_url": "https://api.github.com/repos/JerboaBurrow/Pulse/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/JerboaBurrow/Pulse/merges", + "archive_url": "https://api.github.com/repos/JerboaBurrow/Pulse/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/JerboaBurrow/Pulse/downloads", + "issues_url": "https://api.github.com/repos/JerboaBurrow/Pulse/issues{/number}", + "pulls_url": "https://api.github.com/repos/JerboaBurrow/Pulse/pulls{/number}", + "milestones_url": "https://api.github.com/repos/JerboaBurrow/Pulse/milestones{/number}", + "notifications_url": "https://api.github.com/repos/JerboaBurrow/Pulse/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/JerboaBurrow/Pulse/labels{/name}", + "releases_url": "https://api.github.com/repos/JerboaBurrow/Pulse/releases{/id}", + "deployments_url": "https://api.github.com/repos/JerboaBurrow/Pulse/deployments", + "created_at": "2024-01-03T18:47:03Z", + "updated_at": "2024-01-18T14:21:05Z", + "pushed_at": "2024-01-26T11:20:24Z", + "git_url": "git://github.com/JerboaBurrow/Pulse.git", + "ssh_url": "git@github.com:JerboaBurrow/Pulse.git", + "clone_url": "https://github.com/JerboaBurrow/Pulse.git", + "svn_url": "https://github.com/JerboaBurrow/Pulse", + "homepage": "", + "size": 102, + "stargazers_count": 0, + "watchers_count": 0, + "language": "Rust", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": false, + "has_pages": false, + "has_discussions": false, + "forks_count": 1, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 3, + "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": [ + "bot", + "discord", + "github", + "http", + "https", + "rust", + "server", + "webdev", + "webhook" + ], + "visibility": "public", + "forks": 1, + "open_issues": 3, + "watchers": 0, + "default_branch": "main", + "custom_properties": { + + } + }, + "organization": { + "login": "JerboaBurrow", + "id": 109722648, + "node_id": "O_kgDOBoo8GA", + "url": "https://api.github.com/orgs/JerboaBurrow", + "repos_url": "https://api.github.com/orgs/JerboaBurrow/repos", + "events_url": "https://api.github.com/orgs/JerboaBurrow/events", + "hooks_url": "https://api.github.com/orgs/JerboaBurrow/hooks", + "issues_url": "https://api.github.com/orgs/JerboaBurrow/issues", + "members_url": "https://api.github.com/orgs/JerboaBurrow/members{/member}", + "public_members_url": "https://api.github.com/orgs/JerboaBurrow/public_members{/member}", + "avatar_url": "https://avatars.githubusercontent.com/u/109722648?v=4", + "description": "Creating apps and games" + }, + "sender": { + "login": "Jerboa-app", + "id": 84378622, + "node_id": "MDQ6VXNlcjg0Mzc4NjIy", + "avatar_url": "https://avatars.githubusercontent.com/u/84378622?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/Jerboa-app", + "html_url": "https://github.com/Jerboa-app", + "followers_url": "https://api.github.com/users/Jerboa-app/followers", + "following_url": "https://api.github.com/users/Jerboa-app/following{/other_user}", + "gists_url": "https://api.github.com/users/Jerboa-app/gists{/gist_id}", + "starred_url": "https://api.github.com/users/Jerboa-app/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/Jerboa-app/subscriptions", + "organizations_url": "https://api.github.com/users/Jerboa-app/orgs", + "repos_url": "https://api.github.com/users/Jerboa-app/repos", + "events_url": "https://api.github.com/users/Jerboa-app/events{/privacy}", + "received_events_url": "https://api.github.com/users/Jerboa-app/received_events", + "type": "User", + "site_admin": false + } +}"#; \ No newline at end of file diff --git a/tests/event_config.json b/tests/event_config.json index 3ae8a0c..43e9748 100644 --- a/tests/event_config.json +++ b/tests/event_config.json @@ -68,5 +68,25 @@ ], "end_point": { "addr": "" }, "dont_message_on_private_repos": true + }, + "github_forked": + { + "hmac": "this_is_secret_number_one", + "templates": + [ + { + "criteria": + [ + { + "check_value_path": "", + "check_value_in": [], + "check_value_not_in": [] + } + ], + "body": "New fork!" + } + ], + "end_point": { "addr": "" }, + "dont_message_on_private_repos": true } } \ No newline at end of file diff --git a/tests/test_fork_payload.rs b/tests/test_fork_payload.rs new file mode 100644 index 0000000..313311c --- /dev/null +++ b/tests/test_fork_payload.rs @@ -0,0 +1,22 @@ +mod common; + +#[cfg(test)] +mod test_fork_payload +{ + use std::collections::HashMap; + + use regex::Regex; + + use crate::common::FORKED_PAYLOAD; + + #[test] + fn deserialise_json() + { + let parsed_data: HashMap = serde_json::from_str(FORKED_PAYLOAD).unwrap(); + + assert_eq!(parsed_data["forkee"]["name"], "Pulse"); + + assert_eq!(parsed_data["repository"]["name"], "Pulse"); + } + +} \ No newline at end of file From a5847bbb714768303b02035df2fab47b43663a53 Mon Sep 17 00:00:00 2001 From: Jerboa-app Date: Sun, 4 Feb 2024 09:52:53 +0000 Subject: [PATCH 2/4] adds pr --- src/web/github/response/github_filter.rs | 6 +- .../github/response/github_pull_request.rs | 76 +++++++++++++++++++ src/web/github/response/mod.rs | 1 + tests/event_config.json | 20 +++++ 4 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 src/web/github/response/github_pull_request.rs diff --git a/src/web/github/response/github_filter.rs b/src/web/github/response/github_filter.rs index b2226be..44a9e53 100644 --- a/src/web/github/response/github_filter.rs +++ b/src/web/github/response/github_filter.rs @@ -33,7 +33,7 @@ response:: use crate::web::is_authentic; -use super::{github_forked, github_ping}; +use super::{github_forked, github_ping, github_pull_request}; /// Middleware to detect, verify, and respond to a github POST request from a /// Github webhook @@ -151,6 +151,10 @@ where B: axum::body::HttpBody github_forked::X_GTIHUB_EVENT => { Box::new(github_forked::GithubForked::new()) + }, + github_pull_request::X_GTIHUB_EVENT => + { + Box::new(github_pull_request::GithubPullRequest::new()) } _ => return Ok(StatusCode::CONTINUE.into_response()) } diff --git a/src/web/github/response/github_pull_request.rs b/src/web/github/response/github_pull_request.rs new file mode 100644 index 0000000..b374e71 --- /dev/null +++ b/src/web/github/response/github_pull_request.rs @@ -0,0 +1,76 @@ +use std::collections::HashMap; + +use axum::http::{HeaderMap, StatusCode}; +use axum::body::Bytes; + +use crate::web::discord; +use crate::web::event::{EventConfig, read_config, select_template, expand_template}; +use crate::web::event::Event; + +use super::github_filter::github_request_is_authentic; + +pub const X_GTIHUB_EVENT: &str = "pull_request"; + +pub struct GithubPullRequest +{ + config: EventConfig +} + +impl GithubPullRequest +{ + pub fn new() -> GithubPullRequest + { + GithubPullRequest { config: EventConfig::new() } + } +} + +impl Event for GithubPullRequest +{ + fn get_token(&self) -> String + { + self.config.get_token() + } + + fn get_end_point(&self) -> discord::request::model::Webhook + { + self.config.get_end_point() + } + + fn load_config(&mut self) + { + self.config = read_config("github_pull_request"); + } + + fn is_authentic(&self, headers: HeaderMap, body: Bytes) -> StatusCode + { + return github_request_is_authentic(self.get_token(), headers, body); + } + + fn into_response(&self, data: HashMap) -> (Option, StatusCode) + { + + let template = select_template(self.config.get_templates(), data.clone()); + + let template = if data["repository"]["name"].is_string() + { + match data["repository"]["name"] == "Pulse" + { + true => template.replacen("", "Pulse (that's me!)", 1), + false => {template} + } + } + else + { + return (None, StatusCode::INTERNAL_SERVER_ERROR) + }; + + crate::debug(format!("pull_request from {:?}", data["sender"]["login"]), None); + + if self.config.silent_on_private_repos() && data["repository"]["private"].as_bool().is_some_and(|x|x) + { + return (None, StatusCode::OK); + } + + (expand_template(template, data), StatusCode::OK) + } +} \ No newline at end of file diff --git a/src/web/github/response/mod.rs b/src/web/github/response/mod.rs index 3b273d0..43dcf50 100644 --- a/src/web/github/response/mod.rs +++ b/src/web/github/response/mod.rs @@ -4,4 +4,5 @@ pub mod github_starred; pub mod github_pushed; pub mod github_ping; pub mod github_forked; +pub mod github_pull_request; pub mod model; \ No newline at end of file diff --git a/tests/event_config.json b/tests/event_config.json index 43e9748..8ac34ac 100644 --- a/tests/event_config.json +++ b/tests/event_config.json @@ -88,5 +88,25 @@ ], "end_point": { "addr": "" }, "dont_message_on_private_repos": true + }, + "github_pull_request": + { + "hmac": "this_is_secret_number_one", + "templates": + [ + { + "criteria": + [ + { + "check_value_path": "", + "check_value_in": [], + "check_value_not_in": [] + } + ], + "body": "New PR from !" + } + ], + "end_point": { "addr": "https://discord.com/api/webhooks/1194210175121375262/UU7M37iR7e1aWFteFfAwiPaJkAXYwEao2-v7f1bmZyOGf30V4qKmTcjsdOBEYytDZKTN" }, + "dont_message_on_private_repos": true } } \ No newline at end of file From c156e382e8aae81fc2f33373c18668dc137432b3 Mon Sep 17 00:00:00 2001 From: Jerboa-app Date: Sun, 4 Feb 2024 10:16:34 +0000 Subject: [PATCH 3/4] add issue --- src/web/github/response/github_filter.rs | 7 +- src/web/github/response/github_issue.rs | 76 +++ src/web/github/response/mod.rs | 1 + tests/common/mod.rs | 565 +++++++++++++++++++++++ 4 files changed, 648 insertions(+), 1 deletion(-) create mode 100644 src/web/github/response/github_issue.rs diff --git a/src/web/github/response/github_filter.rs b/src/web/github/response/github_filter.rs index 44a9e53..f392257 100644 --- a/src/web/github/response/github_filter.rs +++ b/src/web/github/response/github_filter.rs @@ -33,7 +33,7 @@ response:: use crate::web::is_authentic; -use super::{github_forked, github_ping, github_pull_request}; +use super::{github_forked, github_issue, github_ping, github_pull_request}; /// Middleware to detect, verify, and respond to a github POST request from a /// Github webhook @@ -130,6 +130,7 @@ where B: axum::body::HttpBody { true => { + crate::debug(format!("x-github-event: {:?}", headers["x-github-event"]), None); match std::str::from_utf8(headers["x-github-event"].as_bytes()).unwrap() { github_pushed::X_GTIHUB_EVENT => @@ -155,6 +156,10 @@ where B: axum::body::HttpBody github_pull_request::X_GTIHUB_EVENT => { Box::new(github_pull_request::GithubPullRequest::new()) + }, + github_issue::X_GTIHUB_EVENT => + { + Box::new(github_issue::GithubIssue::new()) } _ => return Ok(StatusCode::CONTINUE.into_response()) } diff --git a/src/web/github/response/github_issue.rs b/src/web/github/response/github_issue.rs new file mode 100644 index 0000000..3345923 --- /dev/null +++ b/src/web/github/response/github_issue.rs @@ -0,0 +1,76 @@ +use std::collections::HashMap; + +use axum::http::{HeaderMap, StatusCode}; +use axum::body::Bytes; + +use crate::web::discord; +use crate::web::event::{EventConfig, read_config, select_template, expand_template}; +use crate::web::event::Event; + +use super::github_filter::github_request_is_authentic; + +pub const X_GTIHUB_EVENT: &str = "issues"; + +pub struct GithubIssue +{ + config: EventConfig +} + +impl GithubIssue +{ + pub fn new() -> GithubIssue + { + GithubIssue { config: EventConfig::new() } + } +} + +impl Event for GithubIssue +{ + fn get_token(&self) -> String + { + self.config.get_token() + } + + fn get_end_point(&self) -> discord::request::model::Webhook + { + self.config.get_end_point() + } + + fn load_config(&mut self) + { + self.config = read_config("github_issue"); + } + + fn is_authentic(&self, headers: HeaderMap, body: Bytes) -> StatusCode + { + return github_request_is_authentic(self.get_token(), headers, body); + } + + fn into_response(&self, data: HashMap) -> (Option, StatusCode) + { + + let template = select_template(self.config.get_templates(), data.clone()); + + let template = if data["repository"]["name"].is_string() + { + match data["repository"]["name"] == "Pulse" + { + true => template.replacen("", "Pulse (that's me!)", 1), + false => {template} + } + } + else + { + return (None, StatusCode::INTERNAL_SERVER_ERROR) + }; + + crate::debug(format!("issue from {:?}", data["sender"]["login"]), None); + + if self.config.silent_on_private_repos() && data["repository"]["private"].as_bool().is_some_and(|x|x) + { + return (None, StatusCode::OK); + } + + (expand_template(template, data), StatusCode::OK) + } +} \ No newline at end of file diff --git a/src/web/github/response/mod.rs b/src/web/github/response/mod.rs index 43dcf50..6c37a2f 100644 --- a/src/web/github/response/mod.rs +++ b/src/web/github/response/mod.rs @@ -5,4 +5,5 @@ pub mod github_pushed; pub mod github_ping; pub mod github_forked; pub mod github_pull_request; +pub mod github_issue; pub mod model; \ No newline at end of file diff --git a/tests/common/mod.rs b/tests/common/mod.rs index 236e67f..dcad2c4 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -1255,4 +1255,569 @@ pub const FORKED_PAYLOAD: &str = r#" "type": "User", "site_admin": false } +}"#; + +pub const PULL_REQUEST_PAYLOAD: &str = r#" +{ + "action": "synchronize", + "number": 15, + "pull_request": { + "url": "https://api.github.com/repos/JerboaBurrow/Pulse/pulls/15", + "id": 1710298962, + "node_id": "PR_kwDOLAcbA85l8RdS", + "html_url": "https://github.com/JerboaBurrow/Pulse/pull/15", + "diff_url": "https://github.com/JerboaBurrow/Pulse/pull/15.diff", + "patch_url": "https://github.com/JerboaBurrow/Pulse/pull/15.patch", + "issue_url": "https://api.github.com/repos/JerboaBurrow/Pulse/issues/15", + "number": 15, + "state": "open", + "locked": false, + "title": "adds fork event", + "user": { + "login": "Jerboa-app", + "id": 84378622, + "node_id": "MDQ6VXNlcjg0Mzc4NjIy", + "avatar_url": "https://avatars.githubusercontent.com/u/84378622?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/Jerboa-app", + "html_url": "https://github.com/Jerboa-app", + "followers_url": "https://api.github.com/users/Jerboa-app/followers", + "following_url": "https://api.github.com/users/Jerboa-app/following{/other_user}", + "gists_url": "https://api.github.com/users/Jerboa-app/gists{/gist_id}", + "starred_url": "https://api.github.com/users/Jerboa-app/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/Jerboa-app/subscriptions", + "organizations_url": "https://api.github.com/users/Jerboa-app/orgs", + "repos_url": "https://api.github.com/users/Jerboa-app/repos", + "events_url": "https://api.github.com/users/Jerboa-app/events{/privacy}", + "received_events_url": "https://api.github.com/users/Jerboa-app/received_events", + "type": "User", + "site_admin": false + }, + "body": null, + "created_at": "2024-02-04T09:47:41Z", + "updated_at": "2024-02-04T09:53:07Z", + "closed_at": null, + "merged_at": null, + "merge_commit_sha": "20525d66beedc2002ca38df08a09bb142aaa5e93", + "assignee": null, + "assignees": [ + + ], + "requested_reviewers": [ + + ], + "requested_teams": [ + + ], + "labels": [ + + ], + "milestone": null, + "draft": false, + "commits_url": "https://api.github.com/repos/JerboaBurrow/Pulse/pulls/15/commits", + "review_comments_url": "https://api.github.com/repos/JerboaBurrow/Pulse/pulls/15/comments", + "review_comment_url": "https://api.github.com/repos/JerboaBurrow/Pulse/pulls/comments{/number}", + "comments_url": "https://api.github.com/repos/JerboaBurrow/Pulse/issues/15/comments", + "statuses_url": "https://api.github.com/repos/JerboaBurrow/Pulse/statuses/a5847bbb714768303b02035df2fab47b43663a53", + "head": { + "label": "JerboaBurrow:add_fork_issue_pr", + "ref": "add_fork_issue_pr", + "sha": "a5847bbb714768303b02035df2fab47b43663a53", + "user": { + "login": "JerboaBurrow", + "id": 109722648, + "node_id": "O_kgDOBoo8GA", + "avatar_url": "https://avatars.githubusercontent.com/u/109722648?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/JerboaBurrow", + "html_url": "https://github.com/JerboaBurrow", + "followers_url": "https://api.github.com/users/JerboaBurrow/followers", + "following_url": "https://api.github.com/users/JerboaBurrow/following{/other_user}", + "gists_url": "https://api.github.com/users/JerboaBurrow/gists{/gist_id}", + "starred_url": "https://api.github.com/users/JerboaBurrow/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/JerboaBurrow/subscriptions", + "organizations_url": "https://api.github.com/users/JerboaBurrow/orgs", + "repos_url": "https://api.github.com/users/JerboaBurrow/repos", + "events_url": "https://api.github.com/users/JerboaBurrow/events{/privacy}", + "received_events_url": "https://api.github.com/users/JerboaBurrow/received_events", + "type": "Organization", + "site_admin": false + }, + "repo": { + "id": 738663171, + "node_id": "R_kgDOLAcbAw", + "name": "Pulse", + "full_name": "JerboaBurrow/Pulse", + "private": false, + "owner": { + "login": "JerboaBurrow", + "id": 109722648, + "node_id": "O_kgDOBoo8GA", + "avatar_url": "https://avatars.githubusercontent.com/u/109722648?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/JerboaBurrow", + "html_url": "https://github.com/JerboaBurrow", + "followers_url": "https://api.github.com/users/JerboaBurrow/followers", + "following_url": "https://api.github.com/users/JerboaBurrow/following{/other_user}", + "gists_url": "https://api.github.com/users/JerboaBurrow/gists{/gist_id}", + "starred_url": "https://api.github.com/users/JerboaBurrow/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/JerboaBurrow/subscriptions", + "organizations_url": "https://api.github.com/users/JerboaBurrow/orgs", + "repos_url": "https://api.github.com/users/JerboaBurrow/repos", + "events_url": "https://api.github.com/users/JerboaBurrow/events{/privacy}", + "received_events_url": "https://api.github.com/users/JerboaBurrow/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/JerboaBurrow/Pulse", + "description": "Discord webhook bot posting messages on Github events | hot-loadable formatting templates; string interpolation in templates for arbitrary JSON bodies", + "fork": false, + "url": "https://api.github.com/repos/JerboaBurrow/Pulse", + "forks_url": "https://api.github.com/repos/JerboaBurrow/Pulse/forks", + "keys_url": "https://api.github.com/repos/JerboaBurrow/Pulse/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/JerboaBurrow/Pulse/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/JerboaBurrow/Pulse/teams", + "hooks_url": "https://api.github.com/repos/JerboaBurrow/Pulse/hooks", + "issue_events_url": "https://api.github.com/repos/JerboaBurrow/Pulse/issues/events{/number}", + "events_url": "https://api.github.com/repos/JerboaBurrow/Pulse/events", + "assignees_url": "https://api.github.com/repos/JerboaBurrow/Pulse/assignees{/user}", + "branches_url": "https://api.github.com/repos/JerboaBurrow/Pulse/branches{/branch}", + "tags_url": "https://api.github.com/repos/JerboaBurrow/Pulse/tags", + "blobs_url": "https://api.github.com/repos/JerboaBurrow/Pulse/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/JerboaBurrow/Pulse/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/JerboaBurrow/Pulse/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/JerboaBurrow/Pulse/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/JerboaBurrow/Pulse/statuses/{sha}", + "languages_url": "https://api.github.com/repos/JerboaBurrow/Pulse/languages", + "stargazers_url": "https://api.github.com/repos/JerboaBurrow/Pulse/stargazers", + "contributors_url": "https://api.github.com/repos/JerboaBurrow/Pulse/contributors", + "subscribers_url": "https://api.github.com/repos/JerboaBurrow/Pulse/subscribers", + "subscription_url": "https://api.github.com/repos/JerboaBurrow/Pulse/subscription", + "commits_url": "https://api.github.com/repos/JerboaBurrow/Pulse/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/JerboaBurrow/Pulse/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/JerboaBurrow/Pulse/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/JerboaBurrow/Pulse/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/JerboaBurrow/Pulse/contents/{+path}", + "compare_url": "https://api.github.com/repos/JerboaBurrow/Pulse/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/JerboaBurrow/Pulse/merges", + "archive_url": "https://api.github.com/repos/JerboaBurrow/Pulse/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/JerboaBurrow/Pulse/downloads", + "issues_url": "https://api.github.com/repos/JerboaBurrow/Pulse/issues{/number}", + "pulls_url": "https://api.github.com/repos/JerboaBurrow/Pulse/pulls{/number}", + "milestones_url": "https://api.github.com/repos/JerboaBurrow/Pulse/milestones{/number}", + "notifications_url": "https://api.github.com/repos/JerboaBurrow/Pulse/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/JerboaBurrow/Pulse/labels{/name}", + "releases_url": "https://api.github.com/repos/JerboaBurrow/Pulse/releases{/id}", + "deployments_url": "https://api.github.com/repos/JerboaBurrow/Pulse/deployments", + "created_at": "2024-01-03T18:47:03Z", + "updated_at": "2024-01-18T14:21:05Z", + "pushed_at": "2024-02-04T09:53:06Z", + "git_url": "git://github.com/JerboaBurrow/Pulse.git", + "ssh_url": "git@github.com:JerboaBurrow/Pulse.git", + "clone_url": "https://github.com/JerboaBurrow/Pulse.git", + "svn_url": "https://github.com/JerboaBurrow/Pulse", + "homepage": "", + "size": 102, + "stargazers_count": 0, + "watchers_count": 0, + "language": "Rust", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": false, + "has_pages": false, + "has_discussions": false, + "forks_count": 1, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 4, + "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": [ + "bot", + "discord", + "github", + "http", + "https", + "rust", + "server", + "webdev", + "webhook" + ], + "visibility": "public", + "forks": 1, + "open_issues": 4, + "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": "JerboaBurrow:main", + "ref": "main", + "sha": "1e3cded74fda680439e0b7bf306b494af475e2f2", + "user": { + "login": "JerboaBurrow", + "id": 109722648, + "node_id": "O_kgDOBoo8GA", + "avatar_url": "https://avatars.githubusercontent.com/u/109722648?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/JerboaBurrow", + "html_url": "https://github.com/JerboaBurrow", + "followers_url": "https://api.github.com/users/JerboaBurrow/followers", + "following_url": "https://api.github.com/users/JerboaBurrow/following{/other_user}", + "gists_url": "https://api.github.com/users/JerboaBurrow/gists{/gist_id}", + "starred_url": "https://api.github.com/users/JerboaBurrow/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/JerboaBurrow/subscriptions", + "organizations_url": "https://api.github.com/users/JerboaBurrow/orgs", + "repos_url": "https://api.github.com/users/JerboaBurrow/repos", + "events_url": "https://api.github.com/users/JerboaBurrow/events{/privacy}", + "received_events_url": "https://api.github.com/users/JerboaBurrow/received_events", + "type": "Organization", + "site_admin": false + }, + "repo": { + "id": 738663171, + "node_id": "R_kgDOLAcbAw", + "name": "Pulse", + "full_name": "JerboaBurrow/Pulse", + "private": false, + "owner": { + "login": "JerboaBurrow", + "id": 109722648, + "node_id": "O_kgDOBoo8GA", + "avatar_url": "https://avatars.githubusercontent.com/u/109722648?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/JerboaBurrow", + "html_url": "https://github.com/JerboaBurrow", + "followers_url": "https://api.github.com/users/JerboaBurrow/followers", + "following_url": "https://api.github.com/users/JerboaBurrow/following{/other_user}", + "gists_url": "https://api.github.com/users/JerboaBurrow/gists{/gist_id}", + "starred_url": "https://api.github.com/users/JerboaBurrow/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/JerboaBurrow/subscriptions", + "organizations_url": "https://api.github.com/users/JerboaBurrow/orgs", + "repos_url": "https://api.github.com/users/JerboaBurrow/repos", + "events_url": "https://api.github.com/users/JerboaBurrow/events{/privacy}", + "received_events_url": "https://api.github.com/users/JerboaBurrow/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/JerboaBurrow/Pulse", + "description": "Discord webhook bot posting messages on Github events | hot-loadable formatting templates; string interpolation in templates for arbitrary JSON bodies", + "fork": false, + "url": "https://api.github.com/repos/JerboaBurrow/Pulse", + "forks_url": "https://api.github.com/repos/JerboaBurrow/Pulse/forks", + "keys_url": "https://api.github.com/repos/JerboaBurrow/Pulse/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/JerboaBurrow/Pulse/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/JerboaBurrow/Pulse/teams", + "hooks_url": "https://api.github.com/repos/JerboaBurrow/Pulse/hooks", + "issue_events_url": "https://api.github.com/repos/JerboaBurrow/Pulse/issues/events{/number}", + "events_url": "https://api.github.com/repos/JerboaBurrow/Pulse/events", + "assignees_url": "https://api.github.com/repos/JerboaBurrow/Pulse/assignees{/user}", + "branches_url": "https://api.github.com/repos/JerboaBurrow/Pulse/branches{/branch}", + "tags_url": "https://api.github.com/repos/JerboaBurrow/Pulse/tags", + "blobs_url": "https://api.github.com/repos/JerboaBurrow/Pulse/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/JerboaBurrow/Pulse/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/JerboaBurrow/Pulse/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/JerboaBurrow/Pulse/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/JerboaBurrow/Pulse/statuses/{sha}", + "languages_url": "https://api.github.com/repos/JerboaBurrow/Pulse/languages", + "stargazers_url": "https://api.github.com/repos/JerboaBurrow/Pulse/stargazers", + "contributors_url": "https://api.github.com/repos/JerboaBurrow/Pulse/contributors", + "subscribers_url": "https://api.github.com/repos/JerboaBurrow/Pulse/subscribers", + "subscription_url": "https://api.github.com/repos/JerboaBurrow/Pulse/subscription", + "commits_url": "https://api.github.com/repos/JerboaBurrow/Pulse/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/JerboaBurrow/Pulse/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/JerboaBurrow/Pulse/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/JerboaBurrow/Pulse/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/JerboaBurrow/Pulse/contents/{+path}", + "compare_url": "https://api.github.com/repos/JerboaBurrow/Pulse/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/JerboaBurrow/Pulse/merges", + "archive_url": "https://api.github.com/repos/JerboaBurrow/Pulse/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/JerboaBurrow/Pulse/downloads", + "issues_url": "https://api.github.com/repos/JerboaBurrow/Pulse/issues{/number}", + "pulls_url": "https://api.github.com/repos/JerboaBurrow/Pulse/pulls{/number}", + "milestones_url": "https://api.github.com/repos/JerboaBurrow/Pulse/milestones{/number}", + "notifications_url": "https://api.github.com/repos/JerboaBurrow/Pulse/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/JerboaBurrow/Pulse/labels{/name}", + "releases_url": "https://api.github.com/repos/JerboaBurrow/Pulse/releases{/id}", + "deployments_url": "https://api.github.com/repos/JerboaBurrow/Pulse/deployments", + "created_at": "2024-01-03T18:47:03Z", + "updated_at": "2024-01-18T14:21:05Z", + "pushed_at": "2024-02-04T09:53:06Z", + "git_url": "git://github.com/JerboaBurrow/Pulse.git", + "ssh_url": "git@github.com:JerboaBurrow/Pulse.git", + "clone_url": "https://github.com/JerboaBurrow/Pulse.git", + "svn_url": "https://github.com/JerboaBurrow/Pulse", + "homepage": "", + "size": 102, + "stargazers_count": 0, + "watchers_count": 0, + "language": "Rust", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": false, + "has_pages": false, + "has_discussions": false, + "forks_count": 1, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 4, + "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": [ + "bot", + "discord", + "github", + "http", + "https", + "rust", + "server", + "webdev", + "webhook" + ], + "visibility": "public", + "forks": 1, + "open_issues": 4, + "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" + } + }, + "_links": { + "self": { + "href": "https://api.github.com/repos/JerboaBurrow/Pulse/pulls/15" + }, + "html": { + "href": "https://github.com/JerboaBurrow/Pulse/pull/15" + }, + "issue": { + "href": "https://api.github.com/repos/JerboaBurrow/Pulse/issues/15" + }, + "comments": { + "href": "https://api.github.com/repos/JerboaBurrow/Pulse/issues/15/comments" + }, + "review_comments": { + "href": "https://api.github.com/repos/JerboaBurrow/Pulse/pulls/15/comments" + }, + "review_comment": { + "href": "https://api.github.com/repos/JerboaBurrow/Pulse/pulls/comments{/number}" + }, + "commits": { + "href": "https://api.github.com/repos/JerboaBurrow/Pulse/pulls/15/commits" + }, + "statuses": { + "href": "https://api.github.com/repos/JerboaBurrow/Pulse/statuses/a5847bbb714768303b02035df2fab47b43663a53" + } + }, + "author_association": "CONTRIBUTOR", + "auto_merge": null, + "active_lock_reason": null, + "merged": false, + "mergeable": null, + "rebaseable": null, + "mergeable_state": "unknown", + "merged_by": null, + "comments": 0, + "review_comments": 0, + "maintainer_can_modify": false, + "commits": 2, + "additions": 486, + "deletions": 2, + "changed_files": 7 + }, + "before": "0af48bd9c295204f59d9c9c2a4e251442c377760", + "after": "a5847bbb714768303b02035df2fab47b43663a53", + "repository": { + "id": 738663171, + "node_id": "R_kgDOLAcbAw", + "name": "Pulse", + "full_name": "JerboaBurrow/Pulse", + "private": false, + "owner": { + "login": "JerboaBurrow", + "id": 109722648, + "node_id": "O_kgDOBoo8GA", + "avatar_url": "https://avatars.githubusercontent.com/u/109722648?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/JerboaBurrow", + "html_url": "https://github.com/JerboaBurrow", + "followers_url": "https://api.github.com/users/JerboaBurrow/followers", + "following_url": "https://api.github.com/users/JerboaBurrow/following{/other_user}", + "gists_url": "https://api.github.com/users/JerboaBurrow/gists{/gist_id}", + "starred_url": "https://api.github.com/users/JerboaBurrow/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/JerboaBurrow/subscriptions", + "organizations_url": "https://api.github.com/users/JerboaBurrow/orgs", + "repos_url": "https://api.github.com/users/JerboaBurrow/repos", + "events_url": "https://api.github.com/users/JerboaBurrow/events{/privacy}", + "received_events_url": "https://api.github.com/users/JerboaBurrow/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/JerboaBurrow/Pulse", + "description": "Discord webhook bot posting messages on Github events | hot-loadable formatting templates; string interpolation in templates for arbitrary JSON bodies", + "fork": false, + "url": "https://api.github.com/repos/JerboaBurrow/Pulse", + "forks_url": "https://api.github.com/repos/JerboaBurrow/Pulse/forks", + "keys_url": "https://api.github.com/repos/JerboaBurrow/Pulse/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/JerboaBurrow/Pulse/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/JerboaBurrow/Pulse/teams", + "hooks_url": "https://api.github.com/repos/JerboaBurrow/Pulse/hooks", + "issue_events_url": "https://api.github.com/repos/JerboaBurrow/Pulse/issues/events{/number}", + "events_url": "https://api.github.com/repos/JerboaBurrow/Pulse/events", + "assignees_url": "https://api.github.com/repos/JerboaBurrow/Pulse/assignees{/user}", + "branches_url": "https://api.github.com/repos/JerboaBurrow/Pulse/branches{/branch}", + "tags_url": "https://api.github.com/repos/JerboaBurrow/Pulse/tags", + "blobs_url": "https://api.github.com/repos/JerboaBurrow/Pulse/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/JerboaBurrow/Pulse/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/JerboaBurrow/Pulse/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/JerboaBurrow/Pulse/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/JerboaBurrow/Pulse/statuses/{sha}", + "languages_url": "https://api.github.com/repos/JerboaBurrow/Pulse/languages", + "stargazers_url": "https://api.github.com/repos/JerboaBurrow/Pulse/stargazers", + "contributors_url": "https://api.github.com/repos/JerboaBurrow/Pulse/contributors", + "subscribers_url": "https://api.github.com/repos/JerboaBurrow/Pulse/subscribers", + "subscription_url": "https://api.github.com/repos/JerboaBurrow/Pulse/subscription", + "commits_url": "https://api.github.com/repos/JerboaBurrow/Pulse/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/JerboaBurrow/Pulse/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/JerboaBurrow/Pulse/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/JerboaBurrow/Pulse/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/JerboaBurrow/Pulse/contents/{+path}", + "compare_url": "https://api.github.com/repos/JerboaBurrow/Pulse/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/JerboaBurrow/Pulse/merges", + "archive_url": "https://api.github.com/repos/JerboaBurrow/Pulse/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/JerboaBurrow/Pulse/downloads", + "issues_url": "https://api.github.com/repos/JerboaBurrow/Pulse/issues{/number}", + "pulls_url": "https://api.github.com/repos/JerboaBurrow/Pulse/pulls{/number}", + "milestones_url": "https://api.github.com/repos/JerboaBurrow/Pulse/milestones{/number}", + "notifications_url": "https://api.github.com/repos/JerboaBurrow/Pulse/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/JerboaBurrow/Pulse/labels{/name}", + "releases_url": "https://api.github.com/repos/JerboaBurrow/Pulse/releases{/id}", + "deployments_url": "https://api.github.com/repos/JerboaBurrow/Pulse/deployments", + "created_at": "2024-01-03T18:47:03Z", + "updated_at": "2024-01-18T14:21:05Z", + "pushed_at": "2024-02-04T09:53:06Z", + "git_url": "git://github.com/JerboaBurrow/Pulse.git", + "ssh_url": "git@github.com:JerboaBurrow/Pulse.git", + "clone_url": "https://github.com/JerboaBurrow/Pulse.git", + "svn_url": "https://github.com/JerboaBurrow/Pulse", + "homepage": "", + "size": 102, + "stargazers_count": 0, + "watchers_count": 0, + "language": "Rust", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": false, + "has_pages": false, + "has_discussions": false, + "forks_count": 1, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 4, + "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": [ + "bot", + "discord", + "github", + "http", + "https", + "rust", + "server", + "webdev", + "webhook" + ], + "visibility": "public", + "forks": 1, + "open_issues": 4, + "watchers": 0, + "default_branch": "main", + "custom_properties": { + + } + }, + "organization": { + "login": "JerboaBurrow", + "id": 109722648, + "node_id": "O_kgDOBoo8GA", + "url": "https://api.github.com/orgs/JerboaBurrow", + "repos_url": "https://api.github.com/orgs/JerboaBurrow/repos", + "events_url": "https://api.github.com/orgs/JerboaBurrow/events", + "hooks_url": "https://api.github.com/orgs/JerboaBurrow/hooks", + "issues_url": "https://api.github.com/orgs/JerboaBurrow/issues", + "members_url": "https://api.github.com/orgs/JerboaBurrow/members{/member}", + "public_members_url": "https://api.github.com/orgs/JerboaBurrow/public_members{/member}", + "avatar_url": "https://avatars.githubusercontent.com/u/109722648?v=4", + "description": "Creating apps and games" + }, + "sender": { + "login": "Jerboa-app", + "id": 84378622, + "node_id": "MDQ6VXNlcjg0Mzc4NjIy", + "avatar_url": "https://avatars.githubusercontent.com/u/84378622?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/Jerboa-app", + "html_url": "https://github.com/Jerboa-app", + "followers_url": "https://api.github.com/users/Jerboa-app/followers", + "following_url": "https://api.github.com/users/Jerboa-app/following{/other_user}", + "gists_url": "https://api.github.com/users/Jerboa-app/gists{/gist_id}", + "starred_url": "https://api.github.com/users/Jerboa-app/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/Jerboa-app/subscriptions", + "organizations_url": "https://api.github.com/users/Jerboa-app/orgs", + "repos_url": "https://api.github.com/users/Jerboa-app/repos", + "events_url": "https://api.github.com/users/Jerboa-app/events{/privacy}", + "received_events_url": "https://api.github.com/users/Jerboa-app/received_events", + "type": "User", + "site_admin": false + } }"#; \ No newline at end of file From ec0ecbd8ba5cf8ed737dc49184bb52de3e40e47f Mon Sep 17 00:00:00 2001 From: Jerboa-app Date: Sun, 4 Feb 2024 10:16:58 +0000 Subject: [PATCH 4/4] bump version --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index e80b73b..dcb6040 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pulse" -version = "0.0.4" +version = "0.0.5" authors = ["Jerboa"] edition="2021"