diff --git a/deltachat-ffi/deltachat.h b/deltachat-ffi/deltachat.h index b4e482202..97fe035c3 100644 --- a/deltachat-ffi/deltachat.h +++ b/deltachat-ffi/deltachat.h @@ -5072,6 +5072,15 @@ int dc_contact_is_blocked (const dc_contact_t* contact); */ int dc_contact_is_verified (dc_contact_t* contact); +/** + * Returns whether contact is a bot. + * + * @memberof dc_contact_t + * @param contact The contact object. + * @return 0 if the contact is not a bot, 1 otherwise. + */ +int dc_contact_is_bot (dc_contact_t* contact); + /** * Return the contact ID that verified a contact. diff --git a/deltachat-ffi/src/lib.rs b/deltachat-ffi/src/lib.rs index ac0fc05fa..5d68a940d 100644 --- a/deltachat-ffi/src/lib.rs +++ b/deltachat-ffi/src/lib.rs @@ -4132,6 +4132,15 @@ pub unsafe extern "C" fn dc_contact_is_verified(contact: *mut dc_contact_t) -> l } } +#[no_mangle] +pub unsafe extern "C" fn dc_contact_is_bot(contact: *mut dc_contact_t) -> libc::c_int { + if contact.is_null() { + eprintln!("ignoring careless call to dc_contact_is_bot()"); + return 0; + } + (*contact).contact.is_bot() as libc::c_int +} + #[no_mangle] pub unsafe extern "C" fn dc_contact_get_verifier_id(contact: *mut dc_contact_t) -> u32 { if contact.is_null() { diff --git a/deltachat-jsonrpc/src/api/types/contact.rs b/deltachat-jsonrpc/src/api/types/contact.rs index 60acd6b19..f6d9096bd 100644 --- a/deltachat-jsonrpc/src/api/types/contact.rs +++ b/deltachat-jsonrpc/src/api/types/contact.rs @@ -45,6 +45,9 @@ pub struct ContactObject { /// the contact's last seen timestamp last_seen: i64, was_seen_recently: bool, + + /// If the contact is a bot. + is_bot: bool, } impl ContactObject { @@ -80,6 +83,7 @@ impl ContactObject { verifier_id, last_seen: contact.last_seen(), was_seen_recently: contact.was_seen_recently(), + is_bot: contact.is_bot(), }) } }