Use short type labels in JSON API instead of long Java-like namespaces

This commit is contained in:
Torsten Grote
2018-10-03 13:44:25 -03:00
parent ea749f2128
commit 6f54718756
7 changed files with 19 additions and 23 deletions

View File

@@ -31,8 +31,7 @@ import javax.annotation.concurrent.Immutable
import javax.inject.Inject
import javax.inject.Singleton
internal const val EVENT_PRIVATE_MESSAGE =
"org.briarproject.briar.api.messaging.event.PrivateMessageReceivedEvent"
internal const val EVENT_PRIVATE_MESSAGE = "PrivateMessageReceivedEvent"
@Immutable
@Singleton
@@ -121,4 +120,4 @@ private class JsonVisitor(
override fun visitIntroductionRequest(r: IntroductionRequest) = r.output(contactId)
override fun visitIntroductionResponse(r: IntroductionResponse) = r.output(contactId)
}
}

View File

@@ -6,7 +6,7 @@ import org.briarproject.briar.api.messaging.PrivateMessageHeader
import org.briarproject.briar.headless.json.JsonDict
internal fun PrivateMessageHeader.output(contactId: ContactId, body: String?) = JsonDict(
"type" to "org.briarproject.briar.api.messaging.PrivateMessageHeader",
"type" to "PrivateMessage",
"contactId" to contactId.int,
"timestamp" to timestamp,
"read" to isRead,
@@ -19,7 +19,7 @@ internal fun PrivateMessageHeader.output(contactId: ContactId, body: String?) =
)
internal fun PrivateMessage.output(contactId: ContactId, body: String) = JsonDict(
"type" to "org.briarproject.briar.api.messaging.PrivateMessageHeader",
"type" to "PrivateMessage",
"contactId" to contactId.int,
"timestamp" to message.timestamp,
"read" to true,

View File

@@ -23,7 +23,7 @@ internal fun PrivateRequest<*>.output(contactId: ContactId): JsonDict {
internal fun IntroductionRequest.output(contactId: ContactId): JsonDict {
val dict = (this as PrivateRequest<*>).output(contactId)
dict.putAll(
"type" to "org.briarproject.briar.api.introduction.IntroductionRequest",
"type" to "IntroductionRequest",
"alreadyContact" to isContact
)
return dict
@@ -37,18 +37,18 @@ internal fun InvitationRequest<*>.output(contactId: ContactId): JsonDict {
internal fun BlogInvitationRequest.output(contactId: ContactId): JsonDict {
val dict = (this as InvitationRequest<*>).output(contactId)
dict["type"] = "org.briarproject.briar.api.blog.BlogInvitationRequest"
dict["type"] = "BlogInvitationRequest"
return dict
}
internal fun ForumInvitationRequest.output(contactId: ContactId): JsonDict {
val dict = (this as InvitationRequest<*>).output(contactId)
dict["type"] = "org.briarproject.briar.api.forum.ForumInvitationRequest"
dict["type"] = "ForumInvitationRequest"
return dict
}
internal fun GroupInvitationRequest.output(contactId: ContactId): JsonDict {
val dict = (this as InvitationRequest<*>).output(contactId)
dict["type"] = "org.briarproject.briar.api.privategroup.invitation.GroupInvitationRequest"
dict["type"] = "GroupInvitationRequest"
return dict
}

View File

@@ -23,7 +23,7 @@ internal fun PrivateResponse.output(contactId: ContactId): JsonDict {
internal fun IntroductionResponse.output(contactId: ContactId): JsonDict {
val dict = (this as PrivateResponse).output(contactId)
dict.putAll(
"type" to "org.briarproject.briar.api.introduction.IntroductionResponse",
"type" to "IntroductionResponse",
"introducedAuthor" to introducedAuthor.output(),
"introducer" to isIntroducer
)
@@ -38,18 +38,18 @@ internal fun InvitationResponse.output(contactId: ContactId): JsonDict {
internal fun BlogInvitationResponse.output(contactId: ContactId): JsonDict {
val dict = (this as InvitationResponse).output(contactId)
dict["type"] = "org.briarproject.briar.api.blog.BlogInvitationResponse"
dict["type"] = "BlogInvitationResponse"
return dict
}
internal fun ForumInvitationResponse.output(contactId: ContactId): JsonDict {
val dict = (this as InvitationResponse).output(contactId)
dict["type"] = "org.briarproject.briar.api.blog.BlogInvitationResponse"
dict["type"] = "BlogInvitationResponse"
return dict
}
internal fun GroupInvitationResponse.output(contactId: ContactId): JsonDict {
val dict = (this as InvitationResponse).output(contactId)
dict["type"] = "org.briarproject.briar.api.privategroup.invitation.GroupInvitationResponse"
dict["type"] = "GroupInvitationResponse"
return dict
}