ore_types/
response.rs

1use chrono::NaiveDateTime;
2use redis_derive::{FromRedisValue, ToRedisArgs};
3use serde::{Deserialize, Serialize};
4
5/// Response for a successful login, containing the JWT.
6#[derive(Serialize, Deserialize, Debug, Clone)]
7pub struct AuthResponse {
8    pub token: String,
9}
10
11/// Response after successfully sending a chat message.
12#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq)]
13pub struct ChatSendMessageResponse {
14    pub status: String,
15    pub message: String,
16}
17
18#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
19pub struct User {
20    pub authority: String,
21    pub username: String,
22    pub profile_photo_url: Option<String>,
23    pub updated_at: NaiveDateTime,
24    pub risk_score: i64,
25    pub is_banned: bool,
26    pub role: Option<String>,
27}
28
29// Notifications
30
31#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, FromRedisValue, ToRedisArgs)]
32pub struct ChatNotification {
33    pub authority: String,
34    pub username: String,
35    pub text: String,
36    pub id: u64,
37    pub ts: i64,
38    pub profile_photo_url: Option<String>,
39    pub role: Option<String>,
40}
41
42#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
43pub struct ResetNotification {
44    pub block_id: u64,
45}
46
47#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
48pub enum Notification {
49    Chat(ChatNotification),
50    Reset(ResetNotification),
51}
52
53impl Notification {
54    pub fn id(&self) -> String {
55        match self {
56            Notification::Chat(chat) => chat.id.to_string(),
57            Notification::Reset(reset) => reset.block_id.to_string(),
58        }
59    }
60}
61
62#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
63pub struct DailyRevenue {
64    pub day: String,
65    pub revenue: i64,
66}
67
68// Username validation
69
70#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
71pub struct UsernameValidationResponse {
72    pub valid: bool,
73    pub error: Option<String>,
74}
75
76impl UsernameValidationResponse {
77    pub fn valid() -> Self {
78        Self {
79            valid: true,
80            error: None,
81        }
82    }
83
84    pub fn invalid(error: String) -> Self {
85        Self {
86            valid: false,
87            error: Some(error),
88        }
89    }
90}
91
92/// Response for a successful Discord authentication.
93#[derive(Serialize, Deserialize, Debug, Clone)]
94pub struct DiscordAuthResponse {
95    pub access_token: String,
96}