mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 18:59:06 +01:00
Minor improvements to JsonDict output classes
This commit is contained in:
@@ -5,21 +5,18 @@ import org.briarproject.briar.api.messaging.PrivateMessage
|
||||
import org.briarproject.briar.api.messaging.PrivateMessageHeader
|
||||
import org.briarproject.briar.headless.json.JsonDict
|
||||
|
||||
internal fun PrivateMessageHeader.output(contactId: ContactId, body: String?): JsonDict {
|
||||
val dict = JsonDict(
|
||||
"type" to "org.briarproject.briar.api.messaging.PrivateMessageHeader",
|
||||
"contactId" to contactId.int,
|
||||
"timestamp" to timestamp,
|
||||
"read" to isRead,
|
||||
"seen" to isSeen,
|
||||
"sent" to isSent,
|
||||
"local" to isLocal,
|
||||
"id" to id.bytes,
|
||||
"groupId" to groupId.bytes
|
||||
)
|
||||
if (body != null) dict["body"] = body
|
||||
return dict
|
||||
}
|
||||
internal fun PrivateMessageHeader.output(contactId: ContactId, body: String?) = JsonDict(
|
||||
"type" to "org.briarproject.briar.api.messaging.PrivateMessageHeader",
|
||||
"contactId" to contactId.int,
|
||||
"timestamp" to timestamp,
|
||||
"read" to isRead,
|
||||
"seen" to isSeen,
|
||||
"sent" to isSent,
|
||||
"local" to isLocal,
|
||||
"id" to id.bytes,
|
||||
"groupId" to groupId.bytes,
|
||||
"body" to body
|
||||
)
|
||||
|
||||
internal fun PrivateMessage.output(contactId: ContactId, body: String) = JsonDict(
|
||||
"type" to "org.briarproject.briar.api.messaging.PrivateMessageHeader",
|
||||
@@ -32,4 +29,4 @@ internal fun PrivateMessage.output(contactId: ContactId, body: String) = JsonDic
|
||||
"id" to message.id.bytes,
|
||||
"groupId" to message.groupId.bytes,
|
||||
"body" to body
|
||||
)
|
||||
)
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
@file:Suppress("unused")
|
||||
|
||||
package org.briarproject.briar.headless.messaging
|
||||
|
||||
import org.briarproject.bramble.api.contact.ContactId
|
||||
@@ -53,4 +51,4 @@ internal fun GroupInvitationRequest.output(contactId: ContactId): JsonDict {
|
||||
val dict = (this as InvitationRequest<*>).output(contactId)
|
||||
dict["type"] = "org.briarproject.briar.api.privategroup.invitation.GroupInvitationRequest"
|
||||
return dict
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
@file:Suppress("MemberVisibilityCanBePrivate", "unused")
|
||||
|
||||
package org.briarproject.briar.headless.messaging
|
||||
|
||||
import org.briarproject.bramble.api.contact.ContactId
|
||||
@@ -54,4 +52,4 @@ internal fun GroupInvitationResponse.output(contactId: ContactId): JsonDict {
|
||||
val dict = (this as InvitationResponse).output(contactId)
|
||||
dict["type"] = "org.briarproject.briar.api.privategroup.invitation.GroupInvitationResponse"
|
||||
return dict
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user