Add block request action button to collapsed join request events.

This commit is contained in:
Cody Henthorne
2022-03-15 20:41:48 -04:00
parent 130d5a8945
commit d3049a3433
11 changed files with 188 additions and 5 deletions

View File

@@ -1207,7 +1207,7 @@ final class GroupManagerV2 {
DecryptedGroupChange plainGroupChange = groupMutation.getGroupChange();
if (plainGroupChange != null && DecryptedGroupUtil.changeIsEmptyExceptForProfileKeyChanges(plainGroupChange)) {
if (plainGroupChange != null && DecryptedGroupUtil.changeIsSilent(plainGroupChange)) {
if (sendToMembers) {
ApplicationDependencies.getJobManager().add(PushGroupSilentUpdateSendJob.create(context, groupId, groupMutation.getNewGroupState(), outgoingMessage));
}

View File

@@ -0,0 +1,41 @@
package org.thoughtcrime.securesms.groups.v2
import android.content.Context
import io.reactivex.rxjava3.core.Single
import io.reactivex.rxjava3.schedulers.Schedulers
import org.signal.core.util.logging.Log
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
import org.thoughtcrime.securesms.groups.GroupChangeException
import org.thoughtcrime.securesms.groups.GroupId
import org.thoughtcrime.securesms.groups.GroupManager
import org.thoughtcrime.securesms.groups.ui.GroupChangeFailureReason
import org.thoughtcrime.securesms.recipients.Recipient
import java.io.IOException
private val TAG: String = Log.tag(GroupManagementRepository::class.java)
/**
* Single source repository for managing groups.
*/
class GroupManagementRepository @JvmOverloads constructor(private val context: Context = ApplicationDependencies.getApplication()) {
fun blockJoinRequests(groupId: GroupId.V2, recipient: Recipient): Single<GroupManagementResult> {
return Single.fromCallable {
try {
GroupManager.ban(context, groupId, recipient.id)
GroupManagementResult.Success
} catch (e: GroupChangeException) {
Log.w(TAG, e)
GroupManagementResult.Failure(GroupChangeFailureReason.fromException(e))
} catch (e: IOException) {
Log.w(TAG, e)
GroupManagementResult.Failure(GroupChangeFailureReason.fromException(e))
}
}.subscribeOn(Schedulers.io())
}
sealed class GroupManagementResult {
object Success : GroupManagementResult()
data class Failure(val reason: GroupChangeFailureReason) : GroupManagementResult()
}
}

View File

@@ -612,6 +612,8 @@ public class GroupsV2StateProcessor {
for (LocalGroupLogEntry entry : processedLogEntries) {
if (entry.getChange() != null && DecryptedGroupUtil.changeIsEmptyExceptForProfileKeyChanges(entry.getChange()) && !DecryptedGroupUtil.changeIsEmpty(entry.getChange())) {
Log.d(TAG, "Skipping profile key changes only update message");
} if (entry.getChange() != null && DecryptedGroupUtil.changeIsEmptyExceptForBanChangesAndOptionalProfileKeyChanges(entry.getChange())) {
Log.d(TAG, "Skipping ban changes only update message");
} else {
if (entry.getChange() != null && DecryptedGroupUtil.changeIsEmpty(entry.getChange()) && previousGroupState != null) {
Log.w(TAG, "Empty group update message seen. Not inserting.");