98 lines
2.0 KiB
Rust
98 lines
2.0 KiB
Rust
use serde::{Deserialize, Serialize};
|
|
use sqlx::types::chrono::NaiveDateTime;
|
|
use uuid::Uuid;
|
|
|
|
#[derive(Debug, Deserialize)]
|
|
pub struct Message {
|
|
pub territory: u32,
|
|
pub x: f32,
|
|
pub y: f32,
|
|
pub z: f32,
|
|
#[serde(default)]
|
|
pub yaw: f32,
|
|
|
|
pub pack_id: Uuid,
|
|
pub template_1: usize,
|
|
pub word_1_list: Option<usize>,
|
|
pub word_1_word: Option<usize>,
|
|
pub conjunction: Option<usize>,
|
|
pub template_2: Option<usize>,
|
|
pub word_2_list: Option<usize>,
|
|
pub word_2_word: Option<usize>,
|
|
|
|
#[serde(default = "glyph_default")]
|
|
pub glyph: i8,
|
|
|
|
#[serde(default)]
|
|
pub world: Option<u32>,
|
|
#[serde(default)]
|
|
pub ward: Option<u16>,
|
|
#[serde(default)]
|
|
pub plot: Option<u16>,
|
|
}
|
|
|
|
fn glyph_default() -> i8 {
|
|
3
|
|
}
|
|
|
|
#[derive(Debug, Serialize)]
|
|
pub struct RetrievedMessage {
|
|
pub id: String,
|
|
pub x: f64,
|
|
pub y: f64,
|
|
pub z: f64,
|
|
pub yaw: f64,
|
|
pub message: String,
|
|
pub positive_votes: i32,
|
|
pub negative_votes: i32,
|
|
pub user_vote: i64,
|
|
pub glyph: i64,
|
|
#[serde(skip)]
|
|
pub created: NaiveDateTime,
|
|
#[serde(skip)]
|
|
pub user: i64,
|
|
#[serde(skip)]
|
|
pub last_seen_minutes: i64,
|
|
}
|
|
|
|
#[derive(Debug, Serialize)]
|
|
pub struct RetrievedMessageTerritory {
|
|
pub id: String,
|
|
pub territory: i64,
|
|
pub world: Option<i64>,
|
|
pub ward: Option<i64>,
|
|
pub plot: Option<i64>,
|
|
pub x: f64,
|
|
pub y: f64,
|
|
pub z: f64,
|
|
pub yaw: f64,
|
|
pub message: String,
|
|
pub positive_votes: i32,
|
|
pub negative_votes: i32,
|
|
pub user_vote: i64,
|
|
pub glyph: i64,
|
|
#[serde(skip)]
|
|
pub created: NaiveDateTime,
|
|
}
|
|
|
|
#[derive(Debug, Serialize)]
|
|
pub struct OwnMessage {
|
|
pub id: String,
|
|
pub territory: i64,
|
|
pub world: Option<i64>,
|
|
pub ward: Option<i64>,
|
|
pub plot: Option<i64>,
|
|
pub x: f64,
|
|
pub y: f64,
|
|
pub z: f64,
|
|
pub yaw: f64,
|
|
pub message: String,
|
|
pub positive_votes: i32,
|
|
pub negative_votes: i32,
|
|
pub user_vote: i64,
|
|
pub glyph: i64,
|
|
#[serde(skip)]
|
|
pub created: NaiveDateTime,
|
|
pub is_hidden: bool,
|
|
}
|