Show a message request for certain GV2 adds.
This commit is contained in:
parent
6f53fdc02d
commit
9b61e1c85c
5 changed files with 43 additions and 18 deletions
|
@ -33,6 +33,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import net.sqlcipher.database.SQLiteDatabase;
|
import net.sqlcipher.database.SQLiteDatabase;
|
||||||
|
|
||||||
import org.signal.storageservice.protos.groups.local.DecryptedGroup;
|
import org.signal.storageservice.protos.groups.local.DecryptedGroup;
|
||||||
|
import org.signal.storageservice.protos.groups.local.DecryptedMember;
|
||||||
import org.thoughtcrime.securesms.database.MessagingDatabase.MarkedMessageInfo;
|
import org.thoughtcrime.securesms.database.MessagingDatabase.MarkedMessageInfo;
|
||||||
import org.thoughtcrime.securesms.database.RecipientDatabase.RecipientSettings;
|
import org.thoughtcrime.securesms.database.RecipientDatabase.RecipientSettings;
|
||||||
import org.thoughtcrime.securesms.database.helpers.SQLCipherOpenHelper;
|
import org.thoughtcrime.securesms.database.helpers.SQLCipherOpenHelper;
|
||||||
|
@ -55,6 +56,7 @@ import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||||
import org.thoughtcrime.securesms.util.Util;
|
import org.thoughtcrime.securesms.util.Util;
|
||||||
import org.whispersystems.libsignal.util.guava.Optional;
|
import org.whispersystems.libsignal.util.guava.Optional;
|
||||||
import org.whispersystems.signalservice.api.groupsv2.DecryptedGroupUtil;
|
import org.whispersystems.signalservice.api.groupsv2.DecryptedGroupUtil;
|
||||||
|
import org.whispersystems.signalservice.api.util.UuidUtil;
|
||||||
|
|
||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -964,9 +966,16 @@ public class ThreadDatabase extends Database {
|
||||||
DecryptedGroup decryptedGroup = DatabaseFactory.getGroupDatabase(context).requireGroup(resolved.requireGroupId().requireV2()).requireV2GroupProperties().getDecryptedGroup();
|
DecryptedGroup decryptedGroup = DatabaseFactory.getGroupDatabase(context).requireGroup(resolved.requireGroupId().requireV2()).requireV2GroupProperties().getDecryptedGroup();
|
||||||
Optional<UUID> inviter = DecryptedGroupUtil.findInviter(decryptedGroup.getPendingMembersList(), Recipient.self().getUuid().get());
|
Optional<UUID> inviter = DecryptedGroupUtil.findInviter(decryptedGroup.getPendingMembersList(), Recipient.self().getUuid().get());
|
||||||
|
|
||||||
RecipientId recipientId = inviter.isPresent() ? RecipientId.from(inviter.get(), null) : RecipientId.UNKNOWN;
|
if (inviter.isPresent()) {
|
||||||
|
RecipientId recipientId = RecipientId.from(inviter.get(), null);
|
||||||
|
return Extra.forGroupV2invite(recipientId);
|
||||||
|
} else if (decryptedGroup.getRevision() == 0) {
|
||||||
|
Optional<DecryptedMember> foundingMember = DecryptedGroupUtil.firstMember(decryptedGroup.getMembersList());
|
||||||
|
|
||||||
return Extra.forGroupV2invite(recipientId);
|
if (foundingMember.isPresent()) {
|
||||||
|
return Extra.forGroupMessageRequest(RecipientId.from(UuidUtil.fromByteString(foundingMember.get().getUuid()), null));
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
RecipientId recipientId = DatabaseFactory.getMmsSmsDatabase(context).getGroupAddedBy(record.getThreadId());
|
RecipientId recipientId = DatabaseFactory.getMmsSmsDatabase(context).getGroupAddedBy(record.getThreadId());
|
||||||
|
|
||||||
|
|
|
@ -7,12 +7,17 @@ import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.annotation.WorkerThread;
|
import androidx.annotation.WorkerThread;
|
||||||
|
|
||||||
|
import com.google.protobuf.ByteString;
|
||||||
|
|
||||||
import org.signal.storageservice.protos.groups.local.DecryptedGroup;
|
import org.signal.storageservice.protos.groups.local.DecryptedGroup;
|
||||||
import org.signal.storageservice.protos.groups.local.DecryptedGroupChange;
|
import org.signal.storageservice.protos.groups.local.DecryptedGroupChange;
|
||||||
|
import org.signal.storageservice.protos.groups.local.DecryptedMember;
|
||||||
import org.signal.storageservice.protos.groups.local.DecryptedPendingMember;
|
import org.signal.storageservice.protos.groups.local.DecryptedPendingMember;
|
||||||
import org.signal.zkgroup.VerificationFailedException;
|
import org.signal.zkgroup.VerificationFailedException;
|
||||||
import org.signal.zkgroup.groups.GroupMasterKey;
|
import org.signal.zkgroup.groups.GroupMasterKey;
|
||||||
import org.signal.zkgroup.groups.GroupSecretParams;
|
import org.signal.zkgroup.groups.GroupSecretParams;
|
||||||
|
import org.signal.zkgroup.util.UUIDUtil;
|
||||||
|
import org.thoughtcrime.securesms.R;
|
||||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||||
import org.thoughtcrime.securesms.database.GroupDatabase;
|
import org.thoughtcrime.securesms.database.GroupDatabase;
|
||||||
import org.thoughtcrime.securesms.database.MmsDatabase;
|
import org.thoughtcrime.securesms.database.MmsDatabase;
|
||||||
|
@ -152,8 +157,8 @@ public final class GroupsV2StateProcessor {
|
||||||
.transform(g -> g.requireV2GroupProperties().getDecryptedGroup())
|
.transform(g -> g.requireV2GroupProperties().getDecryptedGroup())
|
||||||
.orNull();
|
.orNull();
|
||||||
|
|
||||||
if (signedGroupChange != null &&
|
if (signedGroupChange != null &&
|
||||||
localState != null &&
|
localState != null &&
|
||||||
localState.getRevision() + 1 == signedGroupChange.getRevision() &&
|
localState.getRevision() + 1 == signedGroupChange.getRevision() &&
|
||||||
revision == signedGroupChange.getRevision())
|
revision == signedGroupChange.getRevision())
|
||||||
{
|
{
|
||||||
|
@ -274,9 +279,30 @@ public final class GroupsV2StateProcessor {
|
||||||
jobManager.add(new AvatarGroupsV2DownloadJob(groupId, newLocalState.getAvatar()));
|
jobManager.add(new AvatarGroupsV2DownloadJob(groupId, newLocalState.getAvatar()));
|
||||||
}
|
}
|
||||||
|
|
||||||
final boolean fullMemberPostUpdate = GroupProtoUtil.isMember(Recipient.self().getUuid().get(), newLocalState.getMembersList());
|
boolean fullMemberPostUpdate = GroupProtoUtil.isMember(Recipient.self().getUuid().get(), newLocalState.getMembersList());
|
||||||
if (fullMemberPostUpdate) {
|
boolean trustedAdder = false;
|
||||||
|
|
||||||
|
if (newLocalState.getRevision() == 0) {
|
||||||
|
Optional<DecryptedMember> foundingMember = DecryptedGroupUtil.firstMember(newLocalState.getMembersList());
|
||||||
|
|
||||||
|
if (foundingMember.isPresent()) {
|
||||||
|
UUID foundingMemberUuid = UuidUtil.fromByteString(foundingMember.get().getUuid());
|
||||||
|
Recipient foundingRecipient = Recipient.externalPush(context, foundingMemberUuid, null, false);
|
||||||
|
|
||||||
|
if (foundingRecipient.isSystemContact() || foundingRecipient.isProfileSharing()) {
|
||||||
|
Log.i(TAG, "Group 'adder' is trusted. contact: " + foundingRecipient.isSystemContact() + ", profileSharing: " + foundingRecipient.isProfileSharing());
|
||||||
|
trustedAdder = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Log.i(TAG, "Could not find founding member during gv2 create. Not enabling profile sharing.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fullMemberPostUpdate && trustedAdder) {
|
||||||
|
Log.i(TAG, "Added to a group and auto-enabling profile sharing");
|
||||||
recipientDatabase.setProfileSharing(Recipient.externalGroup(context, groupId).getId(), true);
|
recipientDatabase.setProfileSharing(Recipient.externalGroup(context, groupId).getId(), true);
|
||||||
|
} else {
|
||||||
|
Log.i(TAG, "Added to a group, but not enabling profile sharing. fullMember: " + fullMemberPostUpdate + ", trustedAdded: " + trustedAdder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,12 +68,7 @@ final class MessageRequestRepository {
|
||||||
|
|
||||||
void getMessageRequestState(@NonNull Recipient recipient, long threadId, @NonNull Consumer<MessageRequestState> state) {
|
void getMessageRequestState(@NonNull Recipient recipient, long threadId, @NonNull Consumer<MessageRequestState> state) {
|
||||||
executor.execute(() -> {
|
executor.execute(() -> {
|
||||||
if (recipient.isPushV2Group()) {
|
if (!RecipientUtil.isMessageRequestAccepted(context, threadId)) {
|
||||||
boolean pendingMember = DatabaseFactory.getGroupDatabase(context)
|
|
||||||
.isPendingMember(recipient.requireGroupId().requireV2(), Recipient.self());
|
|
||||||
state.accept(pendingMember ? MessageRequestState.UNACCEPTED
|
|
||||||
: MessageRequestState.ACCEPTED);
|
|
||||||
} else if (!RecipientUtil.isMessageRequestAccepted(context, threadId)) {
|
|
||||||
state.accept(MessageRequestState.UNACCEPTED);
|
state.accept(MessageRequestState.UNACCEPTED);
|
||||||
} else if (RecipientUtil.isPreMessageRequestThread(context, threadId) && !RecipientUtil.isLegacyProfileSharingAccepted(recipient)) {
|
} else if (RecipientUtil.isPreMessageRequestThread(context, threadId) && !RecipientUtil.isLegacyProfileSharingAccepted(recipient)) {
|
||||||
state.accept(MessageRequestState.LEGACY);
|
state.accept(MessageRequestState.LEGACY);
|
||||||
|
|
|
@ -71,11 +71,7 @@ public class MessageRequestsBottomView extends ConstraintLayout {
|
||||||
setActiveInactiveGroups(blockedButtons, normalButtons);
|
setActiveInactiveGroups(blockedButtons, normalButtons);
|
||||||
} else {
|
} else {
|
||||||
if (recipient.isGroup()) {
|
if (recipient.isGroup()) {
|
||||||
if (recipient.isPushV2Group()) {
|
question.setText(R.string.MessageRequestBottomView_do_you_want_to_join_this_group_they_wont_know_youve_seen_their_messages_until_you_accept);
|
||||||
question.setText(HtmlCompat.fromHtml(getContext().getString(R.string.MessageRequestBottomView_you_were_invited_to_join_the_group_s, HtmlUtil.bold(recipient.getDisplayName(getContext()))), 0));
|
|
||||||
} else {
|
|
||||||
question.setText(R.string.MessageRequestBottomView_do_you_want_to_join_this_group_they_wont_know_youve_seen_their_messages_until_you_accept);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
String name = recipient.getShortDisplayName(getContext());
|
String name = recipient.getShortDisplayName(getContext());
|
||||||
question.setText(HtmlCompat.fromHtml(getContext().getString(R.string.MessageRequestBottomView_do_you_want_to_let_s_message_you_they_wont_know_youve_seen_their_messages_until_you_accept, HtmlUtil.bold(name)), 0));
|
question.setText(HtmlCompat.fromHtml(getContext().getString(R.string.MessageRequestBottomView_do_you_want_to_let_s_message_you_they_wont_know_youve_seen_their_messages_until_you_accept, HtmlUtil.bold(name)), 0));
|
||||||
|
|
|
@ -895,7 +895,6 @@
|
||||||
<string name="MessageRequestBottomView_do_you_want_to_let_s_message_you_they_wont_know_youve_seen_their_messages_until_you_accept">Let %1$s message you and share your name and photo with them? They won\'t know you\'ve seen their message until you accept.</string>
|
<string name="MessageRequestBottomView_do_you_want_to_let_s_message_you_they_wont_know_youve_seen_their_messages_until_you_accept">Let %1$s message you and share your name and photo with them? They won\'t know you\'ve seen their message until you accept.</string>
|
||||||
<string name="MessageRequestBottomView_do_you_want_to_let_s_message_you_wont_receive_any_messages_until_you_unblock_them">Let %1$s message you and share your name and photo with them? You won\'t receive any messages until you unblock them.</string>
|
<string name="MessageRequestBottomView_do_you_want_to_let_s_message_you_wont_receive_any_messages_until_you_unblock_them">Let %1$s message you and share your name and photo with them? You won\'t receive any messages until you unblock them.</string>
|
||||||
<string name="MessageRequestBottomView_do_you_want_to_join_this_group_they_wont_know_youve_seen_their_messages_until_you_accept">Join this group and share your name and photo with its members? They won\'t know you\'ve seen their messages until you accept.</string>
|
<string name="MessageRequestBottomView_do_you_want_to_join_this_group_they_wont_know_youve_seen_their_messages_until_you_accept">Join this group and share your name and photo with its members? They won\'t know you\'ve seen their messages until you accept.</string>
|
||||||
<string name="MessageRequestBottomView_you_were_invited_to_join_the_group_s">You were invited to join the group %1$s. Do you want to let members of this group message you?</string>
|
|
||||||
<string name="MessageRequestBottomView_unblock_this_group_and_share_your_name_and_photo_with_its_members">Unblock this group and share your name and photo with its members? You won\'t receive any messages until you unblock them.</string>
|
<string name="MessageRequestBottomView_unblock_this_group_and_share_your_name_and_photo_with_its_members">Unblock this group and share your name and photo with its members? You won\'t receive any messages until you unblock them.</string>
|
||||||
<string name="MessageRequestProfileView_member_of_one_group">Member of %1$s</string>
|
<string name="MessageRequestProfileView_member_of_one_group">Member of %1$s</string>
|
||||||
<string name="MessageRequestProfileView_member_of_two_groups">Member of %1$s and %2$s</string>
|
<string name="MessageRequestProfileView_member_of_two_groups">Member of %1$s and %2$s</string>
|
||||||
|
|
Loading…
Add table
Reference in a new issue