Rotate profile key after blocking if shared via group.

This commit is contained in:
Greyson Parrelli
2020-03-25 11:20:09 -04:00
parent 7e9e2fead2
commit a3358e5b21
2 changed files with 21 additions and 6 deletions

View File

@@ -7,6 +7,8 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.WorkerThread;
import com.annimon.stream.Stream;
import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.contacts.sync.DirectoryHelper;
import org.thoughtcrime.securesms.database.DatabaseFactory;
@@ -81,7 +83,7 @@ public class RecipientUtil {
leaveGroup(context, recipient);
}
if (resolved.isSystemContact() || resolved.isProfileSharing()) {
if (resolved.isSystemContact() || resolved.isProfileSharing() || isProfileSharedViaGroup(context,resolved)) {
ApplicationDependencies.getJobManager().add(new RotateProfileKeyJob());
DatabaseFactory.getRecipientDatabase(context).setProfileSharing(resolved.getId(), false);
}
@@ -229,4 +231,10 @@ public class RecipientUtil {
private static boolean noSecureMessagesInThread(@NonNull Context context, long threadId) {
return DatabaseFactory.getMmsSmsDatabase(context).getSecureConversationCount(threadId) == 0;
}
@WorkerThread
private static boolean isProfileSharedViaGroup(@NonNull Context context, @NonNull Recipient recipient) {
return Stream.of(DatabaseFactory.getGroupDatabase(context).getGroupsContainingMember(recipient.getId()))
.anyMatch(group -> Recipient.resolved(group.getRecipientId()).isProfileSharing());
}
}