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 updated_at: NaiveDateTime,
26    pub risk_score: i64,
27    pub is_banned: bool,
28    pub role: Option<String>,
29}
30
31// Notifications
32
33#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
34#[cfg_attr(feature = "redis", derive(FromRedisValue, ToRedisArgs))]
35pub struct ChatNotification {
36    pub authority: String,
37    pub username: String,
38    pub text: String,
39    pub id: u64,
40    pub ts: i64,
41    pub profile_photo_url: Option<String>,
42    pub role: Option<String>,
43}
44
45#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
46pub struct ResetNotification {
47    pub block_id: u64,
48}
49
50#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
51pub enum Notification {
52    Chat(ChatNotification),
53    Reset(ResetNotification),
54}
55
56impl Notification {
57    pub fn id(&self) -> String {
58        match self {
59            Notification::Chat(chat) => chat.id.to_string(),
60            Notification::Reset(reset) => reset.block_id.to_string(),
61        }
62    }
63}
64
65#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
66pub struct DailyRevenue {
67    pub day: String,
68    pub revenue: i64,
69}
70
71// Username validation
72
73#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
74pub struct UsernameValidationResponse {
75    pub valid: bool,
76    pub error: Option<String>,
77}
78
79impl UsernameValidationResponse {
80    pub fn valid() -> Self {
81        Self {
82            valid: true,
83            error: None,
84        }
85    }
86
87    pub fn invalid(error: String) -> Self {
88        Self {
89            valid: false,
90            error: Some(error),
91        }
92    }
93}
94
95/// Response for a successful Discord authentication.
96#[derive(Serialize, Deserialize, Debug, Clone)]
97pub struct DiscordAuthResponse {
98    pub access_token: String,
99}