mirror of https://github.com/buster-so/buster.git
duplicate chat functionaligy
This commit is contained in:
parent
5a0cb079e3
commit
95f43217cc
|
@ -120,11 +120,11 @@ pub async fn duplicate_chat_handler(
|
||||||
.first::<Message>(&mut conn)
|
.first::<Message>(&mut conn)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
// Get all messages from this point forward in time (inclusive)
|
// Get this message and all older messages (messages created at or before this message)
|
||||||
messages::table
|
messages::table
|
||||||
.filter(messages::chat_id.eq(chat_id))
|
.filter(messages::chat_id.eq(chat_id))
|
||||||
.filter(messages::deleted_at.is_null())
|
.filter(messages::deleted_at.is_null())
|
||||||
.filter(messages::created_at.ge(message.created_at))
|
.filter(messages::created_at.le(message.created_at))
|
||||||
.order_by(messages::created_at.asc())
|
.order_by(messages::created_at.asc())
|
||||||
.load::<Message>(&mut conn)
|
.load::<Message>(&mut conn)
|
||||||
.await?
|
.await?
|
||||||
|
@ -435,7 +435,7 @@ mod tests {
|
||||||
setup_test_file_reference(message_id, &user.id).await;
|
setup_test_file_reference(message_id, &user.id).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Duplicate from the second message
|
// Duplicate second message and all older messages (not the third message)
|
||||||
let result = duplicate_chat_handler(&chat_id, Some(&message_ids[1]), &user).await;
|
let result = duplicate_chat_handler(&chat_id, Some(&message_ids[1]), &user).await;
|
||||||
assert!(
|
assert!(
|
||||||
result.is_ok(),
|
result.is_ok(),
|
||||||
|
@ -457,7 +457,7 @@ mod tests {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
duplicated_chat.message_ids.len(),
|
duplicated_chat.message_ids.len(),
|
||||||
2,
|
2,
|
||||||
"Chat should have 2 messages (only messages from the specific point)"
|
"Chat should have 2 messages (first and second message, but not third)"
|
||||||
);
|
);
|
||||||
|
|
||||||
// Verify file references
|
// Verify file references
|
||||||
|
|
Loading…
Reference in New Issue