Only include "body" for headers that can have bodies.

This commit is contained in:
akwizgran
2018-10-04 09:45:51 +01:00
committed by Torsten Grote
parent 6f54718756
commit 1617a95bb9
2 changed files with 9 additions and 4 deletions

View File

@@ -5,7 +5,7 @@ import org.briarproject.briar.api.messaging.PrivateMessage
import org.briarproject.briar.api.messaging.PrivateMessageHeader import org.briarproject.briar.api.messaging.PrivateMessageHeader
import org.briarproject.briar.headless.json.JsonDict import org.briarproject.briar.headless.json.JsonDict
internal fun PrivateMessageHeader.output(contactId: ContactId, body: String?) = JsonDict( internal fun PrivateMessageHeader.output(contactId: ContactId) = JsonDict(
"type" to "PrivateMessage", "type" to "PrivateMessage",
"contactId" to contactId.int, "contactId" to contactId.int,
"timestamp" to timestamp, "timestamp" to timestamp,
@@ -14,10 +14,15 @@ internal fun PrivateMessageHeader.output(contactId: ContactId, body: String?) =
"sent" to isSent, "sent" to isSent,
"local" to isLocal, "local" to isLocal,
"id" to id.bytes, "id" to id.bytes,
"groupId" to groupId.bytes, "groupId" to groupId.bytes
"body" to body
) )
internal fun PrivateMessageHeader.output(contactId: ContactId, body: String?): JsonDict {
val dict = output(contactId)
dict["body"] = body
return dict
}
internal fun PrivateMessage.output(contactId: ContactId, body: String) = JsonDict( internal fun PrivateMessage.output(contactId: ContactId, body: String) = JsonDict(
"type" to "PrivateMessage", "type" to "PrivateMessage",
"contactId" to contactId.int, "contactId" to contactId.int,

View File

@@ -12,7 +12,7 @@ import org.briarproject.briar.api.sharing.InvitationResponse
import org.briarproject.briar.headless.json.JsonDict import org.briarproject.briar.headless.json.JsonDict
internal fun PrivateResponse.output(contactId: ContactId): JsonDict { internal fun PrivateResponse.output(contactId: ContactId): JsonDict {
val dict = (this as PrivateMessageHeader).output(contactId, null) val dict = (this as PrivateMessageHeader).output(contactId)
dict.putAll( dict.putAll(
"sessionId" to sessionId.bytes, "sessionId" to sessionId.bytes,
"accepted" to wasAccepted() "accepted" to wasAccepted()