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 text: String,
28    pub id: u64,
29    pub ts: i64,
30}
31
32#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
33pub struct ResetNotification {
34    pub block_id: u64,
35}
36
37#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
38pub enum Notification {
39    Chat(ChatNotification),
40    Reset(ResetNotification),
41}
42
43impl Notification {
44    pub fn id(&self) -> String {
45        match self {
46            Notification::Chat(chat) => chat.id.to_string(),
47            Notification::Reset(reset) => reset.block_id.to_string(),
48        }
49    }
50}