use axum::http::HeaderMap; use axum::http::StatusCode; use axum::Json; use serde::Deserialize; use serde::Serialize; use serde_json::Value; pub(crate) async fn hook( headers: HeaderMap, Json(payload): Json, ) -> (StatusCode, Json) { (StatusCode::OK, Json(HookResponse { ok: true })) } #[allow(dead_code)] #[derive(Deserialize)] pub(crate) struct HookRequest { #[serde(rename = "ref")] ref_field: String, before: String, compare_url: String, commits: Vec, total_commits: u64, 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)] pub(crate) struct HookResponse { ok: bool, }