diff --git a/src/message.rs b/src/message.rs index 5c54480e0..4c5deda70 100644 --- a/src/message.rs +++ b/src/message.rs @@ -566,7 +566,7 @@ impl Message { timestamp_rcvd: row.get("timestamp_rcvd")?, ephemeral_timer: row.get("ephemeral_timer")?, ephemeral_timestamp: row.get("ephemeral_timestamp")?, - viewtype: row.get("type")?, + viewtype: row.get("type").unwrap_or_default(), state: state.with_mdns(mdn_msg_id.is_some()), download_state: row.get("download_state")?, error: Some(row.get::<_, String>("error")?) diff --git a/src/message/message_tests.rs b/src/message/message_tests.rs index eb53c7d7c..267c7acbb 100644 --- a/src/message/message_tests.rs +++ b/src/message/message_tests.rs @@ -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(()) +}