started gitea api impl

This commit is contained in:
2026-06-02 19:52:50 +00:00
parent 1f60f6572f
commit 10ebee389e
6 changed files with 91 additions and 21 deletions
+36 -3
View File
@@ -1,13 +1,46 @@
use crate::{env::EnvConfig, gitea::WebhookType};
use crate::{
env::EnvConfig,
errors::AppError,
gitea::{GiteaAPI, ReviewPayload, WebhookType},
};
pub struct Bot {
config: EnvConfig,
gitea_api: GiteaAPI,
}
impl Bot {
pub fn new(config: EnvConfig) -> Self {
Self { config }
Self {
gitea_api: GiteaAPI::new(&config.gitea_url),
config,
}
}
pub async fn exec(&self, webhook: WebhookType) {}
pub async fn start(
&self,
mut rx: tokio::sync::mpsc::Receiver<WebhookType>,
) -> anyhow::Result<()> {
while let Some(wb) = rx.recv().await {
self.exec(wb).await;
}
Ok(())
}
pub async fn exec(&self, webhook: WebhookType) {
let exec_result = match webhook {
WebhookType::Review(review_payload) => self.exec_review(review_payload),
}
.await;
match exec_result {
Ok(_) => println!("Task completed"),
Err(_) => println!("Task errored"),
}
}
pub async fn exec_review(&self, review_payload: ReviewPayload) -> Result<(), AppError> {
Ok(())
}
}