2021-04-13 12:14:07 -06:00
|
|
|
use chrono::Utc;
|
2022-04-22 12:24:38 -06:00
|
|
|
use serde::{Deserialize, Serialize};
|
2022-10-07 21:33:07 -06:00
|
|
|
use std::borrow::Cow;
|
2021-04-13 12:14:07 -06:00
|
|
|
|
2021-04-20 10:07:11 -06:00
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
2022-04-12 16:06:19 -06:00
|
|
|
pub struct UserResponse {
|
|
|
|
pub username: String,
|
2021-04-20 10:07:11 -06:00
|
|
|
}
|
2021-04-13 12:14:07 -06:00
|
|
|
|
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
2022-04-12 16:06:19 -06:00
|
|
|
pub struct RegisterRequest {
|
|
|
|
pub email: String,
|
|
|
|
pub username: String,
|
|
|
|
pub password: String,
|
2021-04-13 12:14:07 -06:00
|
|
|
}
|
|
|
|
|
2021-04-20 10:07:11 -06:00
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
2022-04-12 16:06:19 -06:00
|
|
|
pub struct RegisterResponse {
|
|
|
|
pub session: String,
|
2021-04-20 10:07:11 -06:00
|
|
|
}
|
|
|
|
|
2021-04-13 12:14:07 -06:00
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
2022-04-12 16:06:19 -06:00
|
|
|
pub struct LoginRequest {
|
|
|
|
pub username: String,
|
|
|
|
pub password: String,
|
2021-04-13 12:14:07 -06:00
|
|
|
}
|
|
|
|
|
2021-04-20 10:07:11 -06:00
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
2022-04-12 16:06:19 -06:00
|
|
|
pub struct LoginResponse {
|
|
|
|
pub session: String,
|
2021-04-20 10:07:11 -06:00
|
|
|
}
|
|
|
|
|
2021-04-13 12:14:07 -06:00
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
2022-04-12 16:06:19 -06:00
|
|
|
pub struct AddHistoryRequest {
|
|
|
|
pub id: String,
|
2021-04-13 12:14:07 -06:00
|
|
|
pub timestamp: chrono::DateTime<Utc>,
|
2022-04-12 16:06:19 -06:00
|
|
|
pub data: String,
|
|
|
|
pub hostname: String,
|
2021-04-13 12:14:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
|
|
|
pub struct CountResponse {
|
|
|
|
pub count: i64,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
2022-04-12 16:06:19 -06:00
|
|
|
pub struct SyncHistoryRequest {
|
2021-04-20 10:07:11 -06:00
|
|
|
pub sync_ts: chrono::DateTime<chrono::FixedOffset>,
|
|
|
|
pub history_ts: chrono::DateTime<chrono::FixedOffset>,
|
2022-04-12 16:06:19 -06:00
|
|
|
pub host: String,
|
2021-04-20 10:07:11 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
|
|
|
pub struct SyncHistoryResponse {
|
2021-04-13 12:14:07 -06:00
|
|
|
pub history: Vec<String>,
|
|
|
|
}
|
2022-10-07 21:33:07 -06:00
|
|
|
|
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
|
|
|
pub struct ErrorResponse<'a> {
|
|
|
|
pub reason: Cow<'a, str>,
|
|
|
|
}
|
2022-10-14 03:59:21 -06:00
|
|
|
|
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
|
|
|
pub struct IndexResponse {
|
|
|
|
pub homage: String,
|
|
|
|
pub version: String,
|
|
|
|
}
|
2022-11-04 03:08:20 -06:00
|
|
|
|
|
|
|
// Doubled up with the history sync stuff, because atm we need to support BOTH.
|
|
|
|
// People are still running old clients, and in some cases _very_ old clients.
|
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
|
|
|
pub enum AddEventRequest {
|
|
|
|
Create(AddHistoryRequest),
|
|
|
|
|
|
|
|
Delete {
|
|
|
|
id: String,
|
|
|
|
timestamp: chrono::DateTime<Utc>,
|
|
|
|
hostname: chrono::DateTime<Utc>,
|
|
|
|
|
|
|
|
// When we delete a history item, we push up an event marking its client
|
|
|
|
// id as being deleted.
|
|
|
|
history_id: String,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
|
|
|
pub struct SyncEventRequest {
|
|
|
|
pub sync_ts: chrono::DateTime<chrono::FixedOffset>,
|
|
|
|
pub event_ts: chrono::DateTime<chrono::FixedOffset>,
|
|
|
|
pub host: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
|
|
|
pub struct SyncEventResponse {
|
|
|
|
pub events: Vec<String>,
|
|
|
|
}
|