feat: member counts in v2 open group ConversationActivity

This commit is contained in:
jubb
2021-05-05 13:52:15 +10:00
parent d8e9e372d3
commit 35aec04ac9
8 changed files with 83 additions and 16 deletions

View File

@@ -79,7 +79,7 @@ interface StorageProtocol {
fun updateTitle(groupID: String, newValue: String)
fun updateProfilePicture(groupID: String, newValue: ByteArray)
fun setUserCount(room: String, server: String, newValue: Long)
fun setUserCount(room: String, server: String, newValue: Int)
// Last Message Server ID
fun getLastMessageServerId(room: String, server: String): Long?

View File

@@ -482,10 +482,10 @@ object OpenGroupAPIV2 {
}
}
fun getMemberCount(room: String, server: String): Promise<Long, Exception> {
fun getMemberCount(room: String, server: String): Promise<Int, Exception> {
val request = Request(verb = GET, room = room, server = server, endpoint = "member_count")
return send(request).map { json ->
val memberCount = json["member_count"] as? Long ?: throw Error.PARSING_FAILED
val memberCount = json["member_count"] as? Int ?: throw Error.PARSING_FAILED
val storage = MessagingModuleConfiguration.shared.storage
storage.setUserCount(room, server, memberCount)
memberCount