Renamed getCloseGroup -> getGroup

This commit is contained in:
SessionHero01 2024-10-30 11:47:48 +11:00
parent 22b4479019
commit be087fd575
No known key found for this signature in database
9 changed files with 26 additions and 27 deletions

View File

@ -25,7 +25,7 @@ import org.session.libsession.utilities.ConfigFactoryProtocol
import org.session.libsession.utilities.ConfigPushResult import org.session.libsession.utilities.ConfigPushResult
import org.session.libsession.utilities.ConfigUpdateNotification import org.session.libsession.utilities.ConfigUpdateNotification
import org.session.libsession.utilities.UserConfigType import org.session.libsession.utilities.UserConfigType
import org.session.libsession.utilities.getClosedGroup import org.session.libsession.utilities.getGroup
import org.session.libsignal.utilities.AccountId import org.session.libsignal.utilities.AccountId
import org.session.libsignal.utilities.Base64 import org.session.libsignal.utilities.Base64
import org.session.libsignal.utilities.Log import org.session.libsignal.utilities.Log
@ -98,7 +98,7 @@ class ConfigUploader @Inject constructor(
private suspend fun pushGroupConfigsChangesIfNeeded(groupId: AccountId) = coroutineScope { private suspend fun pushGroupConfigsChangesIfNeeded(groupId: AccountId) = coroutineScope {
// Only admin can push group configs // Only admin can push group configs
val adminKey = configFactory.getClosedGroup(groupId)?.adminKey val adminKey = configFactory.getGroup(groupId)?.adminKey
if (adminKey == null) { if (adminKey == null) {
Log.i(TAG, "Skipping group config push without admin key") Log.i(TAG, "Skipping group config push without admin key")
return@coroutineScope return@coroutineScope

View File

@ -32,6 +32,7 @@ import org.session.libsession.messaging.utilities.SodiumUtilities
import org.session.libsession.utilities.Address import org.session.libsession.utilities.Address
import org.session.libsession.utilities.Address.Companion.fromSerialized import org.session.libsession.utilities.Address.Companion.fromSerialized
import org.session.libsession.utilities.TextSecurePreferences import org.session.libsession.utilities.TextSecurePreferences
import org.session.libsession.utilities.getGroup
import org.session.libsession.utilities.recipients.Recipient import org.session.libsession.utilities.recipients.Recipient
import org.session.libsession.utilities.recipients.MessageType import org.session.libsession.utilities.recipients.MessageType
import org.session.libsession.utilities.recipients.getType import org.session.libsession.utilities.recipients.getType

View File

@ -62,7 +62,7 @@ import org.session.libsession.utilities.GroupUtil
import org.session.libsession.utilities.ProfileKeyUtil import org.session.libsession.utilities.ProfileKeyUtil
import org.session.libsession.utilities.SSKEnvironment import org.session.libsession.utilities.SSKEnvironment
import org.session.libsession.utilities.TextSecurePreferences import org.session.libsession.utilities.TextSecurePreferences
import org.session.libsession.utilities.getClosedGroup import org.session.libsession.utilities.getGroup
import org.session.libsession.utilities.recipients.Recipient import org.session.libsession.utilities.recipients.Recipient
import org.session.libsession.utilities.recipients.Recipient.DisappearingState import org.session.libsession.utilities.recipients.Recipient.DisappearingState
import org.session.libsession.utilities.recipients.MessageType import org.session.libsession.utilities.recipients.MessageType
@ -1016,7 +1016,7 @@ open class Storage @Inject constructor(
} }
override fun getClosedGroupDisplayInfo(groupAccountId: String): GroupDisplayInfo? { override fun getClosedGroupDisplayInfo(groupAccountId: String): GroupDisplayInfo? {
val groupIsAdmin = configFactory.getClosedGroup(AccountId(groupAccountId))?.hasAdminKey() ?: return null val groupIsAdmin = configFactory.getGroup(AccountId(groupAccountId))?.hasAdminKey() ?: return null
return configFactory.withGroupConfigs(AccountId(groupAccountId)) { configs -> return configFactory.withGroupConfigs(AccountId(groupAccountId)) { configs ->
val info = configs.groupInfo val info = configs.groupInfo
@ -1037,7 +1037,7 @@ open class Storage @Inject constructor(
val sentTimestamp = message.sentTimestamp ?: clock.currentTimeMills() val sentTimestamp = message.sentTimestamp ?: clock.currentTimeMills()
val senderPublicKey = message.sender val senderPublicKey = message.sender
val groupName = configFactory.withGroupConfigs(closedGroup) { it.groupInfo.getName() } val groupName = configFactory.withGroupConfigs(closedGroup) { it.groupInfo.getName() }
?: configFactory.getClosedGroup(closedGroup)?.name ?: configFactory.getGroup(closedGroup)?.name
val updateData = UpdateMessageData.buildGroupUpdate(message, groupName.orEmpty()) ?: return null val updateData = UpdateMessageData.buildGroupUpdate(message, groupName.orEmpty()) ?: return null

View File

@ -41,7 +41,7 @@ import org.session.libsession.utilities.MutableUserConfigs
import org.session.libsession.utilities.TextSecurePreferences import org.session.libsession.utilities.TextSecurePreferences
import org.session.libsession.utilities.UserConfigType import org.session.libsession.utilities.UserConfigType
import org.session.libsession.utilities.UserConfigs import org.session.libsession.utilities.UserConfigs
import org.session.libsession.utilities.getClosedGroup import org.session.libsession.utilities.getGroup
import org.session.libsignal.crypto.ecc.DjbECPublicKey import org.session.libsignal.crypto.ecc.DjbECPublicKey
import org.session.libsignal.utilities.AccountId import org.session.libsignal.utilities.AccountId
import org.session.libsignal.utilities.Hex import org.session.libsignal.utilities.Hex
@ -118,7 +118,7 @@ class ConfigFactory @Inject constructor(
} }
private fun ensureGroupConfigsInitialized(groupId: AccountId): Pair<ReentrantReadWriteLock, GroupConfigsImpl> { private fun ensureGroupConfigsInitialized(groupId: AccountId): Pair<ReentrantReadWriteLock, GroupConfigsImpl> {
val groupAdminKey = getClosedGroup(groupId)?.adminKey val groupAdminKey = getGroup(groupId)?.adminKey
return synchronized(groupConfigs) { return synchronized(groupConfigs) {
groupConfigs.getOrPut(groupId) { groupConfigs.getOrPut(groupId) {
ReentrantReadWriteLock() to GroupConfigsImpl( ReentrantReadWriteLock() to GroupConfigsImpl(

View File

@ -43,7 +43,7 @@ import org.session.libsession.snode.model.BatchResponse
import org.session.libsession.snode.utilities.await import org.session.libsession.snode.utilities.await
import org.session.libsession.utilities.Address import org.session.libsession.utilities.Address
import org.session.libsession.utilities.SSKEnvironment import org.session.libsession.utilities.SSKEnvironment
import org.session.libsession.utilities.getClosedGroup import org.session.libsession.utilities.getGroup
import org.session.libsession.utilities.recipients.Recipient import org.session.libsession.utilities.recipients.Recipient
import org.session.libsession.utilities.waitUntilGroupConfigsPushed import org.session.libsession.utilities.waitUntilGroupConfigsPushed
import org.session.libsignal.messages.SignalServiceGroup import org.session.libsignal.messages.SignalServiceGroup
@ -87,7 +87,7 @@ class GroupManagerV2Impl @Inject constructor(
*/ */
private fun requireAdminAccess(group: AccountId): ByteArray { private fun requireAdminAccess(group: AccountId): ByteArray {
return checkNotNull( return checkNotNull(
configFactory.getClosedGroup(group) configFactory.getGroup(group)
?.adminKey ?.adminKey
?.takeIf { it.isNotEmpty() } ?.takeIf { it.isNotEmpty() }
) { "Only admin is allowed to invite members" } ) { "Only admin is allowed to invite members" }
@ -384,7 +384,7 @@ class GroupManagerV2Impl @Inject constructor(
return@withContext return@withContext
} }
val groupAdminAuth = configFactory.getClosedGroup(groupAccountId)?.adminKey?.let { val groupAdminAuth = configFactory.getGroup(groupAccountId)?.adminKey?.let {
OwnedSwarmAuth.ofClosedGroup(groupAccountId, it) OwnedSwarmAuth.ofClosedGroup(groupAccountId, it)
} ?: return@withContext } ?: return@withContext
@ -392,7 +392,7 @@ class GroupManagerV2Impl @Inject constructor(
} }
override suspend fun handleMemberLeftMessage(memberId: AccountId, group: AccountId) { override suspend fun handleMemberLeftMessage(memberId: AccountId, group: AccountId) {
val closedGroup = configFactory.getClosedGroup(group) ?: return val closedGroup = configFactory.getGroup(group) ?: return
val groupAdminKey = closedGroup.adminKey val groupAdminKey = closedGroup.adminKey
if (groupAdminKey != null) { if (groupAdminKey != null) {
@ -406,7 +406,7 @@ class GroupManagerV2Impl @Inject constructor(
} }
override suspend fun leaveGroup(groupId: AccountId, deleteOnLeave: Boolean) = withContext(dispatcher + SupervisorJob()) { override suspend fun leaveGroup(groupId: AccountId, deleteOnLeave: Boolean) = withContext(dispatcher + SupervisorJob()) {
val group = configFactory.getClosedGroup(groupId) val group = configFactory.getGroup(groupId)
// Only send the left/left notification group message when we are not kicked and we are not the only admin (only admin has a special treatment) // Only send the left/left notification group message when we are not kicked and we are not the only admin (only admin has a special treatment)
val weAreTheOnlyAdmin = configFactory.withGroupConfigs(groupId) { config -> val weAreTheOnlyAdmin = configFactory.withGroupConfigs(groupId) { config ->
@ -664,7 +664,7 @@ class GroupManagerV2Impl @Inject constructor(
promoteMessageTimestamp: Long, promoteMessageTimestamp: Long,
): Unit = withContext(dispatcher) { ): Unit = withContext(dispatcher) {
val userAuth = requireNotNull(storage.userAuth) { "No current user available" } val userAuth = requireNotNull(storage.userAuth) { "No current user available" }
val group = configFactory.getClosedGroup(groupId) val group = configFactory.getGroup(groupId)
if (group == null) { if (group == null) {
// If we haven't got the group in the config, it could mean that we haven't // If we haven't got the group in the config, it could mean that we haven't
@ -722,7 +722,7 @@ class GroupManagerV2Impl @Inject constructor(
inviteMessageTimestamp: Long inviteMessageTimestamp: Long
) { ) {
// If we have already received an invitation in the past, we should not process this one // If we have already received an invitation in the past, we should not process this one
if (configFactory.getClosedGroup(groupId)?.invited == true) { if (configFactory.getGroup(groupId)?.invited == true) {
return return
} }
@ -772,7 +772,7 @@ class GroupManagerV2Impl @Inject constructor(
return@withContext return@withContext
} }
val adminKey = configFactory.getClosedGroup(groupId)?.adminKey val adminKey = configFactory.getGroup(groupId)?.adminKey
if (adminKey == null || adminKey.isEmpty()) { if (adminKey == null || adminKey.isEmpty()) {
return@withContext // We don't have the admin key, we can't process the invite response return@withContext // We don't have the admin key, we can't process the invite response
} }
@ -794,7 +794,7 @@ class GroupManagerV2Impl @Inject constructor(
pollerFactory.pollerFor(groupId)?.stop() pollerFactory.pollerFor(groupId)?.stop()
val userId = requireNotNull(storage.getUserPublicKey()) { "No current user available" } val userId = requireNotNull(storage.getUserPublicKey()) { "No current user available" }
val group = configFactory.getClosedGroup(groupId) ?: return@withContext val group = configFactory.getGroup(groupId) ?: return@withContext
// Retrieve the group name one last time from the group info, // Retrieve the group name one last time from the group info,
// as we are going to clear the keys, we won't have the chance to // as we are going to clear the keys, we won't have the chance to
@ -877,7 +877,7 @@ class GroupManagerV2Impl @Inject constructor(
// meanwhile, if we are admin we can just delete those messages from the group swarm, and otherwise // meanwhile, if we are admin we can just delete those messages from the group swarm, and otherwise
// the admins can pick up the group message and delete the messages on our behalf. // the admins can pick up the group message and delete the messages on our behalf.
val group = requireNotNull(configFactory.getClosedGroup(groupId)) { val group = requireNotNull(configFactory.getGroup(groupId)) {
"Group doesn't exist" "Group doesn't exist"
} }
val userPubKey = requireNotNull(storage.getUserPublicKey()) { "No current user available" } val userPubKey = requireNotNull(storage.getUserPublicKey()) { "No current user available" }
@ -981,7 +981,7 @@ class GroupManagerV2Impl @Inject constructor(
} }
} }
val adminKey = configFactory.getClosedGroup(groupId)?.adminKey val adminKey = configFactory.getGroup(groupId)?.adminKey
if (!senderIsVerifiedAdmin && adminKey != null && hashes.isNotEmpty()) { if (!senderIsVerifiedAdmin && adminKey != null && hashes.isNotEmpty()) {
// If the deletion request comes from a non-admin, and we as an admin, will also delete // If the deletion request comes from a non-admin, and we as an admin, will also delete
// the content from the swarm, provided that the messages are actually sent by that user // the content from the swarm, provided that the messages are actually sent by that user

View File

@ -20,12 +20,11 @@ import org.session.libsession.snode.utilities.await
import org.session.libsession.utilities.StringSubstitutionConstants.GROUP_NAME_KEY import org.session.libsession.utilities.StringSubstitutionConstants.GROUP_NAME_KEY
import org.session.libsession.utilities.StringSubstitutionConstants.NAME_KEY import org.session.libsession.utilities.StringSubstitutionConstants.NAME_KEY
import org.session.libsession.utilities.StringSubstitutionConstants.OTHER_NAME_KEY import org.session.libsession.utilities.StringSubstitutionConstants.OTHER_NAME_KEY
import org.session.libsession.utilities.getClosedGroup import org.session.libsession.utilities.getGroup
import org.session.libsession.utilities.truncateIdForDisplay import org.session.libsession.utilities.truncateIdForDisplay
import org.session.libsignal.protos.SignalServiceProtos.DataMessage.GroupUpdateInviteMessage import org.session.libsignal.protos.SignalServiceProtos.DataMessage.GroupUpdateInviteMessage
import org.session.libsignal.protos.SignalServiceProtos.DataMessage.GroupUpdateMessage import org.session.libsignal.protos.SignalServiceProtos.DataMessage.GroupUpdateMessage
import org.session.libsignal.utilities.AccountId import org.session.libsignal.utilities.AccountId
import org.session.libsignal.utilities.prettifiedDescription
class InviteContactsJob(val groupSessionId: String, val memberSessionIds: Array<String>) : Job { class InviteContactsJob(val groupSessionId: String, val memberSessionIds: Array<String>) : Job {
@ -101,7 +100,7 @@ class InviteContactsJob(val groupSessionId: String, val memberSessionIds: Array<
} }
val groupName = configs.withGroupConfigs(sessionId) { it.groupInfo.getName() } val groupName = configs.withGroupConfigs(sessionId) { it.groupInfo.getName() }
?: configs.getClosedGroup(sessionId)?.name ?: configs.getGroup(sessionId)?.name
val failures = results.filter { it.second.isFailure } val failures = results.filter { it.second.isFailure }
// if there are failed invites, display a message // if there are failed invites, display a message

View File

@ -22,10 +22,9 @@ import org.session.libsession.snode.RawResponse
import org.session.libsession.snode.SnodeAPI import org.session.libsession.snode.SnodeAPI
import org.session.libsession.snode.SnodeClock import org.session.libsession.snode.SnodeClock
import org.session.libsession.snode.model.RetrieveMessageResponse import org.session.libsession.snode.model.RetrieveMessageResponse
import org.session.libsession.snode.utilities.await
import org.session.libsession.utilities.ConfigFactoryProtocol import org.session.libsession.utilities.ConfigFactoryProtocol
import org.session.libsession.utilities.ConfigMessage import org.session.libsession.utilities.ConfigMessage
import org.session.libsession.utilities.getClosedGroup import org.session.libsession.utilities.getGroup
import org.session.libsignal.database.LokiAPIDatabaseProtocol import org.session.libsignal.database.LokiAPIDatabaseProtocol
import org.session.libsignal.exceptions.NonRetryableException import org.session.libsignal.exceptions.NonRetryableException
import org.session.libsignal.utilities.AccountId import org.session.libsignal.utilities.AccountId
@ -136,7 +135,7 @@ class ClosedGroupPoller(
} }
} }
val group = configFactoryProtocol.getClosedGroup(closedGroupSessionId) val group = configFactoryProtocol.getGroup(closedGroupSessionId)
if (group == null) { if (group == null) {
throw NonRetryableException("Group doesn't exist") throw NonRetryableException("Group doesn't exist")
} }

View File

@ -26,7 +26,7 @@ import org.session.libsession.utilities.StringSubstitutionConstants.GROUP_NAME_K
import org.session.libsession.utilities.StringSubstitutionConstants.NAME_KEY import org.session.libsession.utilities.StringSubstitutionConstants.NAME_KEY
import org.session.libsession.utilities.StringSubstitutionConstants.OTHER_NAME_KEY import org.session.libsession.utilities.StringSubstitutionConstants.OTHER_NAME_KEY
import org.session.libsession.utilities.StringSubstitutionConstants.TIME_KEY import org.session.libsession.utilities.StringSubstitutionConstants.TIME_KEY
import org.session.libsession.utilities.getClosedGroup import org.session.libsession.utilities.getGroup
import org.session.libsignal.utilities.AccountId import org.session.libsignal.utilities.AccountId
object UpdateMessageBuilder { object UpdateMessageBuilder {
@ -282,7 +282,7 @@ object UpdateMessageBuilder {
} }
is UpdateMessageData.Kind.GroupInvitation -> { is UpdateMessageData.Kind.GroupInvitation -> {
val invitingAdmin = Recipient.from(context, Address.fromSerialized(updateData.invitingAdmin), false) val invitingAdmin = Recipient.from(context, Address.fromSerialized(updateData.invitingAdmin), false)
val approved = configFactory.getClosedGroup(AccountId(updateData.groupAccountId))?.invited == false val approved = configFactory.getGroup(AccountId(updateData.groupAccountId))?.invited == false
return if (invitingAdmin.name != null && !approved) { return if (invitingAdmin.name != null && !approved) {
Phrase.from(context, R.string.messageRequestGroupInvite) Phrase.from(context, R.string.messageRequestGroupInvite)
.put(NAME_KEY, invitingAdmin.name) .put(NAME_KEY, invitingAdmin.name)

View File

@ -97,7 +97,7 @@ enum class UserConfigType(val namespace: Int) {
/** /**
* Shortcut to get the group info for a closed group. Equivalent to: `withUserConfigs { it.userGroups.getClosedGroup(groupId) }` * Shortcut to get the group info for a closed group. Equivalent to: `withUserConfigs { it.userGroups.getClosedGroup(groupId) }`
*/ */
fun ConfigFactoryProtocol.getClosedGroup(groupId: AccountId): GroupInfo.ClosedGroupInfo? { fun ConfigFactoryProtocol.getGroup(groupId: AccountId): GroupInfo.ClosedGroupInfo? {
return withUserConfigs { it.userGroups.getClosedGroup(groupId.hexString) } return withUserConfigs { it.userGroups.getClosedGroup(groupId.hexString) }
} }