[headless] Fix unit tests by passing only timestamp into OutputContact

This commit is contained in:
Torsten Grote
2020-04-20 09:15:56 -03:00
parent 6135f9152f
commit f61e2b399e
3 changed files with 13 additions and 12 deletions

View File

@@ -63,7 +63,8 @@ constructor(
override fun list(ctx: Context): Context {
val contacts = contactManager.contacts.map { contact ->
contact.output(conversationManager)
val latestMsgTime = conversationManager.getGroupCount(contact.id).latestMsgTime
contact.output(latestMsgTime)
}
return ctx.json(contacts)
}

View File

@@ -6,19 +6,16 @@ import org.briarproject.bramble.identity.output
import org.briarproject.briar.api.conversation.ConversationManager
import org.briarproject.briar.headless.json.JsonDict
internal fun Contact.output(conversationManager: ConversationManager) = JsonDict(
internal fun Contact.output(latestMsgTime: Long) = JsonDict(
"contactId" to id.int,
"author" to author.output(),
"verified" to isVerified,
"lastChatActivity" to this.getLastChatActivity(conversationManager)
"lastChatActivity" to latestMsgTime
).apply {
alias?.let { put("alias", it) }
handshakePublicKey?.let { put("handshakePublicKey", it.encoded) }
}
internal fun Contact.getLastChatActivity(conversationManager: ConversationManager) =
conversationManager.getGroupCount(this.id).latestMsgTime
internal fun ContactAddedEvent.output() = JsonDict(
"contactId" to contactId.int,
"verified" to isVerified