briar-headless: Last round of review comments

This commit is contained in:
Torsten Grote
2018-10-09 12:19:21 -03:00
parent e3686186ee
commit b3615b4a77
11 changed files with 32 additions and 26 deletions

View File

@@ -11,4 +11,3 @@ fun Author.output() = JsonDict(
)
fun Author.Status.output() = name.toLowerCase()

View File

@@ -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

View File

@@ -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(),

View File

@@ -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())

View File

@@ -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
)