1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#![doc = include_str!("../../docs/server_sync.md")]

use serde::{Deserialize, Serialize};

use super::id::*;

#[derive(Debug, Serialize, Deserialize)]
#[serde(transparent)]
#[repr(transparent)]
struct Signature(pub String);

#[derive(Debug, Serialize, Deserialize)]
pub struct MessagePushRequest {
    // prev_message_id: MessageId,
    /// signature of this message (using the key issued by the server)
    signature: Signature,
    /// the message the user wants to send
    message: String,
    /// user who wants to send a message
    sender: UserId,
    /// receiver id (channel id or user id)
    receiver: SubjectId,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct MessagePushResponse {
    /// status info (send success or fail)
    status: String,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct GetMissingMessageRequest {
    /// the server name of the server that the user in
    origin: ServerName,
    /// users who want to get message
    receiver: UserId,
    /// the subject of the message to the user
    sender: SubjectId,
    /// range of messages to get
    // maybe timestamp
    lower_message: MessageId,
    upper_message: Option<MessageId>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct GetMissingMessageResponse {
    message: String,
}