aboutsummaryrefslogblamecommitdiffstats
path: root/filamento/src/chat.rs
blob: 557b42bd24179a9b1ba46a6bfc6b3b88bf052ed3 (plain) (tree)
1
2
3
4
5
6
7
8
9
                            
             

               
                       
                    

                                             
                         
                  
                                   
                                 


                              
                   

 










                             





                        
                       
                 
                                               
                     

 
                       
                 
                           
                           


                                                                                                               

                                                                   

 

                      
           




                                                                



                                         

 
                    




                          
use chrono::{DateTime, Utc};
use jid::JID;
use uuid::Uuid;

#[derive(Debug, Clone)]
pub struct Message {
    pub id: Uuid,
    // does not contain full user information
    // bare jid (for now)
    pub from: JID,
    pub delivery: Option<Delivery>,
    pub timestamp: DateTime<Utc>,
    // TODO: originally_from
    // TODO: message edits
    // TODO: message timestamp
    pub body: Body,
}

#[derive(Debug, Clone, Copy)]
pub enum Delivery {
    Sending,
    Written,
    Sent,
    Delivered,
    Read,
    Failed,
    Queued,
}

// TODO: user migrations
// pub enum Migrated {
//     Jabber(User),
//     Outside,
// }

#[derive(Debug, Clone)]
pub struct Body {
    // TODO: rich text, other contents, threads
    pub body: String,
}

#[derive(Debug, Clone)]
pub struct Chat {
    pub correspondent: JID,
    pub have_chatted: bool,
    // pub unread_messages: i32,
    // pub latest_message: Message,
    // when a new message is received, the chat should be updated, and the new message should be delivered too.
    // message history is not stored in chat, retreived separately.
    // pub message_history: Vec<Message>,
}

pub enum ChatUpdate {}

impl Chat {
    pub fn new(correspondent: JID, have_chatted: bool) -> Self {
        Self {
            correspondent,
            have_chatted,
        }
    }
    pub fn correspondent(&self) -> &JID {
        &self.correspondent
    }
}

// TODO: group chats
// pub enum Chat {
//     Direct(DirectChat),
//     Channel(Channel),
// }
// pub struct Channel {}