mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 09:26:29 +03:00
fix: do not fail to load messages with unknown viewtype
This commit is contained in:
@@ -566,7 +566,7 @@ impl Message {
|
|||||||
timestamp_rcvd: row.get("timestamp_rcvd")?,
|
timestamp_rcvd: row.get("timestamp_rcvd")?,
|
||||||
ephemeral_timer: row.get("ephemeral_timer")?,
|
ephemeral_timer: row.get("ephemeral_timer")?,
|
||||||
ephemeral_timestamp: row.get("ephemeral_timestamp")?,
|
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()),
|
state: state.with_mdns(mdn_msg_id.is_some()),
|
||||||
download_state: row.get("download_state")?,
|
download_state: row.get("download_state")?,
|
||||||
error: Some(row.get::<_, String>("error")?)
|
error: Some(row.get::<_, String>("error")?)
|
||||||
|
|||||||
@@ -747,3 +747,21 @@ async fn test_send_empty_file() -> Result<()> {
|
|||||||
assert_eq!(bob_received_msg.get_viewtype(), Viewtype::File);
|
assert_eq!(bob_received_msg.get_viewtype(), Viewtype::File);
|
||||||
Ok(())
|
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(())
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user