mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2025-06-20 16:35:17 +00:00
Add new field in conversation members table to ease database access
This commit is contained in:
@ -206,7 +206,7 @@ pub fn refresh_single(r: &mut HttpRequestHandler) -> RequestResult {
|
||||
let conv = r.post_conv("conversationID")?;
|
||||
let last_message_id = r.post_u64("last_message_id")?;
|
||||
|
||||
let messages = match last_message_id {
|
||||
let mut messages = match last_message_id {
|
||||
// Get latest messages of the conversation
|
||||
0 => conversations_helper::get_last_messages(conv.conv_id, 10)?,
|
||||
|
||||
@ -214,11 +214,13 @@ pub fn refresh_single(r: &mut HttpRequestHandler) -> RequestResult {
|
||||
_ => conversations_helper::get_new_messages(conv.conv_id, last_message_id)?,
|
||||
};
|
||||
|
||||
messages.sort_by(|one, two| one.id.cmp(&two.id));
|
||||
|
||||
if messages.len() > 0 {
|
||||
conversations_helper::mark_user_seen(
|
||||
conv.conv_id,
|
||||
r.user_id_ref()?,
|
||||
messages.iter().map(|m| m.id).max().unwrap(),
|
||||
&messages[messages.len() - 1],
|
||||
)?;
|
||||
}
|
||||
|
||||
@ -374,7 +376,7 @@ pub fn handle_event(e: &events_helper::Event) -> Res {
|
||||
user_ws_controller::send_message_to_specific_connections(
|
||||
|f| f.conversations.contains(&msg.conv_id),
|
||||
|_| UserWsMessage::no_id_message("new_conv_message", ConversationMessageAPI::new(msg)),
|
||||
Some(|conn: &UserWsConnection| conversations_helper::mark_user_seen(msg.conv_id, conn.user_id(), msg.id)),
|
||||
Some(|conn: &UserWsConnection| conversations_helper::mark_user_seen(msg.conv_id, conn.user_id(), msg)),
|
||||
)?;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user