mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-21 07:09:56 +01:00
Allow null values in JsonDict.
This commit is contained in:
@@ -1,25 +1,21 @@
|
|||||||
package org.briarproject.briar.headless.blogs
|
package org.briarproject.briar.headless.blogs
|
||||||
|
|
||||||
import org.briarproject.bramble.api.sync.MessageId
|
|
||||||
import org.briarproject.bramble.identity.output
|
import org.briarproject.bramble.identity.output
|
||||||
import org.briarproject.briar.api.blog.BlogPostHeader
|
import org.briarproject.briar.api.blog.BlogPostHeader
|
||||||
import org.briarproject.briar.api.blog.MessageType
|
import org.briarproject.briar.api.blog.MessageType
|
||||||
import org.briarproject.briar.headless.json.JsonDict
|
import org.briarproject.briar.headless.json.JsonDict
|
||||||
|
|
||||||
internal fun BlogPostHeader.output(body: String): JsonDict {
|
internal fun BlogPostHeader.output(body: String) = JsonDict(
|
||||||
val dict = JsonDict(
|
|
||||||
"body" to body,
|
"body" to body,
|
||||||
"author" to author.output(),
|
"author" to author.output(),
|
||||||
"authorStatus" to authorStatus.output(),
|
"authorStatus" to authorStatus.output(),
|
||||||
"type" to type.output(),
|
"type" to type.output(),
|
||||||
"id" to id.bytes,
|
"id" to id.bytes,
|
||||||
|
"parentId" to parentId?.bytes,
|
||||||
"read" to isRead,
|
"read" to isRead,
|
||||||
"rssFeed" to isRssFeed,
|
"rssFeed" to isRssFeed,
|
||||||
"timestamp" to timestamp,
|
"timestamp" to timestamp,
|
||||||
"timestampReceived" to timeReceived
|
"timestampReceived" to timeReceived
|
||||||
)
|
)
|
||||||
if (parentId != null) dict["parentId"] = (parentId as MessageId).bytes
|
|
||||||
return dict
|
|
||||||
}
|
|
||||||
|
|
||||||
internal fun MessageType.output() = name.toLowerCase()
|
internal fun MessageType.output() = name.toLowerCase()
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
package org.briarproject.briar.headless.json
|
package org.briarproject.briar.headless.json
|
||||||
|
|
||||||
class JsonDict(vararg pairs: Pair<String, Any>) : HashMap<String, Any>(pairs.size) {
|
class JsonDict(vararg pairs: Pair<String, Any?>) : HashMap<String, Any?>(pairs.size) {
|
||||||
init {
|
init {
|
||||||
putAll(pairs)
|
putAll(pairs)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun putAll(vararg pairs: Pair<String, Any>) {
|
fun putAll(vararg pairs: Pair<String, Any?>) {
|
||||||
for (p in pairs) put(p.first, p.second)
|
for (p in pairs) put(p.first, p.second)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user