started gitea api impl
This commit is contained in:
@@ -3,6 +3,26 @@ use serde_json::Value;
|
||||
|
||||
use crate::errors::AppError;
|
||||
|
||||
pub struct GiteaAPI {
|
||||
base_url: String,
|
||||
}
|
||||
|
||||
impl GiteaAPI {
|
||||
pub fn new(base_url: &str) -> Self {
|
||||
Self {
|
||||
base_url: String::from(base_url),
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn comment(&self, full_name: &str, index: u64) -> anyhow::Result<u64> {
|
||||
Ok(1)
|
||||
}
|
||||
|
||||
pub async fn edit_comment(&self, full_name: &str, id: u64) -> anyhow::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum WebhookType {
|
||||
Review(ReviewPayload),
|
||||
@@ -12,6 +32,7 @@ pub enum WebhookType {
|
||||
pub struct ReviewPayload {
|
||||
pub action: String,
|
||||
pub pull_request: PullRequest,
|
||||
pub repository: Repository,
|
||||
pub comment: Comment,
|
||||
}
|
||||
|
||||
@@ -33,6 +54,11 @@ pub struct User {
|
||||
pub id: u64,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
pub struct Repository {
|
||||
pub full_name: String,
|
||||
}
|
||||
|
||||
impl WebhookType {
|
||||
pub fn from_event(event: &str, bot_name: &str, json: Value) -> Result<Self, AppError> {
|
||||
let wb = match event {
|
||||
|
||||
Reference in New Issue
Block a user