[headless] only offload to DatabaseExecutor when needed

when receiving a new conversation message
This commit is contained in:
Torsten Grote
2018-11-07 15:21:55 -03:00
parent 6766fb76b2
commit 8b3983ef9e
2 changed files with 4 additions and 6 deletions

View File

@@ -81,9 +81,9 @@ constructor(
override fun eventOccurred(e: Event) {
when (e) {
is ConversationMessageReceivedEvent<*> -> dbExecutor.execute {
is ConversationMessageReceivedEvent<*> -> {
val h = e.messageHeader
if (h is PrivateMessageHeader) {
if (h is PrivateMessageHeader) dbExecutor.execute {
val text = messagingManager.getMessageText(h.id)
webSocketController.sendEvent(EVENT_CONVERSATION_MESSAGE, e.output(text))
} else {

View File

@@ -69,8 +69,6 @@ internal class WebSocketControllerTest : ControllerTest() {
@Test
fun testIntroductionRequestEvent() {
val sessionId = SessionId(getRandomId())
val authorInfo = AuthorInfo(VERIFIED)
val introductionRequest = IntroductionRequest(
message.id,
group.id,
@@ -79,11 +77,11 @@ internal class WebSocketControllerTest : ControllerTest() {
true,
true,
true,
sessionId,
SessionId(getRandomId()),
author,
text,
false,
authorInfo
AuthorInfo(VERIFIED)
)
val introductionRequestEvent =
IntroductionRequestReceivedEvent(introductionRequest, contact.id)