diff --git a/src/org/thoughtcrime/securesms/loki/activities/CreateClosedGroupActivity.kt b/src/org/thoughtcrime/securesms/loki/activities/CreateClosedGroupActivity.kt index 87f7020a87..d79a10fc0d 100644 --- a/src/org/thoughtcrime/securesms/loki/activities/CreateClosedGroupActivity.kt +++ b/src/org/thoughtcrime/securesms/loki/activities/CreateClosedGroupActivity.kt @@ -124,7 +124,8 @@ class CreateClosedGroupActivity : PassphraseRequiredActionBarActivity(), MemberC if (selectedMembers.count() > 49) { // Minus one because we're going to include self later return Toast.makeText(this, R.string.activity_create_closed_group_too_many_group_members_error, Toast.LENGTH_LONG).show() } - ClosedGroupsProtocol.createClosedGroup(this, name.toString(), selectedMembers) + val userPublicKey = TextSecurePreferences.getLocalNumber(this) + ClosedGroupsProtocol.createClosedGroup(this, name.toString(), selectedMembers + setOf( userPublicKey )) } private fun createLegacyClosedGroup() { diff --git a/src/org/thoughtcrime/securesms/loki/protocol/ClosedGroupsProtocol.kt b/src/org/thoughtcrime/securesms/loki/protocol/ClosedGroupsProtocol.kt index 726dfa53e7..bebdce37af 100644 --- a/src/org/thoughtcrime/securesms/loki/protocol/ClosedGroupsProtocol.kt +++ b/src/org/thoughtcrime/securesms/loki/protocol/ClosedGroupsProtocol.kt @@ -6,7 +6,9 @@ import nl.komponents.kovenant.Promise import org.thoughtcrime.securesms.ApplicationContext import org.thoughtcrime.securesms.database.Address import org.thoughtcrime.securesms.database.DatabaseFactory +import org.thoughtcrime.securesms.database.ThreadDatabase import org.thoughtcrime.securesms.loki.utilities.recipient +import org.thoughtcrime.securesms.mms.OutgoingMediaMessage import org.thoughtcrime.securesms.recipients.Recipient import org.thoughtcrime.securesms.sms.MessageSender import org.thoughtcrime.securesms.util.GroupUtil @@ -57,7 +59,9 @@ object ClosedGroupsProtocol { // Add the group to the user's set of public keys to poll for DatabaseFactory.getSSKDatabase(context).setClosedGroupPrivateKey(groupPublicKey, groupKeyPair.hexEncodedPrivateKey) // Notify the user - // TODO: Implement + val infoMessage = OutgoingMediaMessage(Recipient.from(context, Address.fromSerialized(groupID), false), "Test", listOf(), System.currentTimeMillis(), + 0, 0, ThreadDatabase.DistributionTypes.CONVERSATION, null, listOf(), listOf(), listOf(), listOf()) + MessageSender.send(context, infoMessage, -1, false, null) // Return return Promise.of(Unit) } @@ -349,8 +353,12 @@ object ClosedGroupsProtocol { if (GroupUtil.isOpenGroup(groupID)) { return listOf( Address.fromSerialized(groupID) ) } else { - // TODO: Shared sender keys - return DatabaseFactory.getGroupDatabase(context).getGroupMembers(groupID, false).map { it.address } + val groupPublicKey = GroupUtil.getDecodedId(groupID).toHexString() + if (DatabaseFactory.getSSKDatabase(context).isSSKBasedClosedGroup(groupPublicKey)) { + return listOf( Address.fromSerialized(groupPublicKey) ) + } else { + return DatabaseFactory.getGroupDatabase(context).getGroupMembers(groupID, false).map { it.address } + } /* return FileServerAPI.shared.getDeviceLinks(members.map { it.address.serialize() }.toSet()).map { val result = members.flatMap { member ->