Skip to content

Commit

Permalink
fix: reply condition check ReturnRoute (#88)
Browse files Browse the repository at this point in the history
It was checking Some(Some(ReturnRoute)) contains all
The double option type was wrong.

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 b1b865d commit c2a091c
Showing 1 changed file with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import io.iohk.atala.mediator.protocols.MissingProtocolExecuter
object ActionUtils {

def packResponse(
plaintextMessage: Option[PlaintextMessage],
originalMessage: Option[PlaintextMessage],
action: Action
): ZIO[Operations & Agent & Resolver & MessageDispatcher, MediatorError, Option[EncryptedMessage]] =
action match {
Expand Down Expand Up @@ -79,15 +79,12 @@ object ActionUtils {
) *> ZIO
.succeed(msg)
.when(
{
plaintextMessage.map(_.return_route).contains(ReturnRoute.all)
&& {
plaintextMessage.flatMap(_.from.map(_.asTO)) match {
case None => false
case Some(replyTo) => send2DIDs.contains(replyTo)
}
originalMessage
.map { oMsg =>
oMsg.return_route.contains(ReturnRoute.all) && // Should replies use the same transport channel?
oMsg.from.map(_.asTO).exists(send2DIDs.contains) // Is the reply back to the original sender?
}
} // || action.isInstanceOf[SyncReplyOnly]
.getOrElse(false) // If originalMessage is None
)
} yield maybeSyncReplyMsg
}
Expand Down

0 comments on commit c2a091c

Please sign in to comment.