mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-27 20:15:21 +00:00
add open group through configuration message
This commit is contained in:
parent
5ceaf87ba9
commit
c32c58eee7
@ -31,6 +31,7 @@ import org.session.libsignal.service.loki.api.opengroups.PublicChat
|
||||
import org.thoughtcrime.securesms.crypto.IdentityKeyUtil
|
||||
import org.thoughtcrime.securesms.database.helpers.SQLCipherOpenHelper
|
||||
import org.thoughtcrime.securesms.loki.database.LokiThreadDatabase
|
||||
import org.thoughtcrime.securesms.loki.utilities.OpenGroupUtilities
|
||||
import org.thoughtcrime.securesms.loki.utilities.get
|
||||
import org.thoughtcrime.securesms.loki.utilities.getString
|
||||
import org.thoughtcrime.securesms.mms.IncomingMediaMessage
|
||||
@ -396,6 +397,10 @@ class Storage(context: Context, helper: SQLCipherOpenHelper) : Database(context,
|
||||
return DatabaseFactory.getLokiThreadDatabase(context).getAllPublicChats()
|
||||
}
|
||||
|
||||
override fun addOpenGroup(server: String, channel: Long) {
|
||||
OpenGroupUtilities.addGroup(context, server, channel)
|
||||
}
|
||||
|
||||
override fun getAllGroups(): List<GroupRecord> {
|
||||
return DatabaseFactory.getGroupDatabase(context).allGroups
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ object OpenGroupUtilities {
|
||||
val groupID = PublicChat.getId(channel, url)
|
||||
val threadID = GroupManager.getOpenGroupThreadID(groupID, context)
|
||||
val openGroup = DatabaseFactory.getLokiThreadDatabase(context).getPublicChat(threadID)
|
||||
if (openGroup != null) return openGroup
|
||||
if (openGroup != null) { return openGroup }
|
||||
|
||||
// Add the new group.
|
||||
val application = ApplicationContext.getInstance(context)
|
||||
|
@ -58,6 +58,7 @@ interface StorageProtocol {
|
||||
fun getOpenGroup(threadID: String): OpenGroup?
|
||||
fun getThreadID(openGroupID: String): String?
|
||||
fun getAllOpenGroups(): Map<Long, PublicChat>
|
||||
fun addOpenGroup(server: String, channel: Long)
|
||||
|
||||
// Open Group Public Keys
|
||||
fun getOpenGroupPublicKey(server: String): String?
|
||||
|
@ -113,7 +113,7 @@ private fun MessageReceiver.handleConfigurationMessage(message: ConfigurationMes
|
||||
val allOpenGroups = storage.getAllOpenGroups().map { it.value.server }
|
||||
for (openGroup in message.openGroups) {
|
||||
if (allOpenGroups.contains(openGroup)) continue
|
||||
// TODO
|
||||
storage.addOpenGroup(openGroup, 1)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user