Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Handle Error Notify webhooks ATL-6934 #1279

Merged
merged 15 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ object ConnectBackgroundJobs extends BackgroundJobsHelper {
_,
metaRetries,
_,
_
_,
_,
) if metaRetries > 0 =>
val inviteeProcessFlow = for {
walletAccessContext <- buildWalletAccessContextLayer(request.from)
Expand Down Expand Up @@ -147,7 +148,8 @@ object ConnectBackgroundJobs extends BackgroundJobsHelper {
Some(response),
metaRetries,
_,
_
_,
_,
) if metaRetries > 0 =>
val inviterProcessFlow = for {
walletAccessContext <- buildWalletAccessContextLayer(response.from)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,41 @@ object PresentBackgroundJobs extends BackgroundJobsHelper {
for {
_ <- ZIO.logDebug(s"Running action with records => $record")
_ <- record match {
case PresentationRecord(_, _, _, _, _, _, _, _, InvitationGenerated, _, _, _, _, _, _, _, _, _, _, _, _, _) =>
case PresentationRecord(
_,
_,
_,
_,
_,
_,
_,
_,
InvitationGenerated,
_,
_,
_,
_,
_,
_,
_,
_,
_,
_,
_,
_,
_,
_
) =>
ZIO.unit
case PresentationRecord(_, _, _, _, _, _, _, _, InvitationExpired, _, _, _, _, _, _, _, _, _, _, _, _, _) =>
case PresentationRecord(_, _, _, _, _, _, _, _, InvitationExpired, _, _, _, _, _, _, _, _, _, _, _, _, _, _) =>
ZIO.unit
case PresentationRecord(id, _, _, _, _, _, _, _, ProposalPending, _, _, _, _, _, _, _, _, _, _, _, _, _) =>
case PresentationRecord(id, _, _, _, _, _, _, _, ProposalPending, _, _, _, _, _, _, _, _, _, _, _, _, _, _) =>
ZIO.fail(NotImplemented)
case PresentationRecord(id, _, _, _, _, _, _, _, ProposalSent, _, _, _, _, _, _, _, _, _, _, _, _, _) =>
case PresentationRecord(id, _, _, _, _, _, _, _, ProposalSent, _, _, _, _, _, _, _, _, _, _, _, _, _, _) =>
ZIO.fail(NotImplemented)
case PresentationRecord(id, _, _, _, _, _, _, _, ProposalReceived, _, _, _, _, _, _, _, _, _, _, _, _, _) =>
case PresentationRecord(id, _, _, _, _, _, _, _, ProposalReceived, _, _, _, _, _, _, _, _, _, _, _, _, _, _) =>
ZIO.fail(NotImplemented)
case PresentationRecord(id, _, _, _, _, _, _, _, ProposalRejected, _, _, _, _, _, _, _, _, _, _, _, _, _) =>
case PresentationRecord(id, _, _, _, _, _, _, _, ProposalRejected, _, _, _, _, _, _, _, _, _, _, _, _, _, _) =>
ZIO.fail(NotImplemented)
case PresentationRecord(
id,
Expand All @@ -131,6 +155,7 @@ object PresentBackgroundJobs extends BackgroundJobsHelper {
_,
_,
_,
_,
_
) => // Verifier
ZIO.fail(InvalidState("PresentationRecord 'RequestPending' with no Record"))
Expand All @@ -156,6 +181,7 @@ object PresentBackgroundJobs extends BackgroundJobsHelper {
_,
_,
_,
_,
_
) => // Verifier
Verifier.handleRequestPending(id, requestPresentation)
Expand All @@ -181,6 +207,7 @@ object PresentBackgroundJobs extends BackgroundJobsHelper {
_,
_,
_,
_,
_
) => // Verifier
ZIO.logDebug("PresentationRecord: RequestSent") *> ZIO.unit
Expand All @@ -206,6 +233,7 @@ object PresentBackgroundJobs extends BackgroundJobsHelper {
_,
_,
_,
_,
_
) => // Prover
ZIO.logDebug("PresentationRecord: RequestReceived") *> ZIO.unit
Expand All @@ -231,12 +259,37 @@ object PresentBackgroundJobs extends BackgroundJobsHelper {
_,
_,
_,
_,
_
) => // Prover
ZIO.logDebug("PresentationRecord: RequestRejected") *> ZIO.unit
case PresentationRecord(id, _, _, _, _, _, _, _, ProblemReportPending, _, _, _, _, _, _, _, _, _, _, _, _, _) =>
case PresentationRecord(
id,
_,
_,
_,
_,
_,
_,
_,
ProblemReportPending,
_,
_,
_,
_,
_,
_,
_,
_,
_,
_,
_,
_,
_,
_
) =>
ZIO.fail(NotImplemented)
case PresentationRecord(id, _, _, _, _, _, _, _, ProblemReportSent, _, _, _, _, _, _, _, _, _, _, _, _, _) =>
case PresentationRecord(id, _, _, _, _, _, _, _, ProblemReportSent, _, _, _, _, _, _, _, _, _, _, _, _, _, _) =>
ZIO.fail(NotImplemented)
case PresentationRecord(
id,
Expand All @@ -260,6 +313,7 @@ object PresentBackgroundJobs extends BackgroundJobsHelper {
_,
_,
_,
_,
_
) =>
ZIO.fail(NotImplemented)
Expand All @@ -285,6 +339,7 @@ object PresentBackgroundJobs extends BackgroundJobsHelper {
_,
_,
_,
_,
_
) => // Prover
ZIO.fail(InvalidState("PresentationRecord 'RequestPending' with no Record"))
Expand All @@ -311,6 +366,7 @@ object PresentBackgroundJobs extends BackgroundJobsHelper {
_,
_,
_,
_,
_
) => // Prover
Prover.PresentationPending.handle(
Expand Down Expand Up @@ -343,6 +399,7 @@ object PresentBackgroundJobs extends BackgroundJobsHelper {
_,
_,
_,
_,
_
) => // Prover
ZIO.fail(InvalidState("PresentationRecord in 'PresentationGenerated' with no Presentation"))
Expand All @@ -369,12 +426,13 @@ object PresentBackgroundJobs extends BackgroundJobsHelper {
_,
_,
_,
_,
_
) => // Prover
ZIO.logDebug("PresentationRecord: PresentationGenerated") *> ZIO.unit
Prover.handlePresentationGenerated(id, presentation)

case PresentationRecord(id, _, _, _, _, _, _, _, PresentationSent, _, _, _, _, _, _, _, _, _, _, _, _, _) =>
case PresentationRecord(id, _, _, _, _, _, _, _, PresentationSent, _, _, _, _, _, _, _, _, _, _, _, _, _, _) =>
ZIO.logDebug("PresentationRecord: PresentationSent") *> ZIO.unit
case PresentationRecord(
id,
Expand All @@ -398,6 +456,7 @@ object PresentBackgroundJobs extends BackgroundJobsHelper {
_,
_,
_,
_,
_
) => // Verifier
ZIO.fail(InvalidState("PresentationRecord in 'PresentationReceived' with no Presentation"))
Expand All @@ -423,6 +482,7 @@ object PresentBackgroundJobs extends BackgroundJobsHelper {
_,
_,
_,
_,
_
) =>
ZIO.fail(InvalidState("PresentationRecord in 'PresentationReceived' with no Presentation Request"))
Expand All @@ -448,6 +508,7 @@ object PresentBackgroundJobs extends BackgroundJobsHelper {
_,
_,
_,
_,
_
) => // Verifier
ZIO.logDebug("PresentationRecord: PresentationReceived") *> ZIO.unit
Expand Down Expand Up @@ -475,14 +536,87 @@ object PresentBackgroundJobs extends BackgroundJobsHelper {
_,
_,
_,
_,
_
) =>
ZIO.logDebug("PresentationRecord: PresentationVerificationFailed") *> ZIO.unit
case PresentationRecord(id, _, _, _, _, _, _, _, PresentationAccepted, _, _, _, _, _, _, _, _, _, _, _, _, _) =>
case PresentationRecord(
id,
_,
_,
_,
_,
_,
_,
_,
PresentationAccepted,
_,
_,
_,
_,
_,
_,
_,
_,
_,
_,
_,
_,
_,
_
) =>
ZIO.logDebug("PresentationRecord: PresentationVerifiedAccepted") *> ZIO.unit
case PresentationRecord(id, _, _, _, _, _, _, _, PresentationVerified, _, _, _, _, _, _, _, _, _, _, _, _, _) =>
case PresentationRecord(
id,
_,
_,
_,
_,
_,
_,
_,
PresentationVerified,
_,
_,
_,
_,
_,
_,
_,
_,
_,
_,
_,
_,
_,
_
) =>
ZIO.logDebug("PresentationRecord: PresentationVerified") *> ZIO.unit
case PresentationRecord(id, _, _, _, _, _, _, _, PresentationRejected, _, _, _, _, _, _, _, _, _, _, _, _, _) =>
case PresentationRecord(
id,
_,
_,
_,
_,
_,
_,
_,
PresentationRejected,
_,
_,
_,
_,
_,
_,
_,
_,
_,
_,
_,
_,
_,
_
) =>
ZIO.logDebug("PresentationRecord: PresentationRejected") *> ZIO.unit
case _ =>
ZIO.logWarning(s"Unhandled PresentationRecord state: ${record.protocolState}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import org.hyperledger.identus.mercury.protocol.invitation.v2.Invitation
import org.hyperledger.identus.pollux.core.model.{CredentialFormat, DidCommID, IssueCredentialRecord}
import org.hyperledger.identus.pollux.core.model.IssueCredentialRecord.{ProtocolState, Role}
import org.hyperledger.identus.pollux.core.service.MockCredentialService
import org.hyperledger.identus.shared.models.WalletId
import sttp.client3.{basicRequest, DeserializationException, UriContext}
import sttp.client3.ziojson.*
import sttp.model.StatusCode
Expand Down Expand Up @@ -114,7 +115,8 @@ object IssueControllerImplSpec extends ZIOSpecDefault with IssueControllerTestTo
Some(connectionResponse),
5,
None,
None
None,
WalletId.fromUUID(UUID.randomUUID)
)
val acceptCredentialOfferRequest = AcceptCredentialOfferRequest(
Some(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import org.hyperledger.identus.connect.core.model.ConnectionRecord.{ProtocolStat
import org.hyperledger.identus.mercury.protocol.connection.{ConnectionRequest, ConnectionResponse}
import org.hyperledger.identus.mercury.protocol.invitation.v2.Invitation
import org.hyperledger.identus.shared.models.Failure
import org.hyperledger.identus.shared.models.WalletAccessContext
import org.hyperledger.identus.shared.models.WalletId
import zio.ZIO

import java.time.temporal.ChronoUnit
import java.time.Instant
Expand Down Expand Up @@ -43,7 +46,8 @@ case class ConnectionRecord(
connectionResponse: Option[ConnectionResponse],
metaRetries: Int,
metaNextRetry: Option[Instant],
metaLastFailure: Option[Failure]
metaLastFailure: Option[Failure],
walletId: WalletId,
) {
def withTruncatedTimestamp(unit: ChronoUnit = ChronoUnit.MICROS): ConnectionRecord = copy(
createdAt = createdAt.truncatedTo(unit),
Expand All @@ -52,6 +56,51 @@ case class ConnectionRecord(
)
}

/** Like [[ConnectionRecordBefore]] but without the walletId */
case class ConnectionRecordBeforeStored(
id: UUID,
createdAt: Instant,
updatedAt: Option[Instant],
thid: String,
label: Option[String],
goalCode: Option[String],
goal: Option[String],
role: Role,
protocolState: ProtocolState,
invitation: Invitation,
connectionRequest: Option[ConnectionRequest],
connectionResponse: Option[ConnectionResponse],
metaRetries: Int,
metaNextRetry: Option[Instant],
metaLastFailure: Option[Failure],
) {

def withTruncatedTimestamp(unit: ChronoUnit = ChronoUnit.MICROS) = copy(
createdAt = createdAt.truncatedTo(unit),
updatedAt = updatedAt.map(_.truncatedTo(unit)),
metaNextRetry = metaNextRetry.map(_.truncatedTo(unit))
)

def withWalletId(walletId: WalletId): ConnectionRecord = ConnectionRecord(
id = id,
createdAt = createdAt,
updatedAt = updatedAt,
thid = thid,
label = label,
goalCode = goalCode,
goal = goal,
role = role,
protocolState = protocolState,
invitation = invitation,
connectionRequest = connectionRequest,
connectionResponse = connectionResponse,
metaRetries = metaRetries,
metaNextRetry = metaNextRetry,
metaLastFailure = metaLastFailure,
walletId = walletId
)
}

object ConnectionRecord {
enum Role:
case Inviter extends Role
Expand Down
Loading
Loading