mirror of
https://github.com/oxen-io/session-android.git
synced 2025-12-30 07:08:19 +00:00
Improve GV2 Invitation revoke experience.
This commit is contained in:
committed by
Greyson Parrelli
parent
c8ed0b19f0
commit
810ccf8e94
@@ -297,7 +297,13 @@ final class GroupsV2UpdateMessageProducer {
|
||||
boolean newMemberIsYou = invitee.getUuid().equals(selfUuidBytes);
|
||||
|
||||
if (newMemberIsYou) {
|
||||
updates.add(updateDescription(context.getString(R.string.MessageRecord_you_were_invited_to_the_group)));
|
||||
UUID uuid = UuidUtil.fromByteStringOrUnknown(invitee.getAddedByUuid());
|
||||
|
||||
if (UuidUtil.UNKNOWN_UUID.equals(uuid)) {
|
||||
updates.add(updateDescription(context.getString(R.string.MessageRecord_you_were_invited_to_the_group)));
|
||||
} else {
|
||||
updates.add(updateDescription(invitee.getAddedByUuid(), editor -> context.getString(R.string.MessageRecord_s_invited_you_to_the_group, editor)));
|
||||
}
|
||||
} else {
|
||||
notYouInviteCount++;
|
||||
}
|
||||
@@ -320,6 +326,8 @@ final class GroupsV2UpdateMessageProducer {
|
||||
} else {
|
||||
updates.add(updateDescription(context.getString(R.string.MessageRecord_someone_declined_an_invitation_to_the_group)));
|
||||
}
|
||||
} else if (invitee.getUuid().equals(selfUuidBytes)) {
|
||||
updates.add(updateDescription(change.getEditor(), editor -> context.getString(R.string.MessageRecord_s_revoked_your_invitation_to_the_group, editor)));
|
||||
} else {
|
||||
notDeclineCount++;
|
||||
}
|
||||
@@ -342,7 +350,7 @@ final class GroupsV2UpdateMessageProducer {
|
||||
boolean inviteeWasYou = invitee.getUuid().equals(selfUuidBytes);
|
||||
|
||||
if (inviteeWasYou) {
|
||||
updates.add(updateDescription(context.getString(R.string.MessageRecord_your_invitation_to_the_group_was_revoked)));
|
||||
updates.add(updateDescription(context.getString(R.string.MessageRecord_an_admin_revoked_your_invitation_to_the_group)));
|
||||
} else {
|
||||
notDeclineCount++;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.thoughtcrime.securesms.messagerequests;
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.WorkerThread;
|
||||
import androidx.core.util.Consumer;
|
||||
|
||||
import org.signal.storageservice.protos.groups.local.DecryptedGroup;
|
||||
@@ -67,15 +68,29 @@ final class MessageRequestRepository {
|
||||
}
|
||||
|
||||
void getMessageRequestState(@NonNull Recipient recipient, long threadId, @NonNull Consumer<MessageRequestState> state) {
|
||||
executor.execute(() -> {
|
||||
if (!RecipientUtil.isMessageRequestAccepted(context, threadId)) {
|
||||
state.accept(MessageRequestState.UNACCEPTED);
|
||||
} else if (RecipientUtil.isPreMessageRequestThread(context, threadId) && !RecipientUtil.isLegacyProfileSharingAccepted(recipient)) {
|
||||
state.accept(MessageRequestState.LEGACY);
|
||||
} else {
|
||||
state.accept(MessageRequestState.ACCEPTED);
|
||||
executor.execute(() -> state.accept(findMessageRequestState(recipient, threadId)));
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
private MessageRequestState findMessageRequestState(@NonNull Recipient recipient, long threadId) {
|
||||
if (!RecipientUtil.isMessageRequestAccepted(context, threadId)) {
|
||||
if (recipient.isGroup()) {
|
||||
GroupDatabase.MemberLevel memberLevel = DatabaseFactory.getGroupDatabase(context)
|
||||
.getGroup(recipient.getId())
|
||||
.transform(g -> g.memberLevel(Recipient.self()))
|
||||
.or(GroupDatabase.MemberLevel.NOT_A_MEMBER);
|
||||
|
||||
if (memberLevel == GroupDatabase.MemberLevel.NOT_A_MEMBER) {
|
||||
return MessageRequestState.NOT_REQUIRED;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return MessageRequestState.REQUIRED;
|
||||
} else if (RecipientUtil.isPreMessageRequestThread(context, threadId) && !RecipientUtil.isLegacyProfileSharingAccepted(recipient)) {
|
||||
return MessageRequestState.LEGACY;
|
||||
} else {
|
||||
return MessageRequestState.NOT_REQUIRED;
|
||||
}
|
||||
}
|
||||
|
||||
void acceptMessageRequest(@NonNull LiveRecipient liveRecipient,
|
||||
@@ -218,6 +233,19 @@ final class MessageRequestRepository {
|
||||
}
|
||||
|
||||
enum MessageRequestState {
|
||||
ACCEPTED, UNACCEPTED, LEGACY
|
||||
/**
|
||||
* Message request permission does not need to be gained at this time.
|
||||
* <p>
|
||||
* Either:
|
||||
* - Explicit message request has been accepted, or;
|
||||
* - Did not need to be shown because they are a contact etc, or;
|
||||
* - It's a group that they are no longer in or invited to.
|
||||
*/
|
||||
NOT_REQUIRED,
|
||||
|
||||
/** Explicit message request permission is required. */
|
||||
REQUIRED,
|
||||
|
||||
LEGACY
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,10 +161,10 @@ public class MessageRequestViewModel extends ViewModel {
|
||||
|
||||
repository.getMessageRequestState(recipient, threadId, accepted -> {
|
||||
switch (accepted) {
|
||||
case ACCEPTED:
|
||||
case NOT_REQUIRED:
|
||||
displayState.postValue(DisplayState.DISPLAY_NONE);
|
||||
break;
|
||||
case UNACCEPTED:
|
||||
case REQUIRED:
|
||||
displayState.postValue(DisplayState.DISPLAY_MESSAGE_REQUEST);
|
||||
break;
|
||||
case LEGACY:
|
||||
|
||||
@@ -168,6 +168,7 @@ public final class MessageGroupContext {
|
||||
memberUuids.addAll(DecryptedGroupUtil.membersToUuidList(decryptedGroupV2Context.getGroupState().getMembersList()));
|
||||
memberUuids.addAll(DecryptedGroupUtil.pendingToUuidList(decryptedGroupV2Context.getGroupState().getPendingMembersList()));
|
||||
memberUuids.addAll(DecryptedGroupUtil.removedMembersUuidList(decryptedGroupV2Context.getChange()));
|
||||
memberUuids.addAll(DecryptedGroupUtil.removedPendingMembersUuidList(decryptedGroupV2Context.getChange()));
|
||||
|
||||
return UuidUtil.filterKnown(memberUuids);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user