Skip to content

Commit

Permalink
feat: process KeylistQuery and return Keylist (#30)
Browse files Browse the repository at this point in the history
Process a Keylist Query and return a Keylist
For ATL-4208

Signed-off-by: Fabio Pinheiro <fabiomgpinheiro@gmail.com>

Signed-off-by: Shailesh Patil <shailesh.patil@iohk.io>
  • Loading branch information
FabioPinheiro authored and mineme0110 committed May 1, 2024
1 parent 3b44d2f commit 04d2980
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ inThisBuild(

/** Versions */
lazy val V = new {
val scalaDID = "0.1.0-M3"
val scalaDID = "0.1.0-M4"
// val scalajsJavaSecureRandom = "1.0.0"

// FIXME another bug in the test framework https://github.com/scalameta/munit/issues/554
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,24 @@ object MediatorCoordinationExecuter extends ProtocolExecuterWithServices[Protoco
}
} yield SyncReplyOnly(m.makeKeylistResponse(updateResponse).toPlaintextMessage)
case m: KeylistResponse => ZIO.logWarning("KeylistResponse") *> ZIO.succeed(NoReply)
case m: KeylistQuery => ZIO.logError("Not implemented KeylistQuery") *> ZIO.succeed(NoReply) // TODO
case m: Keylist => ZIO.logWarning("Keylist") *> ZIO.succeed(NoReply)
case m: KeylistQuery =>
for {
_ <- ZIO.logInfo("KeylistQuery")
repo <- ZIO.service[UserAccountRepo]
mAccount <- repo.getDidAccount(m.from.toDID)
mResponse = mAccount.map { account =>
Keylist(
thid = m.id,
from = m.to.asFROM,
to = m.from.asTO,
keys = account.alias.map(e => Keylist.RecipientDID(e)),
pagination = None,
)
}
} yield mResponse match
case None => NoReply // TODO error report
case Some(response) => SyncReplyOnly(response.toPlaintextMessage)
case m: Keylist => ZIO.logWarning("Keylist") *> ZIO.succeed(NoReply)
} match
case Left(error) => ZIO.logError(error) *> ZIO.succeed(NoReply)
case Right(program) => program
Expand Down

0 comments on commit 04d2980

Please sign in to comment.