mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 03:09:04 +01:00
briar-headless: Last round of review comments
This commit is contained in:
@@ -11,4 +11,3 @@ fun Author.output() = JsonDict(
|
||||
)
|
||||
|
||||
fun Author.Status.output() = name.toLowerCase()
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ private val DEFAULT_DATA_DIR = getProperty("user.home") + separator + ".briar"
|
||||
|
||||
private class Main : CliktCommand(
|
||||
name = "briar-headless",
|
||||
help = "A Briar client without GUI that exposes a REST and Websocket API"
|
||||
help = "A Briar peer without GUI that exposes a REST and Websocket API"
|
||||
) {
|
||||
private val debug by option("--debug", "-d", help = "Enable printing of debug messages").flag(
|
||||
default = false
|
||||
|
||||
@@ -6,7 +6,7 @@ import org.briarproject.briar.api.blog.MessageType
|
||||
import org.briarproject.briar.headless.json.JsonDict
|
||||
|
||||
internal fun BlogPostHeader.output(body: String) = JsonDict(
|
||||
"body" to body,
|
||||
"text" to body,
|
||||
"author" to author.output(),
|
||||
"authorStatus" to authorStatus.output(),
|
||||
"type" to type.output(),
|
||||
|
||||
@@ -21,7 +21,7 @@ constructor(private val forumManager: ForumManager) : ForumController {
|
||||
}
|
||||
|
||||
override fun create(ctx: Context): Context {
|
||||
val name = ctx.getFromJson("text")
|
||||
val name = ctx.getFromJson("name")
|
||||
if (StringUtils.utf8IsTooLong(name, MAX_FORUM_NAME_LENGTH))
|
||||
throw BadRequestResponse("Forum name is too long")
|
||||
return ctx.json(forumManager.addForum(name).output())
|
||||
|
||||
@@ -19,19 +19,22 @@ internal fun PrivateMessageHeader.output(contactId: ContactId) = JsonDict(
|
||||
|
||||
internal fun PrivateMessageHeader.output(contactId: ContactId, body: String?): JsonDict {
|
||||
val dict = output(contactId)
|
||||
dict["body"] = body
|
||||
dict["text"] = body
|
||||
return dict
|
||||
}
|
||||
|
||||
/**
|
||||
* Use only for outgoing messages that were just sent
|
||||
*/
|
||||
internal fun PrivateMessage.output(contactId: ContactId, body: String) = JsonDict(
|
||||
"type" to "PrivateMessage",
|
||||
"contactId" to contactId.int,
|
||||
"timestamp" to message.timestamp,
|
||||
"read" to true,
|
||||
"seen" to true,
|
||||
"sent" to true,
|
||||
"seen" to false,
|
||||
"sent" to false,
|
||||
"local" to true,
|
||||
"id" to message.id.bytes,
|
||||
"groupId" to message.groupId.bytes,
|
||||
"body" to body
|
||||
"text" to body
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user