mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 17:29:32 +01:00
Renamed database classes to table classes.
Because they're not databases. They're tables.
This commit is contained in:
committed by
Cody Henthorne
parent
b190f9495a
commit
7949996c5c
@@ -13,11 +13,10 @@ import org.signal.libsignal.zkgroup.groups.UuidCiphertext;
|
||||
import org.signal.storageservice.protos.groups.GroupExternalCredential;
|
||||
import org.signal.storageservice.protos.groups.local.DecryptedGroup;
|
||||
import org.signal.storageservice.protos.groups.local.DecryptedGroupJoinInfo;
|
||||
import org.thoughtcrime.securesms.database.GroupDatabase;
|
||||
import org.thoughtcrime.securesms.database.GroupTable;
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase;
|
||||
import org.thoughtcrime.securesms.groups.v2.GroupInviteLinkUrl;
|
||||
import org.thoughtcrime.securesms.groups.v2.GroupLinkPassword;
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
||||
import org.thoughtcrime.securesms.profiles.AvatarHelper;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId;
|
||||
@@ -85,7 +84,7 @@ public final class GroupManager {
|
||||
}
|
||||
} else if (groupId.isV1()) {
|
||||
List<Recipient> members = SignalDatabase.groups()
|
||||
.getGroupMembers(groupId, GroupDatabase.MemberSet.FULL_MEMBERS_EXCLUDING_SELF);
|
||||
.getGroupMembers(groupId, GroupTable.MemberSet.FULL_MEMBERS_EXCLUDING_SELF);
|
||||
|
||||
Set<RecipientId> recipientIds = getMemberIds(new HashSet<>(members));
|
||||
|
||||
@@ -296,8 +295,8 @@ public final class GroupManager {
|
||||
@NonNull RecipientId recipientId)
|
||||
throws GroupChangeBusyException, IOException, GroupChangeFailedException, GroupNotAMemberException, GroupInsufficientRightsException
|
||||
{
|
||||
GroupDatabase.V2GroupProperties groupProperties = SignalDatabase.groups().requireGroup(groupId).requireV2GroupProperties();
|
||||
Recipient recipient = Recipient.resolved(recipientId);
|
||||
GroupTable.V2GroupProperties groupProperties = SignalDatabase.groups().requireGroup(groupId).requireV2GroupProperties();
|
||||
Recipient recipient = Recipient.resolved(recipientId);
|
||||
|
||||
if (groupProperties.getBannedMembers().contains(recipient.requireServiceId().uuid())) {
|
||||
Log.i(TAG, "Attempt to ban already banned recipient: " + recipientId);
|
||||
@@ -403,14 +402,14 @@ public final class GroupManager {
|
||||
throws GroupChangeFailedException, GroupInsufficientRightsException, IOException, GroupNotAMemberException, GroupChangeBusyException, MembershipNotSuitableForV2Exception
|
||||
{
|
||||
if (groupId.isV2()) {
|
||||
GroupDatabase.GroupRecord groupRecord = SignalDatabase.groups().requireGroup(groupId);
|
||||
GroupTable.GroupRecord groupRecord = SignalDatabase.groups().requireGroup(groupId);
|
||||
|
||||
try (GroupManagerV2.GroupEditor editor = new GroupManagerV2(context).edit(groupId.requireV2())) {
|
||||
return editor.addMembers(newMembers, groupRecord.requireV2GroupProperties().getBannedMembers());
|
||||
}
|
||||
} else {
|
||||
GroupDatabase.GroupRecord groupRecord = SignalDatabase.groups().requireGroup(groupId);
|
||||
List<RecipientId> members = groupRecord.getMembers();
|
||||
GroupTable.GroupRecord groupRecord = SignalDatabase.groups().requireGroup(groupId);
|
||||
List<RecipientId> members = groupRecord.getMembers();
|
||||
byte[] avatar = groupRecord.hasAvatar() ? AvatarHelper.getAvatarBytes(context, groupRecord.getRecipientId()) : null;
|
||||
Set<RecipientId> recipientIds = new HashSet<>(members);
|
||||
int originalSize = recipientIds.size();
|
||||
|
||||
@@ -12,11 +12,11 @@ import com.google.protobuf.ByteString;
|
||||
import org.signal.core.util.logging.Log;
|
||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
||||
import org.thoughtcrime.securesms.attachments.UriAttachment;
|
||||
import org.thoughtcrime.securesms.database.AttachmentDatabase;
|
||||
import org.thoughtcrime.securesms.database.GroupDatabase;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase;
|
||||
import org.thoughtcrime.securesms.database.AttachmentTable;
|
||||
import org.thoughtcrime.securesms.database.GroupTable;
|
||||
import org.thoughtcrime.securesms.database.RecipientTable;
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase;
|
||||
import org.thoughtcrime.securesms.database.ThreadDatabase;
|
||||
import org.thoughtcrime.securesms.database.ThreadTable;
|
||||
import org.thoughtcrime.securesms.groups.GroupManager.GroupActionResult;
|
||||
import org.thoughtcrime.securesms.mms.OutgoingExpirationUpdateMessage;
|
||||
import org.thoughtcrime.securesms.mms.OutgoingGroupUpdateMessage;
|
||||
@@ -25,7 +25,6 @@ import org.thoughtcrime.securesms.providers.BlobProvider;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId;
|
||||
import org.thoughtcrime.securesms.sms.MessageSender;
|
||||
import org.thoughtcrime.securesms.util.GroupUtil;
|
||||
import org.thoughtcrime.securesms.util.MediaUtil;
|
||||
import org.whispersystems.signalservice.internal.push.SignalServiceProtos.GroupContext;
|
||||
|
||||
@@ -49,8 +48,8 @@ final class GroupManagerV1 {
|
||||
@Nullable String name,
|
||||
boolean mms)
|
||||
{
|
||||
final GroupDatabase groupDatabase = SignalDatabase.groups();
|
||||
final SecureRandom secureRandom = new SecureRandom();
|
||||
final GroupTable groupDatabase = SignalDatabase.groups();
|
||||
final SecureRandom secureRandom = new SecureRandom();
|
||||
final GroupId groupId = mms ? GroupId.createMms(secureRandom) : GroupId.createV1(secureRandom);
|
||||
final RecipientId groupRecipientId = SignalDatabase.recipients().getOrInsertFromGroupId(groupId);
|
||||
final Recipient groupRecipient = Recipient.resolved(groupRecipientId);
|
||||
@@ -80,7 +79,7 @@ final class GroupManagerV1 {
|
||||
}
|
||||
groupDatabase.onAvatarUpdated(groupId, avatarBytes != null);
|
||||
|
||||
long threadId = SignalDatabase.threads().getOrCreateThreadIdFor(groupRecipient, ThreadDatabase.DistributionTypes.CONVERSATION);
|
||||
long threadId = SignalDatabase.threads().getOrCreateThreadIdFor(groupRecipient, ThreadTable.DistributionTypes.CONVERSATION);
|
||||
return new GroupActionResult(groupRecipient, threadId, memberIds.size() - 1, Collections.emptyList());
|
||||
}
|
||||
}
|
||||
@@ -92,8 +91,8 @@ final class GroupManagerV1 {
|
||||
@Nullable String name,
|
||||
int newMemberCount)
|
||||
{
|
||||
final GroupDatabase groupDatabase = SignalDatabase.groups();
|
||||
final RecipientId groupRecipientId = SignalDatabase.recipients().getOrInsertFromGroupId(groupId);
|
||||
final GroupTable groupDatabase = SignalDatabase.groups();
|
||||
final RecipientId groupRecipientId = SignalDatabase.recipients().getOrInsertFromGroupId(groupId);
|
||||
|
||||
memberAddresses.add(Recipient.self().getId());
|
||||
groupDatabase.updateMembers(groupId, new LinkedList<>(memberAddresses));
|
||||
@@ -122,8 +121,8 @@ final class GroupManagerV1 {
|
||||
@Nullable byte[] avatarBytes,
|
||||
@Nullable String name)
|
||||
{
|
||||
GroupDatabase groupDatabase = SignalDatabase.groups();
|
||||
RecipientId groupRecipientId = SignalDatabase.recipients().getOrInsertFromGroupId(groupId);
|
||||
GroupTable groupDatabase = SignalDatabase.groups();
|
||||
RecipientId groupRecipientId = SignalDatabase.recipients().getOrInsertFromGroupId(groupId);
|
||||
Recipient groupRecipient = Recipient.resolved(groupRecipientId);
|
||||
long threadId = SignalDatabase.threads().getOrCreateThreadIdFor(groupRecipient);
|
||||
|
||||
@@ -172,7 +171,7 @@ final class GroupManagerV1 {
|
||||
|
||||
if (avatar != null) {
|
||||
Uri avatarUri = BlobProvider.getInstance().forData(avatar).createForSingleUseInMemory();
|
||||
avatarAttachment = new UriAttachment(avatarUri, MediaUtil.IMAGE_PNG, AttachmentDatabase.TRANSFER_PROGRESS_DONE, avatar.length, null, false, false, false, false, null, null, null, null, null);
|
||||
avatarAttachment = new UriAttachment(avatarUri, MediaUtil.IMAGE_PNG, AttachmentTable.TRANSFER_PROGRESS_DONE, avatar.length, null, false, false, false, false, null, null, null, null, null);
|
||||
}
|
||||
|
||||
OutgoingGroupUpdateMessage outgoingMessage = new OutgoingGroupUpdateMessage(groupRecipient, groupContext, avatarAttachment, System.currentTimeMillis(), 0, false, null, Collections.emptyList(), Collections.emptyList(), Collections.emptyList());
|
||||
@@ -193,12 +192,12 @@ final class GroupManagerV1 {
|
||||
|
||||
@WorkerThread
|
||||
static void updateGroupTimer(@NonNull Context context, @NonNull GroupId.V1 groupId, int expirationTime) {
|
||||
RecipientDatabase recipientDatabase = SignalDatabase.recipients();
|
||||
ThreadDatabase threadDatabase = SignalDatabase.threads();
|
||||
Recipient recipient = Recipient.externalGroupExact(groupId);
|
||||
long threadId = threadDatabase.getOrCreateThreadIdFor(recipient);
|
||||
RecipientTable recipientTable = SignalDatabase.recipients();
|
||||
ThreadTable threadTable = SignalDatabase.threads();
|
||||
Recipient recipient = Recipient.externalGroupExact(groupId);
|
||||
long threadId = threadTable.getOrCreateThreadIdFor(recipient);
|
||||
|
||||
recipientDatabase.setExpireMessages(recipient.getId(), expirationTime);
|
||||
recipientTable.setExpireMessages(recipient.getId(), expirationTime);
|
||||
OutgoingExpirationUpdateMessage outgoingMessage = new OutgoingExpirationUpdateMessage(recipient, System.currentTimeMillis(), expirationTime * 1000L);
|
||||
MessageSender.send(context, outgoingMessage, threadId, false, null, null);
|
||||
}
|
||||
@@ -208,7 +207,7 @@ final class GroupManagerV1 {
|
||||
@NonNull GroupId.V1 groupId,
|
||||
@NonNull Recipient groupRecipient)
|
||||
{
|
||||
GroupDatabase groupDatabase = SignalDatabase.groups();
|
||||
GroupTable groupDatabase = SignalDatabase.groups();
|
||||
|
||||
if (!groupDatabase.isActive(groupId)) {
|
||||
Log.w(TAG, "Group has already been left.");
|
||||
|
||||
@@ -32,9 +32,9 @@ import org.signal.storageservice.protos.groups.local.DecryptedMember;
|
||||
import org.signal.storageservice.protos.groups.local.DecryptedPendingMember;
|
||||
import org.signal.storageservice.protos.groups.local.DecryptedRequestingMember;
|
||||
import org.thoughtcrime.securesms.crypto.ProfileKeyUtil;
|
||||
import org.thoughtcrime.securesms.database.GroupDatabase;
|
||||
import org.thoughtcrime.securesms.database.GroupTable;
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase;
|
||||
import org.thoughtcrime.securesms.database.ThreadDatabase;
|
||||
import org.thoughtcrime.securesms.database.ThreadTable;
|
||||
import org.thoughtcrime.securesms.database.model.databaseprotos.DecryptedGroupV2Context;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.groups.v2.GroupCandidateHelper;
|
||||
@@ -94,9 +94,9 @@ final class GroupManagerV2 {
|
||||
|
||||
private static final String TAG = Log.tag(GroupManagerV2.class);
|
||||
|
||||
private final Context context;
|
||||
private final GroupDatabase groupDatabase;
|
||||
private final GroupsV2Api groupsV2Api;
|
||||
private final Context context;
|
||||
private final GroupTable groupDatabase;
|
||||
private final GroupsV2Api groupsV2Api;
|
||||
private final GroupsV2Operations groupsV2Operations;
|
||||
private final GroupsV2Authorization authorization;
|
||||
private final GroupsV2StateProcessor groupsV2StateProcessor;
|
||||
@@ -119,7 +119,7 @@ final class GroupManagerV2 {
|
||||
}
|
||||
|
||||
@VisibleForTesting GroupManagerV2(Context context,
|
||||
GroupDatabase groupDatabase,
|
||||
GroupTable groupDatabase,
|
||||
GroupsV2Api groupsV2Api,
|
||||
GroupsV2Operations groupsV2Operations,
|
||||
GroupsV2Authorization authorization,
|
||||
@@ -167,11 +167,11 @@ final class GroupManagerV2 {
|
||||
|
||||
@WorkerThread
|
||||
@NonNull Map<UUID, UuidCiphertext> getUuidCipherTexts(@NonNull GroupId.V2 groupId) {
|
||||
GroupDatabase.GroupRecord groupRecord = SignalDatabase.groups().requireGroup(groupId);
|
||||
GroupDatabase.V2GroupProperties v2GroupProperties = groupRecord.requireV2GroupProperties();
|
||||
GroupMasterKey groupMasterKey = v2GroupProperties.getGroupMasterKey();
|
||||
ClientZkGroupCipher clientZkGroupCipher = new ClientZkGroupCipher(GroupSecretParams.deriveFromMasterKey(groupMasterKey));
|
||||
List<Recipient> recipients = v2GroupProperties.getMemberRecipients(GroupDatabase.MemberSet.FULL_MEMBERS_INCLUDING_SELF);
|
||||
GroupTable.GroupRecord groupRecord = SignalDatabase.groups().requireGroup(groupId);
|
||||
GroupTable.V2GroupProperties v2GroupProperties = groupRecord.requireV2GroupProperties();
|
||||
GroupMasterKey groupMasterKey = v2GroupProperties.getGroupMasterKey();
|
||||
ClientZkGroupCipher clientZkGroupCipher = new ClientZkGroupCipher(GroupSecretParams.deriveFromMasterKey(groupMasterKey));
|
||||
List<Recipient> recipients = v2GroupProperties.getMemberRecipients(GroupTable.MemberSet.FULL_MEMBERS_INCLUDING_SELF);
|
||||
|
||||
Map<UUID, UuidCiphertext> uuidCipherTexts = new HashMap<>();
|
||||
for (Recipient recipient : recipients) {
|
||||
@@ -251,9 +251,9 @@ final class GroupManagerV2 {
|
||||
throws IOException, MembershipNotSuitableForV2Exception, GroupAlreadyExistsException, GroupChangeFailedException
|
||||
{
|
||||
GroupMasterKey groupMasterKey = groupIdV1.deriveV2MigrationMasterKey();
|
||||
GroupSecretParams groupSecretParams = GroupSecretParams.deriveFromMasterKey(groupMasterKey);
|
||||
GroupDatabase.GroupRecord groupRecord = groupDatabase.requireGroup(groupIdV1);
|
||||
String name = Util.emptyIfNull(groupRecord.getTitle());
|
||||
GroupSecretParams groupSecretParams = GroupSecretParams.deriveFromMasterKey(groupMasterKey);
|
||||
GroupTable.GroupRecord groupRecord = groupDatabase.requireGroup(groupIdV1);
|
||||
String name = Util.emptyIfNull(groupRecord.getTitle());
|
||||
byte[] avatar = groupRecord.hasAvatar() ? AvatarHelper.getAvatarBytes(context, groupRecord.getRecipientId()) : null;
|
||||
int messageTimer = Recipient.resolved(groupRecord.getRecipientId()).getExpiresInSeconds();
|
||||
Set<RecipientId> memberIds = Stream.of(members)
|
||||
@@ -318,16 +318,16 @@ final class GroupManagerV2 {
|
||||
@SuppressWarnings("UnusedReturnValue")
|
||||
final class GroupEditor extends LockOwner {
|
||||
|
||||
private final GroupId.V2 groupId;
|
||||
private final GroupDatabase.V2GroupProperties v2GroupProperties;
|
||||
private final GroupMasterKey groupMasterKey;
|
||||
private final GroupId.V2 groupId;
|
||||
private final GroupTable.V2GroupProperties v2GroupProperties;
|
||||
private final GroupMasterKey groupMasterKey;
|
||||
private final GroupSecretParams groupSecretParams;
|
||||
private final GroupsV2Operations.GroupOperations groupOperations;
|
||||
|
||||
GroupEditor(@NonNull GroupId.V2 groupId, @NonNull Closeable lock) {
|
||||
super(lock);
|
||||
|
||||
GroupDatabase.GroupRecord groupRecord = groupDatabase.requireGroup(groupId);
|
||||
GroupTable.GroupRecord groupRecord = groupDatabase.requireGroup(groupId);
|
||||
|
||||
this.groupId = groupId;
|
||||
this.v2GroupProperties = groupRecord.requireV2GroupProperties();
|
||||
@@ -455,8 +455,8 @@ final class GroupManagerV2 {
|
||||
void leaveGroup()
|
||||
throws GroupChangeFailedException, GroupInsufficientRightsException, IOException, GroupNotAMemberException
|
||||
{
|
||||
GroupDatabase.GroupRecord groupRecord = groupDatabase.requireGroup(groupId);
|
||||
DecryptedGroup decryptedGroup = groupRecord.requireV2GroupProperties().getDecryptedGroup();
|
||||
GroupTable.GroupRecord groupRecord = groupDatabase.requireGroup(groupId);
|
||||
DecryptedGroup decryptedGroup = groupRecord.requireV2GroupProperties().getDecryptedGroup();
|
||||
Optional<DecryptedMember> selfMember = DecryptedGroupUtil.findMemberByUuid(decryptedGroup.getMembersList(), selfAci.uuid());
|
||||
Optional<DecryptedPendingMember> aciPendingMember = DecryptedGroupUtil.findPendingByUuid(decryptedGroup.getPendingMembersList(), selfAci.uuid());
|
||||
Optional<DecryptedPendingMember> pniPendingMember = DecryptedGroupUtil.findPendingByUuid(decryptedGroup.getPendingMembersList(), selfPni.uuid());
|
||||
@@ -617,8 +617,8 @@ final class GroupManagerV2 {
|
||||
commitChangeWithConflictResolution(selfAci, change);
|
||||
|
||||
if (state != GroupManager.GroupLinkState.DISABLED) {
|
||||
GroupDatabase.V2GroupProperties v2GroupProperties = groupDatabase.requireGroup(groupId).requireV2GroupProperties();
|
||||
GroupMasterKey groupMasterKey = v2GroupProperties.getGroupMasterKey();
|
||||
GroupTable.V2GroupProperties v2GroupProperties = groupDatabase.requireGroup(groupId).requireV2GroupProperties();
|
||||
GroupMasterKey groupMasterKey = v2GroupProperties.getGroupMasterKey();
|
||||
DecryptedGroup decryptedGroup = v2GroupProperties.getDecryptedGroup();
|
||||
|
||||
return GroupInviteLinkUrl.forGroup(groupMasterKey, decryptedGroup);
|
||||
@@ -728,9 +728,9 @@ final class GroupManagerV2 {
|
||||
private GroupManager.GroupActionResult commitChange(@NonNull GroupChange.Actions.Builder change, boolean allowWhenBlocked, boolean sendToMembers)
|
||||
throws GroupNotAMemberException, GroupChangeFailedException, IOException, GroupInsufficientRightsException
|
||||
{
|
||||
final GroupDatabase.GroupRecord groupRecord = groupDatabase.requireGroup(groupId);
|
||||
final GroupDatabase.V2GroupProperties v2GroupProperties = groupRecord.requireV2GroupProperties();
|
||||
final int nextRevision = v2GroupProperties.getGroupRevision() + 1;
|
||||
final GroupTable.GroupRecord groupRecord = groupDatabase.requireGroup(groupId);
|
||||
final GroupTable.V2GroupProperties v2GroupProperties = groupRecord.requireV2GroupProperties();
|
||||
final int nextRevision = v2GroupProperties.getGroupRevision() + 1;
|
||||
final GroupChange.Actions changeActions = change.setRevision(nextRevision).build();
|
||||
final DecryptedGroupChange decryptedChange;
|
||||
final DecryptedGroup decryptedGroupState;
|
||||
@@ -923,7 +923,7 @@ final class GroupManagerV2 {
|
||||
alreadyAMember = true;
|
||||
}
|
||||
|
||||
Optional<GroupDatabase.GroupRecord> unmigratedV1Group = groupDatabase.getGroupV1ByExpectedV2(groupId);
|
||||
Optional<GroupTable.GroupRecord> unmigratedV1Group = groupDatabase.getGroupV1ByExpectedV2(groupId);
|
||||
|
||||
if (unmigratedV1Group.isPresent()) {
|
||||
Log.i(TAG, "Group link was for a migrated V1 group we know about! Migrating it and using that as the base.");
|
||||
@@ -932,7 +932,7 @@ final class GroupManagerV2 {
|
||||
|
||||
DecryptedGroup decryptedGroup = createPlaceholderGroup(joinInfo, requestToJoin);
|
||||
|
||||
Optional<GroupDatabase.GroupRecord> group = groupDatabase.getGroup(groupId);
|
||||
Optional<GroupTable.GroupRecord> group = groupDatabase.getGroup(groupId);
|
||||
|
||||
if (group.isPresent()) {
|
||||
Log.i(TAG, "Group already present locally");
|
||||
@@ -951,8 +951,8 @@ final class GroupManagerV2 {
|
||||
if (alreadyAMember) {
|
||||
Log.i(TAG, "Already a member of the group");
|
||||
|
||||
ThreadDatabase threadDatabase = SignalDatabase.threads();
|
||||
long threadId = threadDatabase.getOrCreateValidThreadId(groupRecipient, -1);
|
||||
ThreadTable threadTable = SignalDatabase.threads();
|
||||
long threadId = threadTable.getOrCreateValidThreadId(groupRecipient, -1);
|
||||
|
||||
return new GroupManager.GroupActionResult(groupRecipient,
|
||||
threadId,
|
||||
|
||||
@@ -10,18 +10,15 @@ import com.annimon.stream.Stream;
|
||||
import org.signal.core.util.logging.Log;
|
||||
import org.signal.libsignal.zkgroup.groups.GroupMasterKey;
|
||||
import org.signal.storageservice.protos.groups.local.DecryptedGroup;
|
||||
import org.thoughtcrime.securesms.database.GroupDatabase;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase;
|
||||
import org.thoughtcrime.securesms.database.GroupTable;
|
||||
import org.thoughtcrime.securesms.database.RecipientTable;
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase;
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
||||
import org.thoughtcrime.securesms.mms.MmsException;
|
||||
import org.thoughtcrime.securesms.mms.OutgoingMediaMessage;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientUtil;
|
||||
import org.thoughtcrime.securesms.transport.RetryLaterException;
|
||||
import org.thoughtcrime.securesms.util.FeatureFlags;
|
||||
import org.thoughtcrime.securesms.util.GroupUtil;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
@@ -39,8 +36,8 @@ public final class GroupsV1MigrationUtil {
|
||||
throws IOException, RetryLaterException, GroupChangeBusyException, InvalidMigrationStateException
|
||||
{
|
||||
Recipient groupRecipient = Recipient.resolved(recipientId);
|
||||
Long threadId = SignalDatabase.threads().getThreadIdFor(recipientId);
|
||||
GroupDatabase groupDatabase = SignalDatabase.groups();
|
||||
Long threadId = SignalDatabase.threads().getThreadIdFor(recipientId);
|
||||
GroupTable groupDatabase = SignalDatabase.groups();
|
||||
|
||||
if (threadId == null) {
|
||||
Log.w(TAG, "No thread found!");
|
||||
@@ -210,7 +207,7 @@ public final class GroupsV1MigrationUtil {
|
||||
*/
|
||||
public static boolean isAutoMigratable(@NonNull Recipient recipient) {
|
||||
return recipient.hasServiceId() &&
|
||||
recipient.getRegistered() == RecipientDatabase.RegisteredState.REGISTERED &&
|
||||
recipient.getRegistered() == RecipientTable.RegisteredState.REGISTERED &&
|
||||
recipient.getProfileKey() != null;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ import org.signal.storageservice.protos.groups.AccessControl;
|
||||
import org.signal.storageservice.protos.groups.local.DecryptedGroup;
|
||||
import org.signal.storageservice.protos.groups.local.DecryptedRequestingMember;
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.database.GroupDatabase;
|
||||
import org.thoughtcrime.securesms.database.GroupTable;
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.groups.ui.GroupMemberEntry;
|
||||
@@ -46,10 +46,10 @@ public final class LiveGroup {
|
||||
.thenComparing(HAS_DISPLAY_NAME)
|
||||
.thenComparing(ALPHABETICAL);
|
||||
|
||||
private final GroupDatabase groupDatabase;
|
||||
private final LiveData<Recipient> recipient;
|
||||
private final LiveData<GroupDatabase.GroupRecord> groupRecord;
|
||||
private final LiveData<List<GroupMemberEntry.FullMember>> fullMembers;
|
||||
private final GroupTable groupDatabase;
|
||||
private final LiveData<Recipient> recipient;
|
||||
private final LiveData<GroupTable.GroupRecord> groupRecord;
|
||||
private final LiveData<List<GroupMemberEntry.FullMember>> fullMembers;
|
||||
private final LiveData<List<GroupMemberEntry.RequestingMember>> requestingMembers;
|
||||
private final LiveData<GroupLinkUrlAndStatus> groupLink;
|
||||
|
||||
@@ -64,7 +64,7 @@ public final class LiveGroup {
|
||||
this.requestingMembers = mapToRequestingMembers(this.groupRecord);
|
||||
|
||||
if (groupId.isV2()) {
|
||||
LiveData<GroupDatabase.V2GroupProperties> v2Properties = Transformations.map(this.groupRecord, GroupDatabase.GroupRecord::requireV2GroupProperties);
|
||||
LiveData<GroupTable.V2GroupProperties> v2Properties = Transformations.map(this.groupRecord, GroupTable.GroupRecord::requireV2GroupProperties);
|
||||
this.groupLink = Transformations.map(v2Properties, g -> {
|
||||
DecryptedGroup group = g.getDecryptedGroup();
|
||||
AccessControl.AccessRequired addFromInviteLink = group.getAccessControl().getAddFromInviteLink();
|
||||
@@ -87,7 +87,7 @@ public final class LiveGroup {
|
||||
SignalExecutors.BOUNDED.execute(() -> liveRecipient.postValue(Recipient.externalGroupExact(groupId).live()));
|
||||
}
|
||||
|
||||
protected static LiveData<List<GroupMemberEntry.FullMember>> mapToFullMembers(@NonNull LiveData<GroupDatabase.GroupRecord> groupRecord) {
|
||||
protected static LiveData<List<GroupMemberEntry.FullMember>> mapToFullMembers(@NonNull LiveData<GroupTable.GroupRecord> groupRecord) {
|
||||
return LiveDataUtil.mapAsync(groupRecord,
|
||||
g -> Stream.of(g.getMembers())
|
||||
.map(m -> {
|
||||
@@ -98,7 +98,7 @@ public final class LiveGroup {
|
||||
.toList());
|
||||
}
|
||||
|
||||
protected static LiveData<List<GroupMemberEntry.RequestingMember>> mapToRequestingMembers(@NonNull LiveData<GroupDatabase.GroupRecord> groupRecord) {
|
||||
protected static LiveData<List<GroupMemberEntry.RequestingMember>> mapToRequestingMembers(@NonNull LiveData<GroupTable.GroupRecord> groupRecord) {
|
||||
return LiveDataUtil.mapAsync(groupRecord,
|
||||
g -> {
|
||||
if (!g.isV2Group()) {
|
||||
@@ -128,11 +128,11 @@ public final class LiveGroup {
|
||||
}
|
||||
|
||||
public LiveData<String> getDescription() {
|
||||
return Transformations.map(groupRecord, GroupDatabase.GroupRecord::getDescription);
|
||||
return Transformations.map(groupRecord, GroupTable.GroupRecord::getDescription);
|
||||
}
|
||||
|
||||
public LiveData<Boolean> isAnnouncementGroup() {
|
||||
return Transformations.map(groupRecord, GroupDatabase.GroupRecord::isAnnouncementGroup);
|
||||
return Transformations.map(groupRecord, GroupTable.GroupRecord::isAnnouncementGroup);
|
||||
}
|
||||
|
||||
public LiveData<Recipient> getGroupRecipient() {
|
||||
@@ -148,7 +148,7 @@ public final class LiveGroup {
|
||||
}
|
||||
|
||||
public LiveData<Boolean> isActive() {
|
||||
return Transformations.map(groupRecord, GroupDatabase.GroupRecord::isActive);
|
||||
return Transformations.map(groupRecord, GroupTable.GroupRecord::isActive);
|
||||
}
|
||||
|
||||
public LiveData<Boolean> getRecipientIsAdmin(@NonNull RecipientId recipientId) {
|
||||
@@ -171,11 +171,11 @@ public final class LiveGroup {
|
||||
}
|
||||
|
||||
public LiveData<GroupAccessControl> getMembershipAdditionAccessControl() {
|
||||
return Transformations.map(groupRecord, GroupDatabase.GroupRecord::getMembershipAdditionAccessControl);
|
||||
return Transformations.map(groupRecord, GroupTable.GroupRecord::getMembershipAdditionAccessControl);
|
||||
}
|
||||
|
||||
public LiveData<GroupAccessControl> getAttributesAccessControl() {
|
||||
return Transformations.map(groupRecord, GroupDatabase.GroupRecord::getAttributesAccessControl);
|
||||
return Transformations.map(groupRecord, GroupTable.GroupRecord::getAttributesAccessControl);
|
||||
}
|
||||
|
||||
public LiveData<List<GroupMemberEntry.FullMember>> getNonAdminFullMembers() {
|
||||
@@ -221,7 +221,7 @@ public final class LiveGroup {
|
||||
return Transformations.map(getFullMembers(), fullMembers -> getMembershipDescription(resources, 0, fullMembers.size()));
|
||||
}
|
||||
|
||||
public LiveData<GroupDatabase.MemberLevel> getMemberLevel(@NonNull Recipient recipient) {
|
||||
public LiveData<GroupTable.MemberLevel> getMemberLevel(@NonNull Recipient recipient) {
|
||||
return Transformations.map(groupRecord, g -> g.memberLevel(recipient));
|
||||
}
|
||||
|
||||
@@ -234,14 +234,14 @@ public final class LiveGroup {
|
||||
}
|
||||
}
|
||||
|
||||
private LiveData<GroupDatabase.MemberLevel> selfMemberLevel() {
|
||||
private LiveData<GroupTable.MemberLevel> selfMemberLevel() {
|
||||
return Transformations.map(groupRecord, g -> g.memberLevel(Recipient.self()));
|
||||
}
|
||||
|
||||
private static boolean applyAccessControl(@NonNull GroupDatabase.MemberLevel memberLevel, @NonNull GroupAccessControl rights) {
|
||||
private static boolean applyAccessControl(@NonNull GroupTable.MemberLevel memberLevel, @NonNull GroupAccessControl rights) {
|
||||
switch (rights) {
|
||||
case ALL_MEMBERS: return memberLevel.isInGroup();
|
||||
case ONLY_ADMINS: return memberLevel == GroupDatabase.MemberLevel.ADMINISTRATOR;
|
||||
case ONLY_ADMINS: return memberLevel == GroupTable.MemberLevel.ADMINISTRATOR;
|
||||
case NO_ONE : return false;
|
||||
default: throw new AssertionError();
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
|
||||
import org.signal.core.util.logging.Log;
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.database.GroupDatabase;
|
||||
import org.thoughtcrime.securesms.database.GroupTable;
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase;
|
||||
import org.thoughtcrime.securesms.groups.GroupChangeException;
|
||||
import org.thoughtcrime.securesms.groups.GroupId;
|
||||
@@ -54,13 +54,13 @@ public final class LeaveGroupDialog {
|
||||
}
|
||||
|
||||
SimpleTask.run(activity.getLifecycle(), () -> {
|
||||
GroupDatabase.V2GroupProperties groupProperties = SignalDatabase.groups()
|
||||
.getGroup(groupId)
|
||||
.map(GroupDatabase.GroupRecord::requireV2GroupProperties)
|
||||
.orElse(null);
|
||||
GroupTable.V2GroupProperties groupProperties = SignalDatabase.groups()
|
||||
.getGroup(groupId)
|
||||
.map(GroupTable.GroupRecord::requireV2GroupProperties)
|
||||
.orElse(null);
|
||||
|
||||
if (groupProperties != null && groupProperties.isAdmin(Recipient.self())) {
|
||||
List<Recipient> otherMemberRecipients = groupProperties.getMemberRecipients(GroupDatabase.MemberSet.FULL_MEMBERS_EXCLUDING_SELF);
|
||||
List<Recipient> otherMemberRecipients = groupProperties.getMemberRecipients(GroupTable.MemberSet.FULL_MEMBERS_EXCLUDING_SELF);
|
||||
long otherAdminsCount = Stream.of(otherMemberRecipients).filter(groupProperties::isAdmin).count();
|
||||
|
||||
return otherAdminsCount == 0 && !otherMemberRecipients.isEmpty();
|
||||
|
||||
@@ -19,14 +19,13 @@ import org.thoughtcrime.securesms.ContactSelectionListFragment;
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.contacts.ContactsCursorLoader;
|
||||
import org.thoughtcrime.securesms.contacts.sync.ContactDiscovery;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase;
|
||||
import org.thoughtcrime.securesms.database.RecipientTable;
|
||||
import org.thoughtcrime.securesms.groups.ui.creategroup.details.AddGroupDetailsActivity;
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId;
|
||||
import org.thoughtcrime.securesms.util.FeatureFlags;
|
||||
import org.signal.core.util.Stopwatch;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
import org.thoughtcrime.securesms.util.views.SimpleProgressDialog;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -151,7 +150,7 @@ public class CreateGroupActivity extends ContactSelectionActivity {
|
||||
stopwatch.split("resolve");
|
||||
|
||||
Set<Recipient> registeredChecks = resolved.stream()
|
||||
.filter(r -> r.getRegistered() == RecipientDatabase.RegisteredState.UNKNOWN)
|
||||
.filter(r -> r.getRegistered() == RecipientTable.RegisteredState.UNKNOWN)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
Log.i(TAG, "Need to do " + registeredChecks.size() + " registration checks.");
|
||||
|
||||
@@ -15,7 +15,7 @@ import org.signal.libsignal.zkgroup.InvalidInputException;
|
||||
import org.signal.libsignal.zkgroup.groups.UuidCiphertext;
|
||||
import org.signal.storageservice.protos.groups.local.DecryptedGroup;
|
||||
import org.signal.storageservice.protos.groups.local.DecryptedPendingMember;
|
||||
import org.thoughtcrime.securesms.database.GroupDatabase;
|
||||
import org.thoughtcrime.securesms.database.GroupTable;
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase;
|
||||
import org.thoughtcrime.securesms.groups.GroupChangeException;
|
||||
import org.thoughtcrime.securesms.groups.GroupId;
|
||||
@@ -49,9 +49,9 @@ final class PendingMemberInvitesRepository {
|
||||
|
||||
public void getInvitees(@NonNull Consumer<InviteeResult> onInviteesLoaded) {
|
||||
executor.execute(() -> {
|
||||
GroupDatabase groupDatabase = SignalDatabase.groups();
|
||||
GroupDatabase.V2GroupProperties v2GroupProperties = groupDatabase.getGroup(groupId).get().requireV2GroupProperties();
|
||||
DecryptedGroup decryptedGroup = v2GroupProperties.getDecryptedGroup();
|
||||
GroupTable groupDatabase = SignalDatabase.groups();
|
||||
GroupTable.V2GroupProperties v2GroupProperties = groupDatabase.getGroup(groupId).get().requireV2GroupProperties();
|
||||
DecryptedGroup decryptedGroup = v2GroupProperties.getDecryptedGroup();
|
||||
List<DecryptedPendingMember> pendingMembersList = decryptedGroup.getPendingMembersList();
|
||||
List<SinglePendingMemberInvitedByYou> byMe = new ArrayList<>(pendingMembersList.size());
|
||||
List<MultiplePendingMembersInvitedByAnother> byOthers = new ArrayList<>(pendingMembersList.size());
|
||||
|
||||
@@ -13,7 +13,7 @@ import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.core.util.Consumer;
|
||||
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase.MentionSetting;
|
||||
import org.thoughtcrime.securesms.database.RecipientTable.MentionSetting;
|
||||
|
||||
public final class GroupMentionSettingDialog {
|
||||
|
||||
|
||||
@@ -4,18 +4,15 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.WorkerThread;
|
||||
import androidx.core.util.Consumer;
|
||||
|
||||
import com.annimon.stream.Collectors;
|
||||
import com.annimon.stream.Stream;
|
||||
|
||||
import org.signal.core.util.concurrent.SignalExecutors;
|
||||
import org.signal.core.util.logging.Log;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase;
|
||||
import org.thoughtcrime.securesms.database.RecipientTable;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.groups.GroupChangeBusyException;
|
||||
import org.thoughtcrime.securesms.groups.GroupsV1MigrationUtil;
|
||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
||||
import org.thoughtcrime.securesms.jobs.RetrieveProfileJob;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientUtil;
|
||||
@@ -24,8 +21,6 @@ import org.thoughtcrime.securesms.transport.RetryLaterException;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
final class GroupsV1MigrationRepository {
|
||||
|
||||
@@ -83,7 +78,7 @@ final class GroupsV1MigrationRepository {
|
||||
group = group.fresh();
|
||||
|
||||
List<Recipient> ineligible = Stream.of(members)
|
||||
.filter(r -> !r.hasServiceId() || r.getRegistered() != RecipientDatabase.RegisteredState.REGISTERED)
|
||||
.filter(r -> !r.hasServiceId() || r.getRegistered() != RecipientTable.RegisteredState.REGISTERED)
|
||||
.toList();
|
||||
|
||||
List<Recipient> invites = Stream.of(members)
|
||||
|
||||
@@ -5,7 +5,7 @@ import androidx.annotation.WorkerThread;
|
||||
|
||||
import org.signal.core.util.logging.Log;
|
||||
import org.signal.libsignal.zkgroup.profiles.ExpiringProfileKeyCredential;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase;
|
||||
import org.thoughtcrime.securesms.database.RecipientTable;
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
@@ -25,11 +25,11 @@ import java.util.Set;
|
||||
|
||||
public class GroupCandidateHelper {
|
||||
private final SignalServiceAccountManager signalServiceAccountManager;
|
||||
private final RecipientDatabase recipientDatabase;
|
||||
private final RecipientTable recipientTable;
|
||||
|
||||
public GroupCandidateHelper() {
|
||||
signalServiceAccountManager = ApplicationDependencies.getSignalServiceAccountManager();
|
||||
recipientDatabase = SignalDatabase.recipients();
|
||||
recipientTable = SignalDatabase.recipients();
|
||||
}
|
||||
|
||||
private static final String TAG = Log.tag(GroupCandidateHelper.class);
|
||||
@@ -54,7 +54,7 @@ public class GroupCandidateHelper {
|
||||
GroupCandidate candidate = new GroupCandidate(serviceId.uuid(), expiringProfileKeyCredential);
|
||||
|
||||
if (!candidate.hasValidProfileKeyCredential()) {
|
||||
recipientDatabase.clearProfileKeyCredential(recipient.getId());
|
||||
recipientTable.clearProfileKeyCredential(recipient.getId());
|
||||
|
||||
Optional<ExpiringProfileKeyCredential> credential = ProfileUtil.updateExpiringProfileKeyCredential(recipient);
|
||||
if (credential.isPresent()) {
|
||||
|
||||
@@ -19,12 +19,12 @@ 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.DecryptedPendingMemberRemoval;
|
||||
import org.thoughtcrime.securesms.database.GroupDatabase;
|
||||
import org.thoughtcrime.securesms.database.GroupDatabase.GroupRecord;
|
||||
import org.thoughtcrime.securesms.database.MessageDatabase;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase;
|
||||
import org.thoughtcrime.securesms.database.GroupTable;
|
||||
import org.thoughtcrime.securesms.database.GroupTable.GroupRecord;
|
||||
import org.thoughtcrime.securesms.database.MessageTable;
|
||||
import org.thoughtcrime.securesms.database.RecipientTable;
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase;
|
||||
import org.thoughtcrime.securesms.database.ThreadDatabase;
|
||||
import org.thoughtcrime.securesms.database.ThreadTable;
|
||||
import org.thoughtcrime.securesms.database.model.databaseprotos.DecryptedGroupV2Context;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.groups.GroupDoesNotExistException;
|
||||
@@ -91,22 +91,22 @@ public class GroupsV2StateProcessor {
|
||||
*/
|
||||
public static final int RESTORE_PLACEHOLDER_REVISION = GroupStateMapper.RESTORE_PLACEHOLDER_REVISION;
|
||||
|
||||
private final Context context;
|
||||
private final RecipientDatabase recipientDatabase;
|
||||
private final GroupDatabase groupDatabase;
|
||||
private final Context context;
|
||||
private final RecipientTable recipientTable;
|
||||
private final GroupTable groupDatabase;
|
||||
private final GroupsV2Authorization groupsV2Authorization;
|
||||
private final GroupsV2Api groupsV2Api;
|
||||
|
||||
public GroupsV2StateProcessor(@NonNull Context context) {
|
||||
this.context = context.getApplicationContext();
|
||||
this.groupsV2Authorization = ApplicationDependencies.getGroupsV2Authorization();
|
||||
this.groupsV2Api = ApplicationDependencies.getSignalServiceAccountManager().getGroupsV2Api();
|
||||
this.recipientDatabase = SignalDatabase.recipients();
|
||||
this.groupDatabase = SignalDatabase.groups();
|
||||
this.groupsV2Api = ApplicationDependencies.getSignalServiceAccountManager().getGroupsV2Api();
|
||||
this.recipientTable = SignalDatabase.recipients();
|
||||
this.groupDatabase = SignalDatabase.groups();
|
||||
}
|
||||
|
||||
public StateProcessorForGroup forGroup(@NonNull ServiceIds serviceIds, @NonNull GroupMasterKey groupMasterKey) {
|
||||
ProfileAndMessageHelper profileAndMessageHelper = new ProfileAndMessageHelper(context, serviceIds.getAci(), groupMasterKey, GroupId.v2(groupMasterKey), recipientDatabase);
|
||||
ProfileAndMessageHelper profileAndMessageHelper = new ProfileAndMessageHelper(context, serviceIds.getAci(), groupMasterKey, GroupId.v2(groupMasterKey), recipientTable);
|
||||
|
||||
return new StateProcessorForGroup(serviceIds, context, groupDatabase, groupsV2Api, groupsV2Authorization, groupMasterKey, profileAndMessageHelper);
|
||||
}
|
||||
@@ -143,9 +143,9 @@ public class GroupsV2StateProcessor {
|
||||
|
||||
public static final class StateProcessorForGroup {
|
||||
private final ServiceIds serviceIds;
|
||||
private final Context context;
|
||||
private final GroupDatabase groupDatabase;
|
||||
private final GroupsV2Api groupsV2Api;
|
||||
private final Context context;
|
||||
private final GroupTable groupDatabase;
|
||||
private final GroupsV2Api groupsV2Api;
|
||||
private final GroupsV2Authorization groupsV2Authorization;
|
||||
private final GroupMasterKey masterKey;
|
||||
private final GroupId.V2 groupId;
|
||||
@@ -154,7 +154,7 @@ public class GroupsV2StateProcessor {
|
||||
|
||||
@VisibleForTesting StateProcessorForGroup(@NonNull ServiceIds serviceIds,
|
||||
@NonNull Context context,
|
||||
@NonNull GroupDatabase groupDatabase,
|
||||
@NonNull GroupTable groupDatabase,
|
||||
@NonNull GroupsV2Api groupsV2Api,
|
||||
@NonNull GroupsV2Authorization groupsV2Authorization,
|
||||
@NonNull GroupMasterKey groupMasterKey,
|
||||
@@ -515,12 +515,12 @@ public class GroupsV2StateProcessor {
|
||||
OutgoingGroupUpdateMessage leaveMessage = new OutgoingGroupUpdateMessage(groupRecipient, decryptedGroupV2Context, System.currentTimeMillis());
|
||||
|
||||
try {
|
||||
MessageDatabase mmsDatabase = SignalDatabase.mms();
|
||||
ThreadDatabase threadDatabase = SignalDatabase.threads();
|
||||
long threadId = threadDatabase.getOrCreateThreadIdFor(groupRecipient);
|
||||
long id = mmsDatabase.insertMessageOutbox(leaveMessage, threadId, false, null);
|
||||
MessageTable mmsDatabase = SignalDatabase.mms();
|
||||
ThreadTable threadTable = SignalDatabase.threads();
|
||||
long threadId = threadTable.getOrCreateThreadIdFor(groupRecipient);
|
||||
long id = mmsDatabase.insertMessageOutbox(leaveMessage, threadId, false, null);
|
||||
mmsDatabase.markAsSent(id, true);
|
||||
threadDatabase.update(threadId, false, false);
|
||||
threadTable.update(threadId, false, false);
|
||||
} catch (MmsException e) {
|
||||
warn( "Failed to insert leave message.", e);
|
||||
}
|
||||
@@ -607,18 +607,18 @@ public class GroupsV2StateProcessor {
|
||||
|
||||
private final Context context;
|
||||
private final ServiceId serviceId;
|
||||
private final GroupId.V2 groupId;
|
||||
private final RecipientDatabase recipientDatabase;
|
||||
private final GroupId.V2 groupId;
|
||||
private final RecipientTable recipientTable;
|
||||
|
||||
@VisibleForTesting
|
||||
GroupMasterKey masterKey;
|
||||
|
||||
ProfileAndMessageHelper(@NonNull Context context, @NonNull ServiceId serviceId, @NonNull GroupMasterKey masterKey, @NonNull GroupId.V2 groupId, @NonNull RecipientDatabase recipientDatabase) {
|
||||
this.context = context;
|
||||
this.serviceId = serviceId;
|
||||
this.masterKey = masterKey;
|
||||
this.groupId = groupId;
|
||||
this.recipientDatabase = recipientDatabase;
|
||||
ProfileAndMessageHelper(@NonNull Context context, @NonNull ServiceId serviceId, @NonNull GroupMasterKey masterKey, @NonNull GroupId.V2 groupId, @NonNull RecipientTable recipientTable) {
|
||||
this.context = context;
|
||||
this.serviceId = serviceId;
|
||||
this.masterKey = masterKey;
|
||||
this.groupId = groupId;
|
||||
this.recipientTable = recipientTable;
|
||||
}
|
||||
|
||||
void determineProfileSharing(@NonNull GlobalGroupState inputGroupState, @NonNull DecryptedGroup newLocalState) {
|
||||
@@ -658,7 +658,7 @@ public class GroupsV2StateProcessor {
|
||||
} else if (addedBy.isSystemContact() || addedBy.isProfileSharing()) {
|
||||
Log.i(TAG, "Group 'adder' is trusted. contact: " + addedBy.isSystemContact() + ", profileSharing: " + addedBy.isProfileSharing());
|
||||
Log.i(TAG, "Added to a group and auto-enabling profile sharing");
|
||||
recipientDatabase.setProfileSharing(Recipient.externalGroupExact(groupId).getId(), true);
|
||||
recipientTable.setProfileSharing(Recipient.externalGroupExact(groupId).getId(), true);
|
||||
} else {
|
||||
Log.i(TAG, "Added to a group, but not enabling profile sharing, as 'adder' is not trusted");
|
||||
}
|
||||
@@ -720,7 +720,7 @@ public class GroupsV2StateProcessor {
|
||||
}
|
||||
|
||||
void persistLearnedProfileKeys(@NonNull ProfileKeySet profileKeys) {
|
||||
Set<RecipientId> updated = recipientDatabase.persistProfileKeySet(profileKeys);
|
||||
Set<RecipientId> updated = recipientTable.persistProfileKeySet(profileKeys);
|
||||
|
||||
if (!updated.isEmpty()) {
|
||||
Log.i(TAG, String.format(Locale.US, "Learned %d new profile keys, fetching profiles", updated.size()));
|
||||
@@ -738,25 +738,25 @@ public class GroupsV2StateProcessor {
|
||||
|
||||
if (outgoing) {
|
||||
try {
|
||||
MessageDatabase mmsDatabase = SignalDatabase.mms();
|
||||
ThreadDatabase threadDatabase = SignalDatabase.threads();
|
||||
RecipientId recipientId = recipientDatabase.getOrInsertFromGroupId(groupId);
|
||||
MessageTable mmsDatabase = SignalDatabase.mms();
|
||||
ThreadTable threadTable = SignalDatabase.threads();
|
||||
RecipientId recipientId = recipientTable.getOrInsertFromGroupId(groupId);
|
||||
Recipient recipient = Recipient.resolved(recipientId);
|
||||
OutgoingGroupUpdateMessage outgoingMessage = new OutgoingGroupUpdateMessage(recipient, decryptedGroupV2Context, timestamp);
|
||||
long threadId = threadDatabase.getOrCreateThreadIdFor(recipient);
|
||||
long threadId = threadTable.getOrCreateThreadIdFor(recipient);
|
||||
long messageId = mmsDatabase.insertMessageOutbox(outgoingMessage, threadId, false, null);
|
||||
|
||||
mmsDatabase.markAsSent(messageId, true);
|
||||
threadDatabase.update(threadId, false, false);
|
||||
threadTable.update(threadId, false, false);
|
||||
} catch (MmsException e) {
|
||||
Log.w(TAG, e);
|
||||
}
|
||||
} else {
|
||||
MessageDatabase smsDatabase = SignalDatabase.sms();
|
||||
RecipientId sender = RecipientId.from(editor.get());
|
||||
MessageTable smsDatabase = SignalDatabase.sms();
|
||||
RecipientId sender = RecipientId.from(editor.get());
|
||||
IncomingTextMessage incoming = new IncomingTextMessage(sender, -1, timestamp, timestamp, timestamp, "", Optional.of(groupId), 0, false, null);
|
||||
IncomingGroupUpdateMessage groupMessage = new IncomingGroupUpdateMessage(incoming, decryptedGroupV2Context);
|
||||
Optional<MessageDatabase.InsertResult> insertResult = smsDatabase.insertMessageInbox(groupMessage);
|
||||
IncomingGroupUpdateMessage groupMessage = new IncomingGroupUpdateMessage(incoming, decryptedGroupV2Context);
|
||||
Optional<MessageTable.InsertResult> insertResult = smsDatabase.insertMessageInbox(groupMessage);
|
||||
|
||||
if (insertResult.isPresent()) {
|
||||
SignalDatabase.threads().update(insertResult.get().getThreadId(), false, false);
|
||||
|
||||
Reference in New Issue
Block a user