Last active
July 13, 2021 04:49
-
-
Save amencke/9b3a45d29c5958977ced1cf3881c51a6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lazy val conversationRoutes: Route = { | |
concat( | |
pathPrefix(version / "conversation" / LongNumber) { conversationID => | |
post { | |
entity(as[PostMessageRequest]) { | |
pmr => | |
val maybeSessionGranted: Future[SessionEvent] = | |
getSession(conversationID, pmr.userID) | |
onComplete(maybeSessionGranted) { | |
case Success(SessionGranted(session)) => | |
postMessage(conversationID, pmr.userID, pmr.message)(session) | |
complete(OK, PostMessageResponse(pmr.message)) | |
case Failure(ex) => | |
complete(InternalServerError -> ex) | |
case _ => complete(InternalServerError, "An unknown error occurred") | |
} | |
} | |
} | |
}, | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment