fix: blocked is an optional value

This commit is contained in:
dignifiedquire
2019-07-20 17:05:24 +02:00
parent e4bf9956a5
commit df5464ea80
4 changed files with 6 additions and 6 deletions

View File

@@ -144,7 +144,7 @@ pub fn dc_chat_load_from_db(chat: *mut Chat, chat_id: u32) -> bool {
free(p as *mut _);
};
c.archived = row.get(5)?;
c.blocked = row.get(6)?;
c.blocked = row.get::<_, Option<i32>>(6)?.unwrap_or_default();
c.gossiped_timestamp = row.get(7)?;
c.is_sending_locations = row.get(8)?;
Ok(())
@@ -330,7 +330,7 @@ pub fn dc_lookup_real_nchat_by_contact_id(
if let Ok((id, blocked)) = context.sql.query_row(
"SELECT c.id, c.blocked FROM chats c INNER JOIN chats_contacts j ON c.id=j.chat_id WHERE c.type=100 AND c.id>9 AND j.contact_id=?;",
params![contact_id as i32],
|row| Ok((row.get(0)?, row.get(1)?)),
|row| Ok((row.get(0)?, row.get::<_, Option<i32>>(1)?.unwrap_or_default())),
) {
unsafe { *ret_chat_id = id };
unsafe { *ret_chat_blocked = blocked };

View File

@@ -294,7 +294,7 @@ pub unsafe fn dc_contact_load_from_db(
(*contact).name = to_cstring(row.get::<_, String>(0)?);
(*contact).addr = to_cstring(row.get::<_, String>(1)?);
(*contact).origin = row.get(2)?;
(*contact).blocked = row.get(3)?;
(*contact).blocked = row.get::<_, Option<i32>>(3)?.unwrap_or_default();
(*contact).authname = to_cstring(row.get::<_, String>(4)?);
Ok(())
}

View File

@@ -470,7 +470,7 @@ pub fn dc_msg_load_from_db<'a>(msg: *mut dc_msg_t<'a>, context: &'a Context, id:
(*msg).starred = row.get(17)?;
(*msg).hidden = row.get(18)?;
(*msg).location_id = row.get(19)?;
(*msg).chat_blocked = row.get(20)?;
(*msg).chat_blocked = row.get::<_, Option<i32>>(20)?.unwrap_or_default();
if (*msg).chat_blocked == 2 {
dc_truncate_n_unwrap_str((*msg).text, 256, 0);
}
@@ -551,7 +551,7 @@ pub fn dc_markseen_msgs(context: &Context, msg_ids: *const u32, msg_cnt: usize)
for i in 0..msg_cnt {
let id = unsafe { *msg_ids.offset(i as isize) };
let (state, blocked) = stmt.query_row(params![id as i32], |row| {
Ok((row.get::<_, i32>(0)?, row.get::<_, i32>(1)?))
Ok((row.get::<_, i32>(0)?, row.get::<_, Option<i32>>(1)?.unwrap_or_default()))
})?;
res.push((id, state, blocked));
}

View File

@@ -1386,7 +1386,7 @@ unsafe fn create_or_lookup_adhoc_group(
),
params![],
|row| {
Ok((row.get::<_, i32>(0)?, row.get::<_, i32>(1)?))
Ok((row.get::<_, i32>(0)?, row.get::<_, Option<i32>>(1)?.unwrap_or_default()))
}
);