From 65b36c006ccbc62471f3ea97a93a005195dddc26 Mon Sep 17 00:00:00 2001 From: jubb Date: Mon, 22 Feb 2021 13:48:48 +1100 Subject: [PATCH] feat: add notifyUser flag to explicitLeave --- .../securesms/loki/activities/HomeActivity.kt | 2 +- .../securesms/loki/protocol/ClosedGroupsProtocolV2.kt | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/HomeActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/loki/activities/HomeActivity.kt index 88c5eea00..2b88ac196 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/HomeActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/loki/activities/HomeActivity.kt @@ -358,7 +358,7 @@ class HomeActivity : PassphraseRequiredActionBarActivity, ConversationClickListe isSSKBasedClosedGroup = false } if (isSSKBasedClosedGroup) { - ClosedGroupsProtocolV2.explicitLeave(context, groupPublicKey!!) + ClosedGroupsProtocolV2.explicitLeave(context, groupPublicKey!!, notifyUser = false) } else if (!ClosedGroupsProtocol.leaveLegacyGroup(context, recipient)) { Toast.makeText(context, R.string.activity_home_leaving_group_failed_message, Toast.LENGTH_LONG).show() return@launch diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/protocol/ClosedGroupsProtocolV2.kt b/app/src/main/java/org/thoughtcrime/securesms/loki/protocol/ClosedGroupsProtocolV2.kt index 72103a3df..b76a51a9f 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/protocol/ClosedGroupsProtocolV2.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/loki/protocol/ClosedGroupsProtocolV2.kt @@ -94,8 +94,8 @@ object ClosedGroupsProtocolV2 { return deferred.promise } - @JvmStatic - fun explicitLeave(context: Context, groupPublicKey: String): Promise { + @JvmStatic @JvmOverloads + fun explicitLeave(context: Context, groupPublicKey: String, notifyUser: Boolean = true): Promise { val deferred = deferred() ThreadUtils.queue { val userPublicKey = TextSecurePreferences.getLocalNumber(context)!! @@ -119,7 +119,9 @@ object ClosedGroupsProtocolV2 { // Notify the user val infoType = GroupContext.Type.QUIT val threadID = DatabaseFactory.getThreadDatabase(context).getOrCreateThreadIdFor(Recipient.from(context, Address.fromSerialized(groupID), false)) - insertOutgoingInfoMessage(context, groupID, infoType, name, updatedMembers, admins, threadID, sentTime) + if (notifyUser) { + insertOutgoingInfoMessage(context, groupID, infoType, name, updatedMembers, admins, threadID, sentTime) + } // Remove the group private key and unsubscribe from PNs disableLocalGroupAndUnsubscribe(context, apiDB, groupPublicKey, groupDB, groupID, userPublicKey) deferred.resolve(Unit)