Add basic models

Signed-off-by: Lee Smet <lee.smet@hotmail.com>
This commit is contained in:
Lee Smet
2025-08-20 14:04:08 +02:00
parent b769fa63f7
commit acf875ed33
10 changed files with 225 additions and 0 deletions

54
src/models/message.rs Normal file
View File

@@ -0,0 +1,54 @@
use serde::{Deserialize, Serialize};
use crate::{
models::{Job, ScriptType},
time::Timestamp,
};
#[derive(Serialize, Deserialize)]
pub struct Message {
/// Unique ID for the message, set by the caller
id: u32,
/// Id of the actor who sent this message
caller_id: u32,
/// Id of the context in which this message was sent
context_id: u32,
message: String,
message_type: ScriptType,
message_format_type: MessageFormatType,
/// Seconds for the message to arrive at the destination
timeout: u32,
/// Seconds for the receiver to acknowledge receipt of the message
timeout_ack: u32,
/// Seconds for the receiver to send us a reply
timeout_result: u32,
job: Vec<Job>,
logs: Vec<Log>,
created_at: Timestamp,
updated_at: Timestamp,
status: MessageStatus,
}
#[derive(Serialize, Deserialize)]
pub enum MessageType {
Job,
Chat,
Mail,
}
#[derive(Serialize, Deserialize)]
pub enum MessageStatus {
Dispatched,
Acknowledged,
Error,
Processed,
}
#[derive(Serialize, Deserialize)]
pub enum MessageFormatType {
Html,
Text,
Md,
}
type Log = String;