Fix unable to receive "invite-as-admin" (#892)

pull/1709/head
SessionHero01 11 months ago committed by GitHub
parent db4e384cd5
commit e214868f15
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -19,6 +19,7 @@ import network.loki.messenger.libsession_util.util.Conversation
import network.loki.messenger.libsession_util.util.ExpiryMode import network.loki.messenger.libsession_util.util.ExpiryMode
import network.loki.messenger.libsession_util.util.GroupInfo import network.loki.messenger.libsession_util.util.GroupInfo
import network.loki.messenger.libsession_util.util.GroupMember import network.loki.messenger.libsession_util.util.GroupMember
import network.loki.messenger.libsession_util.util.Sodium
import network.loki.messenger.libsession_util.util.UserPic import network.loki.messenger.libsession_util.util.UserPic
import org.session.libsession.database.MessageDataProvider import org.session.libsession.database.MessageDataProvider
import org.session.libsession.database.StorageProtocol import org.session.libsession.database.StorageProtocol
@ -720,7 +721,7 @@ class GroupManagerV2Impl @Inject constructor(
override suspend fun handlePromotion( override suspend fun handlePromotion(
groupId: AccountId, groupId: AccountId,
groupName: String, groupName: String,
adminKey: ByteArray, adminKeySeed: ByteArray,
promoter: AccountId, promoter: AccountId,
promoterName: String?, promoterName: String?,
promoteMessageHash: String, promoteMessageHash: String,
@ -736,7 +737,7 @@ class GroupManagerV2Impl @Inject constructor(
handleInvitation( handleInvitation(
groupId = groupId, groupId = groupId,
groupName = groupName, groupName = groupName,
authDataOrAdminSeed = adminKey, authDataOrAdminSeed = adminKeySeed,
fromPromotion = true, fromPromotion = true,
inviter = promoter, inviter = promoter,
inviterName = promoterName, inviterName = promoterName,
@ -745,6 +746,8 @@ class GroupManagerV2Impl @Inject constructor(
) )
} else { } else {
// If we have the group in the config, we can just update the admin key // If we have the group in the config, we can just update the admin key
val adminKey = GroupInfo.ClosedGroupInfo.adminKeyFromSeed(adminKeySeed)
configFactory.withMutableUserConfigs { configFactory.withMutableUserConfigs {
it.userGroups.set(group.copy(adminKey = adminKey)) it.userGroups.set(group.copy(adminKey = adminKey))
} }

@ -61,7 +61,7 @@ interface GroupManagerV2 {
suspend fun handlePromotion( suspend fun handlePromotion(
groupId: AccountId, groupId: AccountId,
groupName: String, groupName: String,
adminKey: ByteArray, adminKeySeed: ByteArray,
promoter: AccountId, promoter: AccountId,
promoterName: String?, promoterName: String?,
promoteMessageHash: String, promoteMessageHash: String,

@ -719,16 +719,15 @@ private fun handleGroupInfoChange(message: GroupUpdated, closedGroup: AccountId)
private fun handlePromotionMessage(message: GroupUpdated) { private fun handlePromotionMessage(message: GroupUpdated) {
val promotion = message.inner.promoteMessage val promotion = message.inner.promoteMessage
val seed = promotion.groupIdentitySeed.toByteArray() val seed = promotion.groupIdentitySeed.toByteArray()
val keyPair = Sodium.ed25519KeyPair(seed)
val sender = message.sender!! val sender = message.sender!!
val adminId = AccountId(sender) val adminId = AccountId(sender)
GlobalScope.launch { GlobalScope.launch {
try { try {
MessagingModuleConfiguration.shared.groupManagerV2 MessagingModuleConfiguration.shared.groupManagerV2
.handlePromotion( .handlePromotion(
groupId = AccountId(IdPrefix.GROUP, keyPair.pubKey), groupId = AccountId(IdPrefix.GROUP, Sodium.ed25519KeyPair(seed).pubKey),
groupName = promotion.name, groupName = promotion.name,
adminKey = keyPair.secretKey, adminKeySeed = seed,
promoter = adminId, promoter = adminId,
promoterName = message.profile?.displayName, promoterName = message.profile?.displayName,
promoteMessageHash = message.serverHash!!, promoteMessageHash = message.serverHash!!,

Loading…
Cancel
Save