Skip to content

Commit

Permalink
Decouple revocation_notification from Issuer handler
Browse files Browse the repository at this point in the history
Signed-off-by: Patrik Stas <patrik.stas@absa.africa>
  • Loading branch information
Patrik-Stas committed Aug 20, 2023
1 parent 88a7f2f commit 4f2a3f6
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 30 deletions.
30 changes: 0 additions & 30 deletions aries_vcx/src/handlers/issuance/issuer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,36 +176,6 @@ impl Issuer {
Ok(())
}

pub async fn send_revocation_notification(
&mut self,
ack_on: Vec<AckOn>,
comment: Option<String>,
send_message: SendClosure,
) -> VcxResult<()> {
// TODO: Check if actually revoked
if self.issuer_sm.is_revokable() {
// TODO: Store to allow checking not. status (sent, acked)
let config = SenderConfigBuilder::default()
.rev_reg_id(self.get_rev_reg_id()?)
.cred_rev_id(self.get_rev_id()?)
.comment(comment)
.ack_on(ack_on)
.build()?;
RevocationNotificationSender::build()
.send_revocation_notification(config, send_message)
.await?;
Ok(())
} else {
Err(AriesVcxError::from_msg(
AriesVcxErrorKind::InvalidState,
format!(
"Can't send revocation notification in state {:?}, credential is not revokable",
self.issuer_sm.get_state()
),
))
}
}

pub fn get_state(&self) -> IssuerState {
self.issuer_sm.get_state()
}
Expand Down
37 changes: 37 additions & 0 deletions aries_vcx/src/handlers/revocation_notification/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,43 @@
use crate::errors::error::{AriesVcxError, AriesVcxErrorKind, VcxResult};
use crate::handlers::issuance::issuer::Issuer;
use crate::handlers::revocation_notification::sender::RevocationNotificationSender;
use crate::protocols::revocation_notification::sender::state_machine::SenderConfigBuilder;
use crate::protocols::SendClosure;
use messages::decorators::please_ack::AckOn;

pub mod receiver;
pub mod sender;

pub async fn send_revocation_notification(
issuer: &Issuer,
ack_on: Vec<AckOn>,
comment: Option<String>,
send_message: SendClosure,
) -> VcxResult<()> {
// TODO: Check if actually revoked
if issuer.is_revokable() {
// TODO: Store to allow checking not. status (sent, acked)
let config = SenderConfigBuilder::default()
.rev_reg_id(issuer.get_rev_reg_id()?)
.cred_rev_id(issuer.get_rev_id()?)
.comment(comment)
.ack_on(ack_on)
.build()?;
RevocationNotificationSender::build()
.send_revocation_notification(config, send_message)
.await?;
Ok(())
} else {
Err(AriesVcxError::from_msg(
AriesVcxErrorKind::InvalidState,
format!(
"Can't send revocation notification in state {:?}, credential is not revokable",
issuer.get_state()
),
))
}
}

pub mod test_utils {
use agency_client::agency_client::AgencyClient;
use messages::msg_fields::protocols::revocation::ack::AckRevoke;
Expand Down

0 comments on commit 4f2a3f6

Please sign in to comment.