Expose unread messages count in API's contacts list

Fixes #1746
This commit is contained in:
Nico Alt
2020-09-25 12:40:43 +02:00
parent 4e5f2e31df
commit ccbe6d4bb8
5 changed files with 13 additions and 7 deletions

View File

@@ -46,6 +46,7 @@ abstract class ControllerTest {
protected val message: Message = getMessage(group.id)
protected val text: String = getRandomString(5)
protected val timestamp = 42L
protected val unreadCount = 42
protected fun assertJsonEquals(json: String, obj: Any) {
assertEquals(json, outputCtx.json(obj).resultString(), STRICT)

View File

@@ -58,7 +58,8 @@ internal class ContactControllerTest : ControllerTest() {
every { contactManager.contacts } returns listOf(contact)
every { conversationManager.getGroupCount(contact.id).latestMsgTime } returns timestamp
every { connectionRegistry.isConnected(contact.id) } returns connected
every { ctx.json(listOf(contact.output(timestamp, connected))) } returns ctx
every { conversationManager.getGroupCount(contact.id).unreadCount } returns unreadCount
every { ctx.json(listOf(contact.output(timestamp, connected, unreadCount))) } returns ctx
controller.list(ctx)
}
@@ -313,10 +314,11 @@ internal class ContactControllerTest : ControllerTest() {
"handshakePublicKey": ${toJson(contact.handshakePublicKey!!.encoded)},
"verified": ${contact.isVerified},
"lastChatActivity": $timestamp,
"connected": $connected
"connected": $connected,
"unreadCount": $unreadCount
}
"""
assertJsonEquals(json, contact.output(timestamp, connected))
assertJsonEquals(json, contact.output(timestamp, connected, unreadCount))
}
@Test