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: process KeylistQuery and return Keylist #30

Merged
merged 1 commit into from
Jul 3, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
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