Avoid ChatId::is_unset when querying location sending

Avoid using the 0 ChatID as a special value, use Options instead.  For
get_range() also do this for contact_id.
This commit is contained in:
Floris Bruynooghe
2021-02-07 20:54:40 +01:00
parent 148ad31024
commit be7cee2c37
4 changed files with 59 additions and 24 deletions

View File

@@ -1943,11 +1943,13 @@ pub unsafe extern "C" fn dc_is_sending_locations_to_chat(
return 0;
}
let ctx = &*context;
let chat_id = if chat_id == 0 {
None
} else {
Some(ChatId::new(chat_id))
};
block_on(location::is_sending_locations_to_chat(
&ctx,
ChatId::new(chat_id),
)) as libc::c_int
block_on(location::is_sending_locations_to_chat(&ctx, chat_id)) as libc::c_int
}
#[no_mangle]
@@ -1979,11 +1981,21 @@ pub unsafe extern "C" fn dc_get_locations(
return ptr::null_mut();
}
let ctx = &*context;
let chat_id = if chat_id == 0 {
None
} else {
Some(ChatId::new(chat_id))
};
let contact_id = if contact_id == 0 {
None
} else {
Some(contact_id)
};
block_on(async move {
let res = location::get_range(
&ctx,
ChatId::new(chat_id),
chat_id,
contact_id,
timestamp_begin as i64,
timestamp_end as i64,