use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize, PartialEq, Clone)]
pub struct ThreadComment {
pub id: i64,
pub body: String,
pub user: User,
}
#[derive(Debug, Deserialize, PartialEq, Clone)]
pub struct User {
pub login: String,
pub id: u64,
}
#[derive(Debug, Serialize, PartialEq, Clone)]
pub struct FullReview {
pub body: String,
pub comments: Vec<ReviewDiffComment>,
pub commit_id: String,
pub event: String,
}
#[derive(Debug, Serialize, PartialEq, Clone)]
pub struct ReviewDiffComment {
pub body: String,
pub new_position: i64,
pub old_position: i64,
pub path: String,
}
impl From<&crate::ReviewComment> for ReviewDiffComment {
fn from(comment: &crate::ReviewComment) -> Self {
Self {
body: comment.comment.clone(),
new_position: comment.line_end as i64,
old_position: comment.line_start.map(|i| i as i64).unwrap_or_default(),
path: comment.path.clone(),
}
}
}
#[derive(Debug, Deserialize, PartialEq, Clone, Copy)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum ReviewState {
Approved,
Pending,
Comment,
RequestChanges,
RequestReview,
}
#[derive(Debug, Deserialize, PartialEq, Clone)]
pub struct ReviewInfo {
pub id: i64,
pub body: String,
pub user: User,
pub state: ReviewState,
#[serde(default)]
pub comments: Vec<GiteaReviewComment>,
pub comments_count: i64,
}
#[derive(Debug, Deserialize, PartialEq, Clone)]
pub struct GiteaReviewComment {
pub id: i64,
pub path: String,
#[serde(default)]
pub old_position: i64,
#[serde(default)]
pub new_position: i64,
pub body: String,
}