pushing for testing on vps
This commit is contained in:
parent
4bd3425b1b
commit
cdcc9764ae
1
.env
Normal file
1
.env
Normal file
|
@ -0,0 +1 @@
|
|||
DATABASE_URL="postgresql://mc_test:mc_test@nya-1.mcorangehq.xyz/mc_test"
|
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"rust-analyzer.showUnlinkedFileNotification": false
|
||||
}
|
10
Cargo.lock
generated
10
Cargo.lock
generated
|
@ -1569,6 +1569,15 @@ dependencies = [
|
|||
"windows-targets 0.48.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "parse_int"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2d695b79916a2c08bcff7be7647ab60d1402885265005a6658ffe6d763553c5a"
|
||||
dependencies = [
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "password-hash"
|
||||
version = "0.5.0"
|
||||
|
@ -2664,6 +2673,7 @@ dependencies = [
|
|||
"env_logger",
|
||||
"futures",
|
||||
"log",
|
||||
"parse_int",
|
||||
"rand",
|
||||
"serde",
|
||||
"serde_json",
|
||||
|
|
|
@ -37,6 +37,7 @@ futures = "0.3.30"
|
|||
bitflags = "2.5.0"
|
||||
rand = "0.8.5"
|
||||
serde_json = "1.0.115"
|
||||
parse_int = "0.6.0"
|
||||
|
||||
[profile.dev.package.sqlx-macros]
|
||||
opt-level = 3
|
||||
|
|
2
migrations/20240330145459_users.down.sql
Normal file
2
migrations/20240330145459_users.down.sql
Normal file
|
@ -0,0 +1,2 @@
|
|||
-- Add down migration script here
|
||||
DROP TABLE users;
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
CREATE TABLE IF NOT EXISTS Users (
|
||||
-- Add up migration script here
|
||||
CREATE TABLE IF NOT EXISTS users (
|
||||
id UUID NOT NULL UNIQUE,
|
||||
email TEXT NOT NULL,
|
||||
username TEXT NOT NULL,
|
2
migrations/20240330145503_tokens.down.sql
Normal file
2
migrations/20240330145503_tokens.down.sql
Normal file
|
@ -0,0 +1,2 @@
|
|||
-- Add down migration script here
|
||||
DROP TABLE tokens;
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
CREATE TABLE IF NOT EXISTS Tokens (
|
||||
-- Add up migration script here
|
||||
CREATE TABLE IF NOT EXISTS tokens (
|
||||
token TEXT NOT NULL UNIQUE,
|
||||
owner_id UUID NOT NULL,
|
||||
permissions BIGINT NOT NULL,
|
2
migrations/20240330145505_posts.down.sql
Normal file
2
migrations/20240330145505_posts.down.sql
Normal file
|
@ -0,0 +1,2 @@
|
|||
-- Add down migration script here
|
||||
DROP TABLE posts;
|
|
@ -1,11 +1,11 @@
|
|||
|
||||
CREATE TABLE IF NOT EXISTS Posts (
|
||||
-- Add up migration script here
|
||||
CREATE TABLE IF NOT EXISTS posts (
|
||||
id UUID NOT NULL UNIQUE,
|
||||
title TEXT NOT NULL,
|
||||
descr TEXT NOT NULL,
|
||||
img_url TEXT NOT NULL,
|
||||
origin_url TEXT NOT NULL,
|
||||
original_request JSON NOT NULL,
|
||||
posted_on TIMESTAMP NOT NULL
|
||||
posted_on TIMESTAMP NOT NULL,
|
||||
PRIMARY KEY (id)
|
||||
)
|
|
@ -1,2 +0,0 @@
|
|||
-- This file should undo anything in `up.sql`
|
||||
DROP TABLE Users
|
56
src/cli.rs
56
src/cli.rs
|
@ -1,5 +1,9 @@
|
|||
|
||||
use clap::Parser;
|
||||
use std::str::FromStr;
|
||||
use clap::{Parser, Subcommand};
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::database::{models::Permissions, Database};
|
||||
|
||||
#[derive(Debug, Clone, Parser)]
|
||||
#[command(version, about, long_about = None)]
|
||||
|
@ -18,4 +22,54 @@ pub struct CliArgs {
|
|||
|
||||
#[arg(long, short, default_value="./config.toml")]
|
||||
pub config: camino::Utf8PathBuf,
|
||||
|
||||
#[command(subcommand)]
|
||||
pub command: Option<CliArgsCommand>
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Subcommand)]
|
||||
pub enum CliArgsCommand {
|
||||
#[command(arg_required_else_help = true)]
|
||||
GenerateToken {
|
||||
#[arg(long)]
|
||||
owner_id: String,
|
||||
#[arg(long)]
|
||||
permissions: i64,
|
||||
},
|
||||
#[command(arg_required_else_help = true)]
|
||||
CreateUser {
|
||||
#[arg(long)]
|
||||
email: String,
|
||||
#[arg(long)]
|
||||
username: String,
|
||||
#[arg(long)]
|
||||
password: String
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pub async fn handle_command(cli: &CliArgs, db: &mut Database) -> anyhow::Result<bool> {
|
||||
let Some(command) = cli.command.clone() else {
|
||||
return Ok(false);
|
||||
};
|
||||
|
||||
|
||||
match command {
|
||||
CliArgsCommand::GenerateToken {
|
||||
owner_id, permissions
|
||||
} => {
|
||||
let permissions = Permissions::from_bits(permissions).unwrap();
|
||||
let owner_id = Uuid::from_str(&owner_id)?;
|
||||
let token = crate::database::models::tokens::Token::create_new(db, owner_id, permissions).await?;
|
||||
log::info!("Generated token: {token:#?}");
|
||||
Ok(true)
|
||||
},
|
||||
CliArgsCommand::CreateUser {
|
||||
email, username, password
|
||||
} => {
|
||||
let user = crate::database::models::users::User::create_new(db, email, username, password).await?;
|
||||
log::info!("Created user: {user:?}");
|
||||
Ok(true)
|
||||
},
|
||||
}
|
||||
}
|
|
@ -16,7 +16,6 @@ pub struct Database {
|
|||
impl Database {
|
||||
pub async fn new(config: &Config) -> anyhow::Result<Self> {
|
||||
|
||||
sqlx::migrate!("./migrations");
|
||||
|
||||
log::info!("Database connecting to {}", config.database.url);
|
||||
let conn = PgPoolOptions::new()
|
||||
|
@ -27,6 +26,8 @@ impl Database {
|
|||
match conn {
|
||||
Ok(c) => {
|
||||
log::info!("Connection successfull");
|
||||
log::info!("Running migrations");
|
||||
sqlx::migrate!("./migrations").run(&c).await?;
|
||||
Ok(Self {
|
||||
connection: c
|
||||
})
|
||||
|
|
|
@ -4,9 +4,11 @@ pub mod users;
|
|||
pub mod tokens;
|
||||
pub mod posts;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Permissions(i64);
|
||||
|
||||
bitflags! {
|
||||
struct Permissions: i64 {
|
||||
impl Permissions: i64 {
|
||||
const MAKE_POST = 1 << 0;
|
||||
}
|
||||
}
|
|
@ -11,7 +11,7 @@ pub struct Post {
|
|||
pub descr: String,
|
||||
pub img_url: String,
|
||||
pub origin_url: String,
|
||||
pub original_request: Value,
|
||||
pub original_request: String,
|
||||
pub posted_on: i64,
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ use futures::TryStreamExt;
|
|||
|
||||
use super::Permissions;
|
||||
|
||||
#[derive(sqlx::FromRow)]
|
||||
#[derive(sqlx::FromRow, Debug)]
|
||||
pub struct Token {
|
||||
pub token: String,
|
||||
pub owner_id: Uuid,
|
||||
|
|
|
@ -19,7 +19,7 @@ impl User {
|
|||
let hash = bcrypt::hash(password, 15)?;
|
||||
|
||||
sqlx::query(r#"
|
||||
INSERT INTO users ( id, email, username, pw_hash, permissions )
|
||||
INSERT INTO "users" ( id, email, username, pw_hash, permissions )
|
||||
VALUES ( $1, $2, $3, $4, 0 )
|
||||
RETURNING id
|
||||
"#)
|
||||
|
|
|
@ -7,7 +7,7 @@ mod config;
|
|||
mod database;
|
||||
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
async fn main() -> anyhow::Result<()> {
|
||||
let cli = cli::CliArgs::parse();
|
||||
logger::init_logger(&cli);
|
||||
|
||||
|
@ -19,7 +19,12 @@ async fn main() -> std::io::Result<()> {
|
|||
}
|
||||
};
|
||||
|
||||
let Ok(database) = database::Database::new(config.get_ref()).await else {return Ok(())};
|
||||
let Ok(mut database) = database::Database::new(config.get_ref()).await else {return Ok(())};
|
||||
|
||||
if cli::handle_command(&cli, &mut database).await? {
|
||||
log::info!("Command exectuted, exiting");
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
if let Err(e) = web::start_actix(config.get_ref(), database).await {
|
||||
log::error!("Actix had an error: {e}");
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
|
||||
mod routes;
|
||||
mod templates;
|
||||
pub mod routes;
|
||||
pub mod templates;
|
||||
|
||||
use std::sync::Mutex;
|
||||
|
||||
use actix_web::{web, App, HttpServer, Route};
|
||||
use actix_web::{web, App, HttpServer};
|
||||
use actix_files as actix_fs;
|
||||
|
||||
use crate::{config::definition::Config, database::Database};
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
mod webhooks;
|
||||
pub mod webhooks;
|
||||
|
||||
use actix_web::{web, Route, Scope};
|
||||
use actix_web::Scope;
|
||||
|
||||
|
||||
|
||||
|
|
28
src/web/routes/api/webhooks/github/events/mod.rs
Normal file
28
src/web/routes/api/webhooks/github/events/mod.rs
Normal file
|
@ -0,0 +1,28 @@
|
|||
use std::{borrow::BorrowMut, sync::Mutex};
|
||||
|
||||
use actix_web::{web::Data, HttpResponse, HttpResponseBuilder, Result};
|
||||
|
||||
use crate::database::{models::{self, tokens::Token}, Database};
|
||||
|
||||
use super::types::ReleaseEvent;
|
||||
|
||||
pub async fn release_handler(db: Data<Mutex<Database>>, token: Token, body: ReleaseEvent, raw_body: String,) -> Result<HttpResponseBuilder> {
|
||||
|
||||
let title = format!("{} has been released on {}!", body.release.tag_name, body.repository.full_name);
|
||||
|
||||
dbg!(body);
|
||||
|
||||
// models::posts::Post::create_new(
|
||||
// db.lock().unwrap().borrow_mut(),
|
||||
// title,
|
||||
// descr,
|
||||
// img_url,
|
||||
// origin_url,
|
||||
// orignal_request
|
||||
// );
|
||||
|
||||
|
||||
|
||||
|
||||
Ok(HttpResponse::Ok())
|
||||
}
|
|
@ -1,9 +1,11 @@
|
|||
pub mod types;
|
||||
pub mod events;
|
||||
|
||||
use std::{borrow::BorrowMut, sync::Mutex};
|
||||
|
||||
use actix_web::{http::header, web::{self, Data}, HttpRequest, HttpResponse, HttpResponseBuilder, Responder, Result, Scope};
|
||||
use serde_json::Value;
|
||||
use actix_web::{http::header, web::{self, Bytes, Data}, HttpRequest, HttpResponse, Responder, Result, Scope};
|
||||
|
||||
use crate::database::{models::{self, tokens::Token}, Database};
|
||||
use crate::database::{models, Database};
|
||||
|
||||
pub fn get_scope() -> Scope {
|
||||
Scope::new("/github")
|
||||
|
@ -13,7 +15,7 @@ pub fn get_scope() -> Scope {
|
|||
)
|
||||
}
|
||||
|
||||
pub async fn handler(req: HttpRequest, body: web::Json<Value>, db: Data<Mutex<Database>>) -> Result<impl Responder> {
|
||||
pub async fn handler(req: HttpRequest, body: Bytes, db: Data<Mutex<Database>>) -> Result<impl Responder> {
|
||||
let Some(auth) = req.headers().get(header::AUTHORIZATION) else {
|
||||
return Ok(HttpResponse::Unauthorized());
|
||||
};
|
||||
|
@ -43,41 +45,17 @@ pub async fn handler(req: HttpRequest, body: web::Json<Value>, db: Data<Mutex<Da
|
|||
return Ok(HttpResponse::BadRequest());
|
||||
};
|
||||
|
||||
match event_type {
|
||||
"release" => {
|
||||
release_handler(db, token, body).await
|
||||
}
|
||||
let Ok(json) = String::from_utf8(body.to_vec()) else {
|
||||
return Ok(HttpResponse::BadRequest());
|
||||
};
|
||||
|
||||
let Ok(event) = types::Event::from_raw_json(event_type, json.clone()) else {
|
||||
return Ok(HttpResponse::BadRequest());
|
||||
};
|
||||
|
||||
match event {
|
||||
types::Event::Release(body) => events::release_handler(db, token, body, json).await,
|
||||
_ => Ok(HttpResponse::Ok())
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
pub async fn release_handler(db: Data<Mutex<Database>>, token: Token, body: web::Json<Value>) -> Result<HttpResponseBuilder> {
|
||||
let Some(release) = body.get("release") else {
|
||||
return Ok(HttpResponse::BadRequest());
|
||||
};
|
||||
|
||||
let Some(origin_url) = release.get("repository") else {
|
||||
return Ok(HttpResponse::BadRequest());
|
||||
};
|
||||
|
||||
|
||||
models::posts::Post::create_new(
|
||||
db.lock().unwrap().borrow_mut(),
|
||||
title,
|
||||
descr,
|
||||
img_url,
|
||||
origin_url,
|
||||
orignal_request
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
Ok(HttpResponse::Ok())
|
||||
}
|
814
src/web/routes/api/webhooks/github/types.rs
Normal file
814
src/web/routes/api/webhooks/github/types.rs
Normal file
|
@ -0,0 +1,814 @@
|
|||
use serde::Deserialize;
|
||||
|
||||
//? Taken from https://github.com/softprops/afterparty/blob/master/src/events.rs.in
|
||||
//? Examples of payloads in https://github.com/softprops/afterparty/blob/master/data/
|
||||
|
||||
impl Event {
|
||||
pub fn from_raw_json(event: &str, json: String) -> anyhow::Result<Self> {
|
||||
let json = format!("{{\"{event}\": {json}}}");
|
||||
let json: Self = serde_json::from_str(&json)?;
|
||||
|
||||
Ok(json)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
pub struct Value { pub json: serde_json::Value }
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
pub enum Event {
|
||||
CommitComment(CommitCommentEvent),
|
||||
Create(CreateEvent),
|
||||
Delete(DeleteEvent),
|
||||
Deployment(DeploymentEvent),
|
||||
DeploymentStatus(DeploymentStatusEvent),
|
||||
Fork(ForkEvent),
|
||||
Gollum(GollumEvent),
|
||||
IssueComment(IssueCommentEvent),
|
||||
Issues(IssuesEvent),
|
||||
Member(MemberEvent),
|
||||
Membership(MembershipEvent),
|
||||
PageBuild(PageBuildEvent),
|
||||
Ping(PingEvent),
|
||||
Public(PublicEvent),
|
||||
PullRequest(PullRequestEvent),
|
||||
PullRequestReviewComment(PullRequestReviewCommentEvent),
|
||||
Push(PushEvent),
|
||||
Release(ReleaseEvent),
|
||||
Repository(RepositoryEvent),
|
||||
Status(StatusEvent),
|
||||
TeamAdd(TeamAddEvent),
|
||||
Watch(WatchEvent),
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
pub struct CommitCommentEvent {
|
||||
pub action: String,
|
||||
pub comment: Comment,
|
||||
pub repository: Repository,
|
||||
pub sender: User,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
pub struct CreateEvent {
|
||||
pub description: String,
|
||||
pub master_branch: String,
|
||||
pub pusher_type: String,
|
||||
#[serde(rename="ref")]
|
||||
pub _ref: String,
|
||||
#[serde(rename="ref_type")]
|
||||
pub ref_type: String,
|
||||
pub repository: Repository,
|
||||
pub sender: User,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
pub struct DeleteEvent {
|
||||
pub pusher_type: String,
|
||||
#[serde(rename="ref")]
|
||||
pub _ref: String,
|
||||
pub ref_type: String,
|
||||
pub repository: Repository,
|
||||
pub sender: User,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
pub struct DeploymentEvent {
|
||||
pub deployment: Deployment,
|
||||
pub repository: Repository,
|
||||
pub sender: User,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
pub struct DeploymentStatusEvent {
|
||||
pub deployment: Deployment,
|
||||
pub deployment_status: DeploymentStatus,
|
||||
pub repository: Repository,
|
||||
pub sender: User,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
pub struct ForkEvent {
|
||||
pub forkee: Repository,
|
||||
pub repository: Repository,
|
||||
pub sender: User,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
pub struct GollumEvent {
|
||||
pub pages: Vec<Pages>,
|
||||
pub repository: Repository,
|
||||
pub sender: User,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
pub struct IssueCommentEvent {
|
||||
pub action: String,
|
||||
pub comment: IssueCommentComment,
|
||||
pub issue: Issue,
|
||||
pub repository: Repository,
|
||||
pub sender: User,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
pub struct IssuesEvent {
|
||||
pub action: String,
|
||||
pub issue: Issue,
|
||||
pub repository: Repository,
|
||||
pub sender: User,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
pub struct MemberEvent {
|
||||
pub action: String,
|
||||
pub member: User,
|
||||
pub repository: Repository,
|
||||
pub sender: User,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
pub struct MembershipEvent {
|
||||
pub action: String,
|
||||
pub member: User,
|
||||
pub organization: Organization,
|
||||
pub scope: String,
|
||||
pub sender: User,
|
||||
pub team: Team,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
pub struct PageBuildEvent {
|
||||
pub build: PageBuild,
|
||||
pub id: u64,
|
||||
pub repository: Repository,
|
||||
pub sender: User,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
pub struct PingEvent {
|
||||
pub hook: Hook,
|
||||
pub hook_id: u64,
|
||||
pub repository: Repository,
|
||||
pub sender: User,
|
||||
pub zen: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
pub struct PublicEvent {
|
||||
pub repository: Repository,
|
||||
pub sender: User,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
pub struct PullRequestEvent {
|
||||
pub action: String,
|
||||
pub number: u64,
|
||||
pub pull_request: PullRequestDetails,
|
||||
pub repository: Repository,
|
||||
pub sender: User,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
pub struct PullRequestReviewCommentEvent {
|
||||
pub action: String,
|
||||
pub comment: PullRequestReviewComment,
|
||||
pub pull_request: PullRequest,
|
||||
pub repository: Repository,
|
||||
pub sender: User,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
pub struct PushEvent {
|
||||
pub after: String,
|
||||
pub base_ref: Option<String>,
|
||||
pub before: String,
|
||||
pub commits: Vec<CommitStats>,
|
||||
pub compare: String,
|
||||
pub created: bool,
|
||||
pub deleted: bool,
|
||||
pub forced: bool,
|
||||
pub head_commit: CommitStats,
|
||||
pub pusher: UserRef, // note there aren't may fields here
|
||||
#[serde(rename="ref")]
|
||||
pub _ref: String,
|
||||
pub repository: PushRepository,
|
||||
pub sender: User,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
pub struct ReleaseEvent {
|
||||
pub action: String,
|
||||
pub release: Release,
|
||||
pub repository: Repository,
|
||||
pub sender: User,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
pub struct RepositoryEvent {
|
||||
pub action: String,
|
||||
pub organization: Organization,
|
||||
pub repository: Repository,
|
||||
pub sender: User,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
pub struct StatusEvent {
|
||||
//pub branches: Vec<BranchRef>,
|
||||
pub commit: CommitRef,
|
||||
pub context: String,
|
||||
pub created_at: String,
|
||||
pub description: Option<String>,
|
||||
pub id: u64,
|
||||
pub name: String,
|
||||
pub repository: Repository,
|
||||
pub sender: User,
|
||||
pub sha: String,
|
||||
pub state: String,
|
||||
pub target_url: Option<String>,
|
||||
pub updated_at: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
pub struct TeamAddEvent {
|
||||
pub organization: Organization,
|
||||
pub repository: Repository,
|
||||
pub sender: User,
|
||||
pub team: Team,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
pub struct WatchEvent {
|
||||
pub action: String,
|
||||
pub repository: Repository,
|
||||
pub sender: User,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Deserialize, Clone)]
|
||||
pub struct Commit {
|
||||
pub author: GitUser,
|
||||
pub committer: GitUser,
|
||||
pub message: String,
|
||||
pub tree: GitRef,
|
||||
pub url: String,
|
||||
pub comment_count: u64
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Deserialize, Clone)]
|
||||
pub struct BranchRef {
|
||||
pub commit: GitRef,
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Deserialize, Clone)]
|
||||
pub struct PageBuild {
|
||||
pub commit: String,
|
||||
pub created_at: String,
|
||||
pub duration: u64,
|
||||
pub error: Error,
|
||||
pub pusher: User,
|
||||
pub status: String,
|
||||
pub updated_at: String,
|
||||
pub url: String,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Deserialize, Clone)]
|
||||
pub struct Comment {
|
||||
pub body: String,
|
||||
pub commit_id: String,
|
||||
pub created_at: String,
|
||||
pub html_url: String,
|
||||
pub id: u64,
|
||||
pub line: Option<String>,
|
||||
pub path: Option<String>,
|
||||
pub position: Option<String>,
|
||||
pub updated_at: String,
|
||||
pub url: String,
|
||||
pub user: User,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Deserialize, Clone)]
|
||||
pub struct CommitRef {
|
||||
pub author: User,
|
||||
pub comments_url: String,
|
||||
pub commit: Commit,
|
||||
pub committer: User,
|
||||
pub html_url: String,
|
||||
pub parents: Vec<GitRef>,
|
||||
pub sha: String,
|
||||
pub url: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
pub struct Deployment {
|
||||
pub created_at: String,
|
||||
pub creator: User,
|
||||
pub description: Option<String>,
|
||||
pub environment: String,
|
||||
pub id: u64,
|
||||
pub payload: Value,
|
||||
#[serde(rename="ref")]
|
||||
pub _ref: String,
|
||||
pub repository_url: String,
|
||||
pub sha: String,
|
||||
pub statuses_url: String,
|
||||
pub task: String,
|
||||
pub updated_at: String,
|
||||
pub url: String,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Deserialize, Clone)]
|
||||
pub struct DeploymentStatus {
|
||||
pub created_at: String,
|
||||
pub creator: User,
|
||||
pub deployment_url: String,
|
||||
pub description: Option<String>,
|
||||
pub id: u64,
|
||||
pub repository_url: String,
|
||||
pub state: String,
|
||||
pub target_url: Option<String>,
|
||||
pub updated_at: String,
|
||||
pub url: String,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Deserialize, Clone)]
|
||||
pub struct CommitStats {
|
||||
pub added: Vec<String>,
|
||||
pub author: GitUser,
|
||||
pub committer: GitUser,
|
||||
pub distinct: bool,
|
||||
pub id: String,
|
||||
pub message: String,
|
||||
pub modified: Vec<String>,
|
||||
pub removed: Vec<String>,
|
||||
pub timestamp: String,
|
||||
pub tree_id: String,
|
||||
pub url: String,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Deserialize, Clone)]
|
||||
pub struct Hook {
|
||||
pub active: bool,
|
||||
pub config: Config,
|
||||
pub created_at: String,
|
||||
pub events: Vec<String>,
|
||||
pub id: u64,
|
||||
pub last_response: LastResponse,
|
||||
pub name: String,
|
||||
pub ping_url: String,
|
||||
pub test_url: String,
|
||||
pub _type: String,
|
||||
pub updated_at: String,
|
||||
pub url: String,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Deserialize, Clone)]
|
||||
pub struct Issue {
|
||||
pub assignee: Option<String>,
|
||||
pub body: Option<String>,
|
||||
pub closed_at: Option<String>,
|
||||
pub comments: u64,
|
||||
pub comments_url: String,
|
||||
pub created_at: String,
|
||||
pub events_url: String,
|
||||
pub html_url: String,
|
||||
pub id: u64,
|
||||
pub labels: Vec<Label>,
|
||||
pub labels_url: String,
|
||||
pub locked: bool,
|
||||
pub milestone: Option<String>,
|
||||
pub number: u64,
|
||||
pub state: String,
|
||||
pub title: String,
|
||||
pub updated_at: String,
|
||||
pub url: String,
|
||||
pub user: User,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Deserialize, Clone)]
|
||||
pub struct IssueCommentComment {
|
||||
pub body: String,
|
||||
pub created_at: String,
|
||||
pub html_url: String,
|
||||
pub id: u64,
|
||||
pub issue_url: String,
|
||||
pub updated_at: String,
|
||||
pub url: String,
|
||||
pub user: User,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Deserialize, Clone)]
|
||||
pub struct Organization {
|
||||
pub avatar_url: String,
|
||||
pub events_url: String,
|
||||
pub id: u64,
|
||||
pub login: String,
|
||||
pub members_url: String,
|
||||
pub public_members_url: String,
|
||||
pub repos_url: String,
|
||||
pub url: String,
|
||||
pub description: Option<String>
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Deserialize, Clone)]
|
||||
pub struct Pages {
|
||||
pub action: String,
|
||||
pub html_url: String,
|
||||
pub page_name: String,
|
||||
pub sha: String,
|
||||
pub summary: Option<String>,
|
||||
pub title: String,
|
||||
}
|
||||
|
||||
|
||||
#[derive(Default, Debug, Deserialize, Clone)]
|
||||
pub struct PullRequestDetails {
|
||||
pub _links: PullRequestLinks,
|
||||
pub assignee: Option<String>,
|
||||
pub base: PullSource,
|
||||
pub body: Option<String>,
|
||||
pub closed_at: Option<String>,
|
||||
pub comments_url: String,
|
||||
pub commits_url: String,
|
||||
pub created_at: String,
|
||||
pub diff_url: String,
|
||||
pub head: PullSource,
|
||||
pub html_url: String,
|
||||
pub id: u64,
|
||||
pub issue_url: String,
|
||||
pub locked: bool,
|
||||
pub merge_commit_sha: String,
|
||||
pub merged_at: Option<String>,
|
||||
pub milestone: Option<String>,
|
||||
pub number: u64,
|
||||
pub patch_url: String,
|
||||
pub review_comment_url: String,
|
||||
pub review_comments_url: String,
|
||||
pub state: String,
|
||||
pub statuses_url: String,
|
||||
pub title: String,
|
||||
pub updated_at: String,
|
||||
pub url: String,
|
||||
pub user: User,
|
||||
pub merged: bool,
|
||||
//mergeable": null,
|
||||
pub mergeable_state: String,
|
||||
//"merged_by": null,
|
||||
pub comments: u64,
|
||||
pub review_comments: u64,
|
||||
pub commits: u64,
|
||||
pub additions: u64,
|
||||
pub deletions: u64,
|
||||
pub changed_files: u64
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Deserialize, Clone)]
|
||||
pub struct PullRequest {
|
||||
pub _links: PullRequestLinks,
|
||||
pub assignee: Option<String>,
|
||||
pub base: PullSource,
|
||||
pub body: Option<String>,
|
||||
pub closed_at: Option<String>,
|
||||
pub comments_url: String,
|
||||
pub commits_url: String,
|
||||
pub created_at: String,
|
||||
pub diff_url: String,
|
||||
pub head: PullSource,
|
||||
pub html_url: String,
|
||||
pub id: u64,
|
||||
pub issue_url: String,
|
||||
pub locked: bool,
|
||||
pub merge_commit_sha: String,
|
||||
pub merged_at: Option<String>,
|
||||
pub milestone: Option<String>,
|
||||
pub number: u64,
|
||||
pub patch_url: String,
|
||||
pub review_comment_url: String,
|
||||
pub review_comments_url: String,
|
||||
pub state: String,
|
||||
pub statuses_url: String,
|
||||
pub title: String,
|
||||
pub updated_at: String,
|
||||
pub url: String,
|
||||
pub user: User,
|
||||
}
|
||||
|
||||
|
||||
#[derive(Default, Debug, Deserialize, Clone)]
|
||||
pub struct PullRequestReviewComment {
|
||||
#[serde(rename="_links")]
|
||||
pub _links: PullRequestReviewCommentLinks,
|
||||
pub body: String,
|
||||
pub commit_id: String,
|
||||
pub created_at: String,
|
||||
pub diff_hunk: String,
|
||||
pub html_url: String,
|
||||
pub id: u64,
|
||||
pub original_commit_id: String,
|
||||
pub original_position: u64,
|
||||
pub path: String,
|
||||
pub position: u64,
|
||||
pub pull_request_url: String,
|
||||
pub updated_at: String,
|
||||
pub url: String,
|
||||
pub user: User,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Deserialize, Clone)]
|
||||
pub struct Release {
|
||||
pub assets: Vec<String>,
|
||||
pub assets_url: String,
|
||||
pub author: User,
|
||||
pub body: Option<String>,
|
||||
pub created_at: String,
|
||||
pub draft: bool,
|
||||
pub html_url: String,
|
||||
pub id: u64,
|
||||
pub name: Option<String>,
|
||||
pub prerelease: bool,
|
||||
pub published_at: String,
|
||||
pub tag_name: String,
|
||||
pub tarball_url: String,
|
||||
pub target_commitish: String,
|
||||
pub upload_url: String,
|
||||
pub url: String,
|
||||
pub zipball_url: String,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Deserialize, Clone)]
|
||||
pub struct UserRef {
|
||||
pub name: String,
|
||||
pub email: Option<String>
|
||||
}
|
||||
|
||||
/// differs from Repository in owner type and some timestamp field types
|
||||
#[derive(Default, Debug, Deserialize, Clone)]
|
||||
pub struct PushRepository {
|
||||
pub archive_url: String,
|
||||
pub assignees_url: String,
|
||||
pub blobs_url: String,
|
||||
pub branches_url: String,
|
||||
pub clone_url: String,
|
||||
pub collaborators_url: String,
|
||||
pub comments_url: String,
|
||||
pub commits_url: String,
|
||||
pub compare_url: String,
|
||||
pub contents_url: String,
|
||||
pub contributors_url: String,
|
||||
pub created_at: u64,
|
||||
pub default_branch: String,
|
||||
pub description: String,
|
||||
pub downloads_url: String,
|
||||
pub events_url: String,
|
||||
pub fork: bool,
|
||||
pub forks_count: u64,
|
||||
pub forks_url: String,
|
||||
pub full_name: String,
|
||||
pub git_commits_url: String,
|
||||
pub git_refs_url: String,
|
||||
pub git_tags_url: String,
|
||||
pub git_url: String,
|
||||
pub has_downloads: bool,
|
||||
pub has_issues: bool,
|
||||
pub has_pages: bool,
|
||||
pub has_wiki: bool,
|
||||
pub homepage: Option<String>,
|
||||
pub hooks_url: String,
|
||||
pub html_url: String,
|
||||
pub id: u64,
|
||||
pub issue_comment_url: String,
|
||||
pub issue_events_url: String,
|
||||
pub issues_url: String,
|
||||
pub keys_url: String,
|
||||
pub labels_url: String,
|
||||
pub language: Option<String>,
|
||||
pub languages_url: String,
|
||||
pub merges_url: String,
|
||||
pub milestones_url: String,
|
||||
pub mirror_url: Option<String>,
|
||||
pub name: String,
|
||||
pub notifications_url: String,
|
||||
pub open_issues: u64,
|
||||
pub open_issues_count: u64,
|
||||
pub owner: UserRef,
|
||||
pub private: bool,
|
||||
pub pulls_url: String,
|
||||
pub pushed_at: u64,
|
||||
pub releases_url: String,
|
||||
pub size: u64,
|
||||
pub ssh_url: String,
|
||||
pub stargazers_count: u64,
|
||||
pub stargazers_url: String,
|
||||
pub statuses_url: String,
|
||||
pub subscribers_url: String,
|
||||
pub subscription_url: String,
|
||||
pub svn_url: String,
|
||||
pub tags_url: String,
|
||||
pub teams_url: String,
|
||||
pub trees_url: String,
|
||||
pub updated_at: String,
|
||||
pub url: String,
|
||||
pub watchers: u64,
|
||||
pub watchers_count: u64,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Deserialize, Clone)]
|
||||
pub struct Repository {
|
||||
pub archive_url: String,
|
||||
pub assignees_url: String,
|
||||
pub blobs_url: String,
|
||||
pub branches_url: String,
|
||||
pub clone_url: String,
|
||||
pub collaborators_url: String,
|
||||
pub comments_url: String,
|
||||
pub commits_url: String,
|
||||
pub compare_url: String,
|
||||
pub contents_url: String,
|
||||
pub contributors_url: String,
|
||||
pub created_at: String,
|
||||
pub default_branch: String,
|
||||
pub description: String,
|
||||
pub downloads_url: String,
|
||||
pub events_url: String,
|
||||
pub forks: u64,
|
||||
pub forks_count: u64,
|
||||
pub forks_url: String,
|
||||
pub full_name: String,
|
||||
pub git_commits_url: String,
|
||||
pub git_refs_url: String,
|
||||
pub git_tags_url: String,
|
||||
pub git_url: String,
|
||||
pub has_downloads: bool,
|
||||
pub has_issues: bool,
|
||||
pub has_pages: bool,
|
||||
pub has_wiki: bool,
|
||||
pub homepage: Option<String>,
|
||||
pub hooks_url: String,
|
||||
pub html_url: String,
|
||||
pub id: u64,
|
||||
pub issue_comment_url: String,
|
||||
pub issue_events_url: String,
|
||||
pub issues_url: String,
|
||||
pub keys_url: String,
|
||||
pub labels_url: String,
|
||||
pub language: Option<String>,
|
||||
pub languages_url: String,
|
||||
pub merges_url: String,
|
||||
pub milestones_url: String,
|
||||
pub mirror_url: Option<String>,
|
||||
pub name: String,
|
||||
pub notifications_url: String,
|
||||
pub open_issues: u64,
|
||||
pub open_issues_count: u64,
|
||||
pub owner: User,
|
||||
pub private: bool,
|
||||
pub pulls_url: String,
|
||||
pub pushed_at: String,
|
||||
pub releases_url: String,
|
||||
pub size: u64,
|
||||
pub ssh_url: String,
|
||||
pub stargazers_count: u64,
|
||||
pub stargazers_url: String,
|
||||
pub statuses_url: String,
|
||||
pub subscribers_url: String,
|
||||
pub subscription_url: String,
|
||||
pub svn_url: String,
|
||||
pub tags_url: String,
|
||||
pub teams_url: String,
|
||||
pub trees_url: String,
|
||||
pub updated_at: String,
|
||||
pub url: String,
|
||||
pub watchers: u64,
|
||||
pub watchers_count: u64,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Deserialize, Clone)]
|
||||
pub struct Team {
|
||||
pub id: u64,
|
||||
pub members_url: String,
|
||||
pub name: String,
|
||||
pub permission: String,
|
||||
pub repositories_url: String,
|
||||
pub slug: String,
|
||||
pub url: String,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Deserialize, Clone)]
|
||||
pub struct GitUser {
|
||||
pub email: String,
|
||||
pub name: String,
|
||||
pub username: Option<String>,
|
||||
pub date: Option<String>
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Deserialize, Clone)]
|
||||
pub struct Config {
|
||||
pub content_type: String,
|
||||
pub insecure_ssl: String,
|
||||
pub secret: String,
|
||||
pub url: String,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Deserialize, Clone)]
|
||||
pub struct Error {
|
||||
pub message: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Deserialize, Clone)]
|
||||
pub struct PullSource {
|
||||
pub label: String,
|
||||
#[serde(rename="ref")]
|
||||
pub _ref: String,
|
||||
pub repo: Repository,
|
||||
pub sha: String,
|
||||
pub user: User,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Deserialize, Clone)]
|
||||
pub struct Label {
|
||||
pub color: String,
|
||||
pub name: String,
|
||||
pub url: String,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Deserialize, Clone)]
|
||||
pub struct LastResponse {
|
||||
pub code: Option<String>,
|
||||
pub message: Option<String>,
|
||||
pub status: String,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Deserialize, Clone)]
|
||||
pub struct PullRequestLinks {
|
||||
pub comments: Link,
|
||||
pub commits: Link,
|
||||
pub html: Link,
|
||||
pub issue: Link,
|
||||
pub review_comment: Link,
|
||||
pub review_comments: Link,
|
||||
#[serde(rename="self")]
|
||||
pub _self: Link,
|
||||
pub statuses: Link,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Deserialize, Clone)]
|
||||
pub struct PullRequestInnerBase {
|
||||
pub label: String,
|
||||
#[serde(rename="ref")]
|
||||
pub _ref: String,
|
||||
pub repo: Repository,
|
||||
pub sha: String,
|
||||
pub user: User,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Deserialize, Clone)]
|
||||
pub struct PullRequestInnerHead {
|
||||
pub label: String,
|
||||
#[serde(rename="ref")]
|
||||
pub _ref: String,
|
||||
pub repo: Repository,
|
||||
pub sha: String,
|
||||
pub user: User,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Deserialize, Clone)]
|
||||
pub struct PullRequestReviewCommentLinks {
|
||||
pub html: Link,
|
||||
pub pull_request: Link,
|
||||
#[serde(rename="self")]
|
||||
pub _self: Link,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Deserialize, Clone)]
|
||||
pub struct User {
|
||||
pub avatar_url: String,
|
||||
pub events_url: String,
|
||||
pub followers_url: String,
|
||||
pub following_url: String,
|
||||
pub gists_url: String,
|
||||
pub gravatar_id: String,
|
||||
pub html_url: String,
|
||||
pub id: u64,
|
||||
pub login: String,
|
||||
pub organizations_url: String,
|
||||
pub received_events_url: String,
|
||||
pub repos_url: String,
|
||||
pub site_admin: bool,
|
||||
pub starred_url: String,
|
||||
pub subscriptions_url: String,
|
||||
#[serde(rename="type")]
|
||||
pub _type: String,
|
||||
pub url: String,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Deserialize, Clone)]
|
||||
pub struct Link {
|
||||
pub href: String,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Deserialize, Clone)]
|
||||
pub struct GitRef {
|
||||
pub sha: String,
|
||||
pub url: String,
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
use actix_web::{web, Scope};
|
||||
use actix_web::Scope;
|
||||
|
||||
mod github;
|
||||
pub mod github;
|
||||
|
||||
|
||||
pub fn get_scope() -> Scope {
|
||||
|
|
Loading…
Reference in New Issue
Block a user