Modrinth/src/models/v2/reports.rs
Wyatt Verchere d59c522f7f
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>
2023-12-19 10:20:32 -08:00

53 lines
1.3 KiB
Rust

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,
}
}
}