From 66eaf070eb6d18666046cce20f432eea599affdf Mon Sep 17 00:00:00 2001 From: Bogdan Mircea Date: Wed, 13 Sep 2023 11:06:49 +0300 Subject: [PATCH] Added extraction of thread_id from Thread Signed-off-by: Bogdan Mircea --- .../src/protocols/connection/invitee/mod.rs | 23 +++++++------------ .../invitee/state_machine.rs | 16 ++++--------- 2 files changed, 13 insertions(+), 26 deletions(-) diff --git a/aries_vcx/src/protocols/connection/invitee/mod.rs b/aries_vcx/src/protocols/connection/invitee/mod.rs index 8b1d9c205a..6a068d0e59 100644 --- a/aries_vcx/src/protocols/connection/invitee/mod.rs +++ b/aries_vcx/src/protocols/connection/invitee/mod.rs @@ -119,27 +119,20 @@ impl InviteeConnection { // When the invitation is Pairwise, it is designed to be sent to a single invitee. // In this case, we reuse the invitation ID (current thread ID) as the thread ID // in both the connection and the request. - let (thread_id, thread) = match &self.state.invitation { - AnyInvitation::Oob(invite) => { - let thread = Thread::builder().thid(id.clone()).pthid(invite.id.clone()).build(); - (id.clone(), thread) - } + let thread = match &self.state.invitation { + AnyInvitation::Oob(invite) => Thread::builder().thid(id.clone()).pthid(invite.id.clone()).build(), AnyInvitation::Con(invite) => match invite.content { - InvitationContent::Public(_) => { - let thread = Thread::builder() - .thid(id.clone()) - .pthid(self.state.thread_id().to_owned()) - .build(); - - (id.clone(), thread) - } + InvitationContent::Public(_) => Thread::builder() + .thid(id.clone()) + .pthid(self.state.thread_id().to_owned()) + .build(), InvitationContent::Pairwise(_) | InvitationContent::PairwiseDID(_) => { - let thread = Thread::builder().thid(self.state.thread_id().to_owned()).build(); - (self.state.thread_id().to_owned(), thread) + Thread::builder().thid(self.state.thread_id().to_owned()).build() } }, }; + let thread_id = thread.thid.clone(); let decorators = decorators.thread(thread).build(); let request = Request::builder() diff --git a/aries_vcx/src/protocols/mediated_connection/invitee/state_machine.rs b/aries_vcx/src/protocols/mediated_connection/invitee/state_machine.rs index 8010184141..67a12b0c8a 100644 --- a/aries_vcx/src/protocols/mediated_connection/invitee/state_machine.rs +++ b/aries_vcx/src/protocols/mediated_connection/invitee/state_machine.rs @@ -230,25 +230,19 @@ impl SmConnectionInvitee { let decorators = RequestDecorators::builder().timing(Timing::builder().out_time(Utc::now()).build()); - let (thread_id, thread) = match &state.invitation { - AnyInvitation::Oob(invite) => { - let thread = Thread::builder().thid(id.clone()).pthid(invite.id.clone()).build(); - - (id.clone(), thread) - } + let thread = match &state.invitation { + AnyInvitation::Oob(invite) => Thread::builder().thid(id.clone()).pthid(invite.id.clone()).build(), AnyInvitation::Con(invite) => match invite.content { InvitationContent::Public(_) => { - let thread = Thread::builder().thid(id.clone()).pthid(self.thread_id.clone()).build(); - - (id.clone(), thread) + Thread::builder().thid(id.clone()).pthid(self.thread_id.clone()).build() } InvitationContent::Pairwise(_) | InvitationContent::PairwiseDID(_) => { - let thread = Thread::builder().thid(self.thread_id.clone()).build(); - (self.thread_id.clone(), thread) + Thread::builder().thid(self.thread_id.clone()).build() } }, }; + let thread_id = thread.thid.clone(); let decorators = decorators.thread(thread).build(); let request = Request::builder()