70 lines
1.6 KiB
Rust
70 lines
1.6 KiB
Rust
use serde::{Deserialize, Serialize};
|
|
|
|
use crate::{
|
|
models::{Job, ScriptType},
|
|
time::Timestamp,
|
|
};
|
|
|
|
#[derive(Clone, Serialize, Deserialize)]
|
|
pub struct Message {
|
|
/// Unique ID for the message, set by the caller
|
|
pub id: u32,
|
|
/// Id of the actor who sent this message
|
|
pub caller_id: u32,
|
|
/// Id of the context in which this message was sent
|
|
pub context_id: u32,
|
|
pub message: String,
|
|
pub message_type: ScriptType,
|
|
pub message_format_type: MessageFormatType,
|
|
/// Seconds for the message to arrive at the destination
|
|
pub timeout: u32,
|
|
/// Seconds for the receiver to acknowledge receipt of the message
|
|
pub timeout_ack: u32,
|
|
/// Seconds for the receiver to send us a reply
|
|
pub timeout_result: u32,
|
|
|
|
/// Outbound transport id returned by Mycelium on push
|
|
pub transport_id: Option<String>,
|
|
/// Latest transport status as reported by Mycelium
|
|
pub transport_status: Option<TransportStatus>,
|
|
|
|
pub job: Vec<Job>,
|
|
pub logs: Vec<Log>,
|
|
pub created_at: Timestamp,
|
|
pub updated_at: Timestamp,
|
|
pub status: MessageStatus,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub enum MessageType {
|
|
Job,
|
|
Chat,
|
|
Mail,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
|
pub enum MessageStatus {
|
|
Dispatched,
|
|
Acknowledged,
|
|
Error,
|
|
Processed,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
|
pub enum TransportStatus {
|
|
Queued,
|
|
Sent,
|
|
Delivered,
|
|
Read,
|
|
Failed,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub enum MessageFormatType {
|
|
Html,
|
|
Text,
|
|
Md,
|
|
}
|
|
|
|
type Log = String;
|