You've already forked AstralRinth
forked from didirus/AstralRinth
Sanity checked all of V2 route conversions (#803)
* follows * all v2 routes now either convert or have a comment * added common structs, clippy * merge fix --------- Co-authored-by: Geometrically <18202329+Geometrically@users.noreply.github.com>
This commit is contained in:
52
src/models/v2/reports.rs
Normal file
52
src/models/v2/reports.rs
Normal file
@@ -0,0 +1,52 @@
|
||||
use crate::models::ids::{ReportId, ThreadId, UserId};
|
||||
use crate::models::reports::{ItemType, Report};
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct LegacyReport {
|
||||
pub id: ReportId,
|
||||
pub report_type: String,
|
||||
pub item_id: String,
|
||||
pub item_type: LegacyItemType,
|
||||
pub reporter: UserId,
|
||||
pub body: String,
|
||||
pub created: DateTime<Utc>,
|
||||
pub closed: bool,
|
||||
pub thread_id: ThreadId,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub enum LegacyItemType {
|
||||
Project,
|
||||
Version,
|
||||
User,
|
||||
Unknown,
|
||||
}
|
||||
impl From<ItemType> for LegacyItemType {
|
||||
fn from(x: ItemType) -> Self {
|
||||
match x {
|
||||
ItemType::Project => LegacyItemType::Project,
|
||||
ItemType::Version => LegacyItemType::Version,
|
||||
ItemType::User => LegacyItemType::User,
|
||||
ItemType::Unknown => LegacyItemType::Unknown,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Report> for LegacyReport {
|
||||
fn from(x: Report) -> Self {
|
||||
LegacyReport {
|
||||
id: x.id,
|
||||
report_type: x.report_type,
|
||||
item_id: x.item_id,
|
||||
item_type: x.item_type.into(),
|
||||
reporter: x.reporter,
|
||||
body: x.body,
|
||||
created: x.created,
|
||||
closed: x.closed,
|
||||
thread_id: x.thread_id,
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user