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.
  • Loading branch information
FabioPinheiro authored Aug 18, 2023
1 parent b757fc4 commit 68c86c8
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 68c86c8

Please sign in to comment.