mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-21 07:09:56 +01:00
Upgrade messaging client to support attachments.
This commit is contained in:
@@ -20,7 +20,7 @@ internal class OutputEvent(val name: String, val data: JsonDict) {
|
||||
val type = "event"
|
||||
}
|
||||
|
||||
internal fun ConversationMessageReceivedEvent<*>.output(text: String): JsonDict {
|
||||
internal fun ConversationMessageReceivedEvent<*>.output(text: String?): JsonDict {
|
||||
check(messageHeader is PrivateMessageHeader)
|
||||
return (messageHeader as PrivateMessageHeader).output(contactId, text)
|
||||
}
|
||||
|
||||
@@ -67,16 +67,16 @@ constructor(
|
||||
override fun write(ctx: Context): Context {
|
||||
val contact = getContact(ctx)
|
||||
|
||||
val message = ctx.getFromJson(objectMapper, "text")
|
||||
if (utf8IsTooLong(message, MAX_PRIVATE_MESSAGE_TEXT_LENGTH))
|
||||
val text = ctx.getFromJson(objectMapper, "text")
|
||||
if (utf8IsTooLong(text, MAX_PRIVATE_MESSAGE_TEXT_LENGTH))
|
||||
throw BadRequestResponse("Message text is too long")
|
||||
|
||||
val group = messagingManager.getContactGroup(contact)
|
||||
val now = clock.currentTimeMillis()
|
||||
val m = privateMessageFactory.createPrivateMessage(group.id, now, message, emptyList())
|
||||
val m = privateMessageFactory.createPrivateMessage(group.id, now, text, emptyList())
|
||||
|
||||
messagingManager.addLocalMessage(m)
|
||||
return ctx.json(m.output(contact.id, message))
|
||||
return ctx.json(m.output(contact.id, text))
|
||||
}
|
||||
|
||||
override fun eventOccurred(e: Event) {
|
||||
|
||||
@@ -169,7 +169,12 @@ internal class MessagingControllerImplTest : ControllerTest() {
|
||||
val event = PrivateMessageReceivedEvent(header, contact.id)
|
||||
|
||||
every { messagingManager.getMessageText(message.id) } returns text
|
||||
every { webSocketController.sendEvent(EVENT_CONVERSATION_MESSAGE, event.output(text)) } just runs
|
||||
every {
|
||||
webSocketController.sendEvent(
|
||||
EVENT_CONVERSATION_MESSAGE,
|
||||
event.output(text)
|
||||
)
|
||||
} just runs
|
||||
|
||||
controller.eventOccurred(event)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user