ore_types/
response.rs

1use serde::{Deserialize, Serialize};
2
3/// Response for a successful login, containing the JWT.
4#[derive(Serialize, Deserialize, Debug, Clone)]
5pub struct AuthResponse {
6    pub token: String,
7}
8
9/// Response after successfully sending a chat message.
10#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq)]
11pub struct ChatSendMessageResponse {
12    pub status: String,
13    pub message: String,
14}
15
16#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
17pub struct User {
18    pub authority: String,
19    pub username: String,
20}
21
22// Notifications
23
24#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
25pub struct ChatNotification {
26    pub authority: String,
27    pub username: String,
28    pub text: String,
29    pub id: u64,
30    pub ts: i64,
31}
32
33#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
34pub struct ResetNotification {
35    pub block_id: u64,
36}
37
38#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
39pub enum Notification {
40    Chat(ChatNotification),
41    Reset(ResetNotification),
42}
43
44impl Notification {
45    pub fn id(&self) -> String {
46        match self {
47            Notification::Chat(chat) => chat.id.to_string(),
48            Notification::Reset(reset) => reset.block_id.to_string(),
49        }
50    }
51}