mirror of
				https://gitlab.com/comunic/comunicapiv3
				synced 2025-11-03 17:14:03 +00:00 
			
		
		
		
	Can get older conversation messages
This commit is contained in:
		@@ -224,6 +224,25 @@ pub fn get_new_messages(conv_id: u64, last_message_id: u64) -> ResultBoxError<Ve
 | 
			
		||||
        .exec(db_to_conversation_message)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Get older messages of a conversation
 | 
			
		||||
///
 | 
			
		||||
/// `conv_id` contains the ID of the target conversation
 | 
			
		||||
/// `start_id` contains the ID from wich the research start
 | 
			
		||||
/// `limit` Maximum number of messages to get
 | 
			
		||||
pub fn get_older_messages(conv_id: u64, start_id: u64, limit: u64) -> ResultBoxError<Vec<ConversationMessage>> {
 | 
			
		||||
    database::QueryInfo::new(CONV_MESSAGES_TABLE)
 | 
			
		||||
        .cond_u64("conv_id", conv_id)
 | 
			
		||||
        .set_custom_where("ID <= ?")
 | 
			
		||||
        .add_custom_where_argument_u64(start_id)
 | 
			
		||||
        .set_order("id DESC")
 | 
			
		||||
        .set_limit(limit)
 | 
			
		||||
        .exec(db_to_conversation_message)
 | 
			
		||||
        .map(|mut l| {
 | 
			
		||||
            l.sort_by(|a, b| a.id.partial_cmp(&b.id).unwrap());
 | 
			
		||||
            l
 | 
			
		||||
        })
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Send a new conversation message
 | 
			
		||||
pub fn send_message(msg: &NewConversationMessage) -> ResultBoxError<()> {
 | 
			
		||||
    let t = time();
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user