Skip to content

Commit

Permalink
api!: remove deprecated get_verifier_addr
Browse files Browse the repository at this point in the history
  • Loading branch information
link2xt committed Nov 3, 2023
1 parent d875691 commit d840a7e
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 57 deletions.
21 changes: 0 additions & 21 deletions deltachat-ffi/deltachat.h
Original file line number Diff line number Diff line change
Expand Up @@ -5055,27 +5055,6 @@ int dc_contact_is_verified (dc_contact_t* contact);



/**
* Return the address that verified a contact
*
* The UI may use this in addition to a checkmark showing the verification status.
* In case of verification chains,
* the last contact in the chain is shown.
* This is because of privacy reasons, but also as it would not help the user
* to see a unknown name here - where one can mostly always ask the shown name
* as it is directly known.
*
* @memberof dc_contact_t
* @param contact The contact object.
* @return
* A string containing the verifiers address. If it is the same address as the contact itself,
* we verified the contact ourself. If it is an empty string, we don't have verifier
* information or the contact is not verified.
* @deprecated 2023-09-28, use dc_contact_get_verifier_id instead
*/
char* dc_contact_get_verifier_addr (dc_contact_t* contact);


/**
* Return the contact ID that verified a contact.
*
Expand Down
17 changes: 0 additions & 17 deletions deltachat-ffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4119,23 +4119,6 @@ pub unsafe extern "C" fn dc_contact_is_verified(contact: *mut dc_contact_t) -> l
.unwrap_or_default() as libc::c_int
}

#[no_mangle]
pub unsafe extern "C" fn dc_contact_get_verifier_addr(
contact: *mut dc_contact_t,
) -> *mut libc::c_char {
if contact.is_null() {
eprintln!("ignoring careless call to dc_contact_get_verifier_addr()");
return "".strdup();
}
let ffi_contact = &*contact;
let ctx = &*ffi_contact.context;
block_on(ffi_contact.contact.get_verifier_addr(ctx))
.context("failed to get verifier for contact")
.log_err(ctx)
.unwrap_or_default()
.strdup()
}

#[no_mangle]
pub unsafe extern "C" fn dc_contact_get_verifier_id(contact: *mut dc_contact_t) -> u32 {
if contact.is_null() {
Expand Down
7 changes: 0 additions & 7 deletions deltachat-jsonrpc/src/api/types/contact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ pub struct ContactObject {
/// in contact list items and in chat member list items.
is_verified: bool,

/// The address that verified this contact
///
/// Deprecated, use `verifier_id` instead.
verifier_addr: Option<String>,

/// The ID of the contact that verified this contact.
///
/// If this is present,
Expand All @@ -56,7 +51,6 @@ impl ContactObject {
};
let is_verified = contact.is_verified(context).await? == VerifiedStatus::BidirectVerified;

let verifier_addr = contact.get_verifier_addr(context).await?;
let verifier_id = contact
.get_verifier_id(context)
.await?
Expand All @@ -74,7 +68,6 @@ impl ContactObject {
name_and_addr: contact.get_name_n_addr(),
is_blocked: contact.is_blocked(),
is_verified,
verifier_addr,
verifier_id,
last_seen: contact.last_seen(),
was_seen_recently: contact.was_seen_recently(),
Expand Down
16 changes: 4 additions & 12 deletions src/contact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1279,15 +1279,6 @@ impl Contact {
Ok(VerifiedStatus::Unverified)
}

/// Returns the address that verified the contact.
///
/// Deprecated, use [Self::get_verifier_id] instead.
pub async fn get_verifier_addr(&self, context: &Context) -> Result<Option<String>> {
Ok(Peerstate::from_addr(context, self.get_addr())
.await?
.and_then(|peerstate| peerstate.get_verifier().map(|addr| addr.to_owned())))
}

/// Returns the `ContactId` that verified the contact.
///
/// If the function returns non-zero result,
Expand All @@ -1301,7 +1292,10 @@ impl Contact {
/// Use [Self::is_verified] to check
/// if a contact can be added to a verified chat instead.
pub async fn get_verifier_id(&self, context: &Context) -> Result<Option<ContactId>> {
let Some(verifier_addr) = self.get_verifier_addr(context).await? else {
let Some(verifier_addr) = Peerstate::from_addr(context, self.get_addr())
.await?
.and_then(|peerstate| peerstate.get_verifier().map(|addr| addr.to_owned()))
else {
return Ok(None);
};

Expand Down Expand Up @@ -2765,7 +2759,6 @@ Hi."#;

let contact_id = Contact::create(&alice, "Bob", "[email protected]").await?;
let contact = Contact::get_by_id(&alice, contact_id).await?;
assert!(contact.get_verifier_addr(&alice).await?.is_none());
assert!(contact.get_verifier_id(&alice).await?.is_none());

// Receive a message from Bob to create a peerstate.
Expand All @@ -2774,7 +2767,6 @@ Hi."#;
alice.recv_msg(&sent_msg).await;

let contact = Contact::get_by_id(&alice, contact_id).await?;
assert!(contact.get_verifier_addr(&alice).await?.is_none());
assert!(contact.get_verifier_id(&alice).await?.is_none());

Ok(())
Expand Down

0 comments on commit d840a7e

Please sign in to comment.