session-open-group-server/src/models.rs

28 lines
621 B
Rust
Raw Normal View History

2021-03-10 03:08:34 +01:00
use serde::{Deserialize, Serialize};
2021-03-19 06:44:07 +01:00
#[derive(Debug, Deserialize, Serialize)]
2021-03-10 03:08:34 +01:00
pub struct Message {
2021-03-10 04:21:44 +01:00
pub server_id: Option<i64>,
2021-03-24 03:54:00 +01:00
pub public_key: Option<String>,
2021-03-26 00:21:08 +01:00
pub timestamp: i64,
2021-03-22 03:25:14 +01:00
pub data: String,
2021-03-25 01:38:06 +01:00
pub signature: String,
2021-03-10 03:08:34 +01:00
}
impl Message {
2021-03-25 01:38:06 +01:00
pub fn is_valid(&self) -> bool {
2021-03-26 00:21:08 +01:00
return self.timestamp > 0 && !self.data.is_empty() && !self.signature.is_empty();
2021-03-25 01:38:06 +01:00
}
2021-03-10 03:08:34 +01:00
}
2021-03-19 06:44:07 +01:00
#[derive(Debug, Deserialize, Serialize)]
pub struct Challenge {
pub ciphertext: String,
2021-03-25 01:38:06 +01:00
pub ephemeral_public_key: String,
2021-03-19 06:44:07 +01:00
}
#[derive(Debug, Deserialize, Serialize)]
pub struct StatusCode {
2021-03-25 01:38:06 +01:00
pub status_code: u16,
}