crypto: Properly mark verification requests as done

This commit is contained in:
Damir Jelić 2021-08-02 07:44:03 +02:00
parent 3726492cf9
commit 5f1e972b3d

View file

@ -471,6 +471,11 @@ impl VerificationRequest {
if self.is_passive() { if self.is_passive() {
None None
} else { } else {
trace!(
other_user = self.other_user().as_str(),
flow_id = self.flow_id().as_str(),
"Timing a verification request out"
);
request request
} }
} else { } else {
@ -573,7 +578,13 @@ impl VerificationRequest {
pub(crate) fn receive_done(&self, sender: &UserId, content: &DoneContent<'_>) { pub(crate) fn receive_done(&self, sender: &UserId, content: &DoneContent<'_>) {
if sender == self.other_user() { if sender == self.other_user() {
let mut inner = self.inner.lock().unwrap().clone(); trace!(
other_user = self.other_user().as_str(),
flow_id = self.flow_id().as_str(),
"Marking a verification request as done"
);
let mut inner = self.inner.lock().unwrap();
inner.receive_done(content); inner.receive_done(content);
} }
} }
@ -688,16 +699,27 @@ impl InnerRequest {
} }
fn cancel(&mut self, cancelled_by_us: bool, cancel_code: &CancelCode) { fn cancel(&mut self, cancelled_by_us: bool, cancel_code: &CancelCode) {
let print_info = || {
trace!( trace!(
cancelled_by_us = cancelled_by_us, cancelled_by_us = cancelled_by_us,
code = cancel_code.as_str(), code = cancel_code.as_str(),
"Verification request going into the cancelled state" "Verification request going into the cancelled state"
); );
};
*self = InnerRequest::Cancelled(match self { *self = InnerRequest::Cancelled(match self {
InnerRequest::Created(s) => s.clone().into_canceled(cancelled_by_us, cancel_code), InnerRequest::Created(s) => {
InnerRequest::Requested(s) => s.clone().into_canceled(cancelled_by_us, cancel_code), print_info();
InnerRequest::Ready(s) => s.clone().into_canceled(cancelled_by_us, cancel_code), s.clone().into_canceled(cancelled_by_us, cancel_code)
}
InnerRequest::Requested(s) => {
print_info();
s.clone().into_canceled(cancelled_by_us, cancel_code)
}
InnerRequest::Ready(s) => {
print_info();
s.clone().into_canceled(cancelled_by_us, cancel_code)
}
InnerRequest::Passive(_) | InnerRequest::Done(_) | InnerRequest::Cancelled(_) => return, InnerRequest::Passive(_) | InnerRequest::Done(_) | InnerRequest::Cancelled(_) => return,
}); });
} }