first comment ! :D
This commit is contained in:
+18
-2
@@ -1,3 +1,5 @@
|
||||
use std::time::Duration;
|
||||
|
||||
use crate::{
|
||||
env::EnvConfig,
|
||||
errors::AppError,
|
||||
@@ -12,7 +14,7 @@ pub struct Bot {
|
||||
impl Bot {
|
||||
pub fn new(config: EnvConfig) -> Self {
|
||||
Self {
|
||||
gitea_api: GiteaAPI::new(&config.gitea_url),
|
||||
gitea_api: GiteaAPI::new(&config.gitea_url, &config.gitea_token),
|
||||
config,
|
||||
}
|
||||
}
|
||||
@@ -36,11 +38,25 @@ impl Bot {
|
||||
|
||||
match exec_result {
|
||||
Ok(_) => println!("Task completed"),
|
||||
Err(_) => println!("Task errored"),
|
||||
Err(err) => println!("{}", err),
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn exec_review(&self, review_payload: ReviewPayload) -> Result<(), AppError> {
|
||||
let new_comment = self
|
||||
.gitea_api
|
||||
.comment(
|
||||
&review_payload.repository.full_name,
|
||||
review_payload.pull_request.number,
|
||||
)
|
||||
.await?;
|
||||
|
||||
tokio::time::sleep(Duration::from_secs(10)).await;
|
||||
|
||||
self.gitea_api
|
||||
.edit_comment(&review_payload.repository.full_name, new_comment.id)
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user