Fix situation where group thread does not yet exist.

This commit is contained in:
Alan Evans 2020-11-17 15:52:38 -04:00 committed by GitHub
parent 8df6e95781
commit 6e5abc92a0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -24,7 +24,9 @@ import java.util.List;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
public class ReviewUtil {
public final class ReviewUtil {
private ReviewUtil() { }
private static final long TIMEOUT = TimeUnit.HOURS.toMillis(24);
@ -91,10 +93,14 @@ public class ReviewUtil {
@WorkerThread
public static @NonNull List<MessageRecord> getProfileChangeRecordsForGroup(@NonNull Context context, @NonNull GroupId.V2 groupId) {
RecipientId recipientId = DatabaseFactory.getRecipientDatabase(context).getByGroupId(groupId).get();
long threadId = Objects.requireNonNull(DatabaseFactory.getThreadDatabase(context).getThreadIdFor(recipientId));
Long threadId = DatabaseFactory.getThreadDatabase(context).getThreadIdFor(recipientId);
if (threadId == null) {
return Collections.emptyList();
} else {
return DatabaseFactory.getSmsDatabase(context).getProfileChangeDetailsRecords(threadId, System.currentTimeMillis() - TIMEOUT);
}
}
@WorkerThread
public static int getGroupsInCommonCount(@NonNull Context context, @NonNull RecipientId recipientId) {