use of org.thoughtcrime.securesms.groups.GroupId in project Signal-Android by WhisperSystems.
the class ReviewUtil method getDuplicatedRecipients.
@WorkerThread
@NonNull
public static List<ReviewRecipient> getDuplicatedRecipients(@NonNull GroupId.V2 groupId) {
Context context = ApplicationDependencies.getApplication();
List<MessageRecord> profileChangeRecords = getProfileChangeRecordsForGroup(context, groupId);
if (profileChangeRecords.isEmpty()) {
return Collections.emptyList();
}
List<Recipient> members = SignalDatabase.groups().getGroupMembers(groupId, GroupDatabase.MemberSet.FULL_MEMBERS_INCLUDING_SELF);
List<ReviewRecipient> changed = Stream.of(profileChangeRecords).distinctBy(record -> record.getRecipient().getId()).map(record -> new ReviewRecipient(record.getRecipient().resolve(), getProfileChangeDetails(record))).filter(recipient -> !recipient.getRecipient().isSystemContact()).toList();
List<ReviewRecipient> results = new LinkedList<>();
for (ReviewRecipient recipient : changed) {
if (results.contains(recipient)) {
continue;
}
members.remove(recipient.getRecipient());
for (Recipient member : members) {
if (Objects.equals(member.getDisplayName(context), recipient.getRecipient().getDisplayName(context))) {
results.add(recipient);
results.add(new ReviewRecipient(member));
}
}
}
return results;
}
use of org.thoughtcrime.securesms.groups.GroupId in project Signal-Android by WhisperSystems.
the class ReviewCardDialogFragment method getRepository.
@NonNull
private ReviewCardRepository getRepository() throws BadGroupIdException {
RecipientId recipientId = getRecipientId();
GroupId.V2 groupId = getGroupId();
if (recipientId != null) {
return new ReviewCardRepository(requireContext(), recipientId);
} else if (groupId != null) {
return new ReviewCardRepository(requireContext(), groupId);
} else {
throw new AssertionError();
}
}
use of org.thoughtcrime.securesms.groups.GroupId in project Signal-Android by WhisperSystems.
the class GroupDatabase method getAllExpectedV2Ids.
/**
* Key: The 'expected' V2 ID (i.e. what a V1 ID would map to when migrated)
* Value: The matching V1 ID
*/
@NonNull
public Map<GroupId.V2, GroupId.V1> getAllExpectedV2Ids() {
Map<GroupId.V2, GroupId.V1> result = new HashMap<>();
String[] projection = new String[] { GROUP_ID, EXPECTED_V2_ID };
String query = EXPECTED_V2_ID + " NOT NULL";
try (Cursor cursor = databaseHelper.getSignalReadableDatabase().query(TABLE_NAME, projection, query, null, null, null, null)) {
while (cursor.moveToNext()) {
GroupId.V1 groupId = GroupId.parseOrThrow(cursor.getString(cursor.getColumnIndexOrThrow(GROUP_ID))).requireV1();
GroupId.V2 expectedId = GroupId.parseOrThrow(cursor.getString(cursor.getColumnIndexOrThrow(EXPECTED_V2_ID))).requireV2();
result.put(expectedId, groupId);
}
}
return result;
}
use of org.thoughtcrime.securesms.groups.GroupId in project Signal-Android by WhisperSystems.
the class GroupDatabase method getOrCreateMmsGroupForMembers.
public GroupId.Mms getOrCreateMmsGroupForMembers(List<RecipientId> members) {
Collections.sort(members);
Cursor cursor = databaseHelper.getSignalReadableDatabase().query(TABLE_NAME, new String[] { GROUP_ID }, MEMBERS + " = ? AND " + MMS + " = ?", new String[] { RecipientId.toSerializedList(members), "1" }, null, null, null);
try {
if (cursor != null && cursor.moveToNext()) {
return GroupId.parseOrThrow(cursor.getString(cursor.getColumnIndexOrThrow(GROUP_ID))).requireMms();
} else {
GroupId.Mms groupId = GroupId.createMms(new SecureRandom());
create(groupId, null, members);
return groupId;
}
} finally {
if (cursor != null)
cursor.close();
}
}
use of org.thoughtcrime.securesms.groups.GroupId in project Signal-Android by WhisperSystems.
the class GroupDatabase method getGroupMembers.
@WorkerThread
@NonNull
public List<Recipient> getGroupMembers(@NonNull GroupId groupId, @NonNull MemberSet memberSet) {
if (groupId.isV2()) {
return getGroup(groupId).transform(g -> g.requireV2GroupProperties().getMemberRecipients(memberSet)).or(Collections.emptyList());
} else {
List<RecipientId> currentMembers = getCurrentMembers(groupId);
List<Recipient> recipients = new ArrayList<>(currentMembers.size());
for (RecipientId member : currentMembers) {
Recipient resolved = Recipient.resolved(member);
if (memberSet.includeSelf || !resolved.isSelf()) {
recipients.add(resolved);
}
}
return recipients;
}
}
Aggregations