From eb0c993e032631210f40a8836214e9f4936d982f Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Sun, 14 Jul 2024 17:04:08 -0400 Subject: [PATCH] Full request schema. --- src/webhook.rs | 135 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 130 insertions(+), 5 deletions(-) diff --git a/src/webhook.rs b/src/webhook.rs index 68c8446..074e5da 100644 --- a/src/webhook.rs +++ b/src/webhook.rs @@ -19,12 +19,137 @@ pub(crate) struct HookRequest { ref_field: String, before: String, compare_url: String, - commits: Value, + commits: Vec, total_commits: u64, - head_commit: Value, - repository: Value, - pusher: Value, - sender: Value, + head_commit: HookCommit, + repository: HookRepository, + pusher: HookUser, + sender: HookUser, +} + +#[allow(dead_code)] +#[derive(Deserialize)] +pub(crate) struct HookUser { + id: u64, + login: String, + login_name: String, + full_name: String, + email: String, + avatar_url: String, + language: String, + is_admin: bool, + last_login: String, // TODO: parse to datetime + created: String, // TODO: parse to datetime + restricted: bool, + active: bool, + prohibit_login: bool, + location: String, + website: String, + description: String, + visibility: String, + followers_count: u64, + following_count: u64, + starred_repos_count: u64, + username: String, +} + +#[allow(dead_code)] +#[derive(Deserialize)] +pub(crate) struct HookRepository { + id: u64, + owner: HookUser, + name: String, + full_name: String, + description: String, + empty: bool, + private: bool, + fork: bool, + template: bool, + parent: Value, // Was null in test hook + mirror: bool, + size: u64, + language: String, + languages_url: String, + html_url: String, + url: String, + link: String, + ssh_url: String, + clone_url: String, + original_url: String, + website: String, + stars_count: u64, + forks_count: u64, + watchers_count: u64, + open_issues_count: u64, + open_pr_counter: u64, + release_counter: u64, + default_branch: String, + archived: bool, + created_at: String, // TODO: parse to datetime + updated_at: String, // TODO: parse to datetime + archived_at: String, // TODO: parse to datetime + permissions: HookRepositoryPermissions, + has_issues: bool, + internal_tracker: HookRepositoryInternalTracker, + has_wiki: bool, + has_pull_requests: bool, + has_projects: bool, + has_releases: bool, + has_packages: bool, + has_actions: bool, + ignore_whitespace_conflicts: bool, + allow_merge_commits: bool, + allow_rebase: bool, + allow_rebase_explicit: bool, + allow_squash_merge: bool, + allow_rebase_update: bool, + default_delete_branch_after_merge: bool, + default_merge_style: String, + default_allow_maintainer_edit: bool, + avatar_url: String, + internal: bool, + mirror_interval: String, + mirror_updated: String, // TODO: parse to datetime + repo_transfer: Value, // Was null in test hook +} + +#[allow(dead_code)] +#[derive(Deserialize)] +pub(crate) struct HookRepositoryPermissions { + admin: bool, + push: bool, + pull: bool, +} + +#[allow(dead_code)] +#[derive(Deserialize)] +pub(crate) struct HookRepositoryInternalTracker { + enable_time_tracker: bool, + allow_only_contributors_to_track_time: bool, + enable_issue_dependencies: bool, +} + +#[allow(dead_code)] +#[derive(Deserialize)] +pub(crate) struct HookCommit { + id: String, + message: String, + url: String, + author: HookGitUser, + committer: HookGitUser, + verification: Value, // Was null in test hook + timestamp: String, // TODO: parse to datetime + added: Vec, + removed: Vec, + modified: Vec, +} + +#[allow(dead_code)] +#[derive(Deserialize)] +pub(crate) struct HookGitUser { + name: String, + email: String, + username: String, } #[derive(Serialize)]