1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2025-06-22 01:15:16 +00:00

Can delete a single conversation message

This commit is contained in:
2020-06-23 14:09:52 +02:00
parent a5c83cc1b4
commit abf9a7fa82
3 changed files with 27 additions and 0 deletions

View File

@ -260,6 +260,13 @@ pub fn get_all_messages(conv_id: u64) -> ResultBoxError<Vec<ConversationMessage>
.exec(db_to_conversation_message)
}
/// Get a single message specified by its ID
pub fn get_single_message(msg_id: u64) -> ResultBoxError<ConversationMessage> {
database::QueryInfo::new(CONV_MESSAGES_TABLE)
.cond_u64("id", msg_id)
.query_row(db_to_conversation_message)
}
/// Send a new conversation message
pub fn send_message(msg: &NewConversationMessage) -> ResultBoxError<()> {
let t = time();
@ -319,6 +326,11 @@ pub fn delete_message(msg: &ConversationMessage) -> ResultBoxError<()> {
Ok(())
}
/// Delete a message with a specific ID
pub fn delete_message_by_id(id: u64) -> ResultBoxError<()> {
delete_message(&get_single_message(id)?)
}
/// Count the number of unread conversation for a specified user
pub fn count_unread_for_user(user_id: UserID) -> ResultBoxError<usize> {
database::QueryInfo::new(CONV_USERS_TABLE)