ore_types/
response.rs

1use chrono::NaiveDateTime;
2use serde::{Deserialize, Serialize};
3
4#[cfg(feature = "redis")]
5use redis_derive::{FromRedisValue, ToRedisArgs};
6
7/// Response for a successful login, containing the JWT.
8#[derive(Serialize, Deserialize, Debug, Clone)]
9pub struct AuthResponse {
10    pub token: String,
11}
12
13/// Response after successfully sending a chat message.
14#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq)]
15pub struct ChatSendMessageResponse {
16    pub status: String,
17    pub message: String,
18}
19
20#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
21pub struct User {
22    pub authority: String,
23    pub username: String,
24    pub profile_photo_url: Option<String>,
25    pub discord_user: Option<DiscordUser>,
26    pub updated_at: NaiveDateTime,
27    pub risk_score: i64,
28    pub is_banned: bool,
29    pub role: Option<String>,
30}
31
32// Notifications
33
34#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
35#[cfg_attr(feature = "redis", derive(FromRedisValue, ToRedisArgs))]
36pub struct ChatNotification {
37    pub authority: String,
38    pub username: String,
39    pub text: String,
40    pub id: u64,
41    pub ts: i64,
42    pub profile_photo_url: Option<String>,
43    pub role: Option<String>,
44    pub discord_user_id: Option<String>,
45}
46
47#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
48pub struct ResetNotification {
49    pub block_id: u64,
50}
51
52#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
53pub enum Notification {
54    Chat(ChatNotification),
55    Reset(ResetNotification),
56}
57
58impl Notification {
59    pub fn id(&self) -> String {
60        match self {
61            Notification::Chat(chat) => chat.id.to_string(),
62            Notification::Reset(reset) => reset.block_id.to_string(),
63        }
64    }
65}
66
67#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
68pub struct DailyRevenue {
69    pub day: String,
70    pub revenue: i64,
71}
72
73// Username validation
74
75#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
76pub struct UsernameValidationResponse {
77    pub valid: bool,
78    pub error: Option<String>,
79}
80
81impl UsernameValidationResponse {
82    pub fn valid() -> Self {
83        Self {
84            valid: true,
85            error: None,
86        }
87    }
88
89    pub fn invalid(error: String) -> Self {
90        Self {
91            valid: false,
92            error: Some(error),
93        }
94    }
95}
96
97/// Response for a successful Discord authentication.
98#[derive(Serialize, Deserialize, Debug, Clone)]
99pub struct DiscordAuthResponse {
100    pub access_token: String,
101}
102
103#[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
104pub struct DiscordUser {
105    pub id: String,
106    pub username: String,
107    pub discriminator: String,
108    #[serde(default, skip_serializing_if = "Option::is_none")]
109    pub global_name: Option<String>,
110    #[serde(default, skip_serializing_if = "Option::is_none")]
111    pub avatar: Option<String>,
112    #[serde(default, skip_serializing_if = "Option::is_none")]
113    pub verified: Option<bool>,
114    #[serde(default, skip_serializing_if = "Option::is_none")]
115    pub email: Option<String>,
116}
117
118#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
119pub struct OreBalance {
120    pub wallet: u64,
121    pub staked: u64,
122    pub unrefined: u64,
123    pub refined: u64,
124}