fix: do not fail to load messages with unknown viewtype

This commit is contained in:
link2xt
2025-10-06 13:58:23 +00:00
committed by l
parent 23bfa4fc43
commit 209a8026fb
2 changed files with 19 additions and 1 deletions

View File

@@ -747,3 +747,21 @@ async fn test_send_empty_file() -> Result<()> {
assert_eq!(bob_received_msg.get_viewtype(), Viewtype::File);
Ok(())
}
/// Tests that viewtype 70
/// which previously corresponded to videochat invitations,
/// is loaded as unknown viewtype without errors.
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_load_unknown_viewtype() -> Result<()> {
let mut tcm = TestContextManager::new();
let alice = &tcm.alice().await;
let bob = &tcm.bob().await;
let msg_id = tcm.send_recv(alice, bob, "Hello!").await.id;
bob.sql
.execute("UPDATE msgs SET type=70 WHERE id=?", (msg_id,))
.await?;
let bob_msg = Message::load_from_db(bob, msg_id).await?;
assert_eq!(bob_msg.get_viewtype(), Viewtype::Unknown);
Ok(())
}