From 64f3bfd41d8984b70a7ea2768c6f48ae8f1d4654 Mon Sep 17 00:00:00 2001 From: Anton Chekulaev Date: Mon, 17 Aug 2020 10:53:02 +1000 Subject: [PATCH] Closed group protocol stub update method. --- .../activities/EditClosedGroupActivity.kt | 21 ++++++++++++++++++- .../loki/protocol/ClosedGroupsProtocol.kt | 12 +++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/org/thoughtcrime/securesms/loki/activities/EditClosedGroupActivity.kt b/src/org/thoughtcrime/securesms/loki/activities/EditClosedGroupActivity.kt index 8916fa0387..6830ca1418 100644 --- a/src/org/thoughtcrime/securesms/loki/activities/EditClosedGroupActivity.kt +++ b/src/org/thoughtcrime/securesms/loki/activities/EditClosedGroupActivity.kt @@ -22,9 +22,13 @@ import org.thoughtcrime.securesms.database.Address import org.thoughtcrime.securesms.database.DatabaseFactory import org.thoughtcrime.securesms.groups.GroupManager import org.thoughtcrime.securesms.loki.dialogs.GroupEditingOptionsBottomSheet +import org.thoughtcrime.securesms.loki.protocol.ClosedGroupsProtocol import org.thoughtcrime.securesms.mms.GlideApp import org.thoughtcrime.securesms.recipients.Recipient +import org.thoughtcrime.securesms.util.GroupUtil import org.whispersystems.signalservice.api.crypto.ProfileCipher +import org.whispersystems.signalservice.loki.utilities.toHexString +import java.io.IOException const val EXTRA_GROUP_ID = "GROUP_ID" const val REQ_CODE_ADD_USERS = 124 @@ -226,7 +230,22 @@ class EditClosedGroupActivity : PassphraseRequiredActionBarActivity() { return Toast.makeText(this, R.string.activity_edit_closed_group_too_many_group_members_error, Toast.LENGTH_LONG).show() } - GroupManager.updateGroup(this, groupID, finalGroupMembers, null, groupDisplayName, finalGroupAdmins) + var isSSKBasedClosedGroup: Boolean + var groupPublicKey: String? + try { + groupPublicKey = GroupUtil.getDecodedId(groupID).toHexString() + isSSKBasedClosedGroup = DatabaseFactory.getSSKDatabase(this).isSSKBasedClosedGroup(groupPublicKey) + } catch (e: IOException) { + groupPublicKey = null + isSSKBasedClosedGroup = false + } + + if (isSSKBasedClosedGroup) { + //TODO AC: Should it use "groupPublicKey" or "groupID"? + ClosedGroupsProtocol.updateGroup(this, groupPublicKey!!, finalGroupMembers, null, groupDisplayName, finalGroupAdmins) + } else { + GroupManager.updateGroup(this, groupID, finalGroupMembers, null, groupDisplayName, finalGroupAdmins) + } finish() } } \ No newline at end of file diff --git a/src/org/thoughtcrime/securesms/loki/protocol/ClosedGroupsProtocol.kt b/src/org/thoughtcrime/securesms/loki/protocol/ClosedGroupsProtocol.kt index d43492b48b..3d63c3c26e 100644 --- a/src/org/thoughtcrime/securesms/loki/protocol/ClosedGroupsProtocol.kt +++ b/src/org/thoughtcrime/securesms/loki/protocol/ClosedGroupsProtocol.kt @@ -1,6 +1,7 @@ package org.thoughtcrime.securesms.loki.protocol import android.content.Context +import android.graphics.Bitmap import android.util.Log import com.google.protobuf.ByteString import org.thoughtcrime.securesms.ApplicationContext @@ -182,6 +183,17 @@ object ClosedGroupsProtocol { insertOutgoingInfoMessage(context, groupID, GroupContext.Type.QUIT, name, members, admins, threadID) } + //TODO AC: This is a reflection of GroupManager's update API. + // It needs a valid implementation and probably the signature should be refactored a bit. + public fun updateGroup(context: Context, + groupPublicKey: String, + members: Collection, + avatar: Bitmap?, + name: String, + admins: Collection) { + // STUB + } + @JvmStatic public fun requestSenderKey(context: Context, groupPublicKey: String, senderPublicKey: String) { // Establish session if needed