shared/domain/jig/
report.rsuse chrono::{DateTime, Utc};
use macros::make_path_parts;
use serde::{Deserialize, Serialize};
use strum_macros::EnumIter;
use uuid::Uuid;
use crate::api::endpoints::PathPart;
use super::JigId;
wrap_uuid! {
pub struct ReportId
}
make_path_parts!(GetJigReportPath => "/v1/jig/{}/report/{}" => JigId, ReportId);
#[derive(Serialize, Deserialize, Clone, Debug)]
#[cfg_attr(feature = "backend", derive(sqlx::Type))]
#[serde(rename_all = "camelCase")]
pub struct JigReport {
pub id: ReportId,
pub jig_id: JigId,
pub report_type: JigReportType,
#[serde(skip_serializing_if = "Option::is_none")]
pub reporter_id: Option<Uuid>,
#[serde(skip_serializing_if = "Option::is_none")]
pub reporter_name: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub reporter_email: Option<String>,
pub created_at: DateTime<Utc>,
}
make_path_parts!(CreateJigReportPath => "/v1/jig/{}/report" => JigId);
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct CreateJigReport {
pub report_type: JigReportType,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct JigReportEmail {
pub display_name: String,
pub report_type: JigReportType,
pub reporter_name: Option<String>,
pub reporter_email: Option<String>,
pub creator_name: String,
}
#[derive(Serialize, Deserialize, Copy, Clone, Eq, PartialEq, Debug, EnumIter)]
#[cfg_attr(feature = "backend", derive(sqlx::Type))]
#[serde(rename_all = "camelCase")]
#[repr(i16)]
pub enum JigReportType {
#[allow(missing_docs)]
Offensive = 0,
#[allow(missing_docs)]
CopyrightInfringement = 1,
#[allow(missing_docs)]
Spam = 2,
#[allow(missing_docs)]
Privacy = 3,
#[allow(missing_docs)]
JiTapGameNotPlaying = 4,
#[allow(missing_docs)]
Other = 5,
}
impl JigReportType {
#[allow(missing_docs)]
pub fn as_str(&self) -> &'static str {
match self {
JigReportType::Offensive => "Offensive",
JigReportType::CopyrightInfringement => "Copyright Infringement",
JigReportType::Spam => "Spam",
JigReportType::Privacy => "Privacy",
JigReportType::JiTapGameNotPlaying => "Ji Tap Game Not Playing",
JigReportType::Other => "Other",
}
}
#[allow(missing_docs)]
pub fn to_value_str(&self) -> String {
serde_json::to_string(&self).unwrap()
}
#[allow(missing_docs)]
pub fn from_value_str(s: &str) -> Self {
serde_json::from_str(s).unwrap()
}
}