Skip to content

Commit

Permalink
Added handling for the new problem report messages
Browse files Browse the repository at this point in the history
Signed-off-by: Bogdan Mircea <mirceapetrebogdan@gmail.com>
  • Loading branch information
bobozaur committed May 12, 2023
1 parent 6eab18a commit 4fe9130
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 8 deletions.
4 changes: 4 additions & 0 deletions aries_vcx/src/handlers/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ pub fn verify_thread_id(thread_id: &str, message: &AriesMessage) -> VcxResult<()
AriesMessage::CredentialIssuance(CredentialIssuance::RequestCredential(msg)) => {
matches_opt_thread_id!(msg, thread_id)
}
AriesMessage::CredentialIssuance(CredentialIssuance::ProblemReport(msg)) => {
matches_opt_thread_id!(msg, thread_id)
}
AriesMessage::DiscoverFeatures(DiscoverFeatures::Query(msg)) => msg.id == thread_id,
AriesMessage::DiscoverFeatures(DiscoverFeatures::Disclose(msg)) => matches_thread_id!(msg, thread_id),
AriesMessage::Notification(Notification::Ack(msg)) => matches_thread_id!(msg, thread_id),
Expand All @@ -109,6 +112,7 @@ pub fn verify_thread_id(thread_id: &str, message: &AriesMessage) -> VcxResult<()
AriesMessage::PresentProof(PresentProof::Presentation(msg)) => matches_thread_id!(msg, thread_id),
AriesMessage::PresentProof(PresentProof::ProposePresentation(msg)) => matches_opt_thread_id!(msg, thread_id),
AriesMessage::PresentProof(PresentProof::RequestPresentation(msg)) => matches_opt_thread_id!(msg, thread_id),
AriesMessage::PresentProof(PresentProof::ProblemReport(msg)) => matches_opt_thread_id!(msg, thread_id),
AriesMessage::ReportProblem(msg) => matches_opt_thread_id!(msg, thread_id),
AriesMessage::Revocation(Revocation::Revoke(msg)) => matches_opt_thread_id!(msg, thread_id),
AriesMessage::Revocation(Revocation::Ack(msg)) => matches_thread_id!(msg, thread_id),
Expand Down
11 changes: 10 additions & 1 deletion aries_vcx/src/protocols/issuance/actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl From<AriesMessage> for CredentialIssuanceAction {
}
AriesMessage::CredentialIssuance(CredentialIssuance::Ack(ack)) => {
CredentialIssuanceAction::CredentialAck(ack)
}
},
AriesMessage::Notification(Notification::Ack(ack)) => {
let MsgParts {
id,
Expand All @@ -76,6 +76,15 @@ impl From<AriesMessage> for CredentialIssuanceAction {
let report = ProblemReport::with_decorators(id, content.0, decorators);
CredentialIssuanceAction::ProblemReport(report)
}
AriesMessage::CredentialIssuance(CredentialIssuance::ProblemReport(report)) => {
let MsgParts {
id,
content,
decorators,
} = report;
let report = ProblemReport::with_decorators(id, content.0, decorators);
CredentialIssuanceAction::ProblemReport(report)
}
_ => CredentialIssuanceAction::Unknown,
}
}
Expand Down
5 changes: 5 additions & 0 deletions aries_vcx/src/protocols/issuance/holder/state_machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@ impl HolderSM {
return Some((uid, message));
}
}
AriesMessage::CredentialIssuance(CredentialIssuance::ProblemReport(problem_report)) => {
if matches_opt_thread_id!(problem_report, self.thread_id.as_str()) {
return Some((uid, message));
}
}
AriesMessage::ReportProblem(problem_report) => {
if matches_opt_thread_id!(problem_report, self.thread_id.as_str()) {
return Some((uid, message));
Expand Down
13 changes: 11 additions & 2 deletions aries_vcx/src/protocols/proof_presentation/prover/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ impl From<AriesMessage> for ProverMessages {
ProverMessages::PresentationAckReceived(ack)
}
AriesMessage::PresentProof(PresentProof::Ack(ack)) => ProverMessages::PresentationAckReceived(ack),
AriesMessage::PresentProof(PresentProof::RequestPresentation(request)) => {
ProverMessages::PresentationRequestReceived(request)
}
AriesMessage::ReportProblem(report) => ProverMessages::PresentationRejectReceived(report),
AriesMessage::Notification(Notification::ProblemReport(report)) => {
let MsgParts {
Expand All @@ -64,8 +67,14 @@ impl From<AriesMessage> for ProverMessages {
let report = ProblemReport::with_decorators(id, content.0, decorators);
ProverMessages::PresentationRejectReceived(report)
}
AriesMessage::PresentProof(PresentProof::RequestPresentation(request)) => {
ProverMessages::PresentationRequestReceived(request)
AriesMessage::PresentProof(PresentProof::ProblemReport(report)) => {
let MsgParts {
id,
content,
decorators,
} = report;
let report = ProblemReport::with_decorators(id, content.0, decorators);
ProverMessages::PresentationRejectReceived(report)
}
_ => ProverMessages::Unknown,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,11 @@ impl ProverSM {
return Some((uid, message));
}
}
AriesMessage::PresentProof(PresentProof::ProblemReport(msg)) => {
if matches_opt_thread_id!(msg, self.thread_id.as_str()) {
return Some((uid, message));
}
}
_ => {}
},
_ => {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ impl From<AriesMessage> for VerifierMessages {
let report = ProblemReport::with_decorators(id, content.0, decorators);
VerifierMessages::PresentationRejectReceived(report)
}
AriesMessage::PresentProof(PresentProof::ProblemReport(report)) => {
let MsgParts {
id,
content,
decorators,
} = report;
let report = ProblemReport::with_decorators(id, content.0, decorators);
VerifierMessages::PresentationRejectReceived(report)
}
_ => VerifierMessages::Unknown,
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@ use chrono::Utc;
use messages::decorators::thread::Thread;
use messages::decorators::timing::Timing;
use messages::msg_fields::protocols::notification::ack::{AckDecorators, AckStatus};
use messages::msg_fields::protocols::notification::problem_report::{
NotificationProblemReport, NotificationProblemReportContent,
};
use messages::msg_fields::protocols::present_proof::ack::{AckPresentation, AckPresentationContent};
use messages::msg_fields::protocols::present_proof::problem_report::{PresentProofProblemReport, PresentProofProblemReportContent};
use messages::msg_fields::protocols::present_proof::request::{
RequestPresentation, RequestPresentationContent, RequestPresentationDecorators,
};
Expand Down Expand Up @@ -257,9 +255,9 @@ impl VerifierSM {
decorators,
} = problem_report;

let problem_report = NotificationProblemReport::with_decorators(
let problem_report = PresentProofProblemReport::with_decorators(
id,
NotificationProblemReportContent(content),
PresentProofProblemReportContent(content),
decorators,
);

Expand Down

0 comments on commit 4fe9130

Please sign in to comment.