Integrate contact hiding with message requests.

This commit is contained in:
Clark
2023-04-05 16:55:05 -04:00
committed by Greyson Parrelli
parent 74877b839e
commit 48360d08d4
15 changed files with 107 additions and 16 deletions

View File

@@ -115,6 +115,7 @@ public class Recipient {
private final String profileAvatar;
private final ProfileAvatarFileDetails profileAvatarFileDetails;
private final boolean profileSharing;
private final boolean isHidden;
private final long lastProfileFetch;
private final String notificationChannel;
private final UnidentifiedAccessMode unidentifiedAccessMode;
@@ -412,6 +413,7 @@ public class Recipient {
this.profileAvatar = null;
this.profileAvatarFileDetails = ProfileAvatarFileDetails.NO_DETAILS;
this.profileSharing = false;
this.isHidden = false;
this.lastProfileFetch = 0;
this.notificationChannel = null;
this.unidentifiedAccessMode = UnidentifiedAccessMode.DISABLED;
@@ -466,6 +468,7 @@ public class Recipient {
this.profileAvatar = details.profileAvatar;
this.profileAvatarFileDetails = details.profileAvatarFileDetails;
this.profileSharing = details.profileSharing;
this.isHidden = details.isHidden;
this.lastProfileFetch = details.lastProfileFetch;
this.notificationChannel = details.notificationChannel;
this.unidentifiedAccessMode = details.unidentifiedAccessMode;
@@ -833,6 +836,10 @@ public class Recipient {
return profileSharing;
}
public boolean isHidden() {
return isHidden;
}
public long getLastProfileFetchTime() {
return lastProfileFetch;
}
@@ -1290,6 +1297,7 @@ public class Recipient {
expireMessages == other.expireMessages &&
Objects.equals(profileAvatarFileDetails, other.profileAvatarFileDetails) &&
profileSharing == other.profileSharing &&
isHidden == other.isHidden &&
forceSmsSelection == other.forceSmsSelection &&
Objects.equals(serviceId, other.serviceId) &&
Objects.equals(username, other.username) &&

View File

@@ -63,6 +63,7 @@ public class RecipientDetails {
final String profileAvatar;
final ProfileAvatarFileDetails profileAvatarFileDetails;
final boolean profileSharing;
final boolean isHidden;
final long lastProfileFetch;
final boolean systemContact;
final boolean isSelf;
@@ -122,6 +123,7 @@ public class RecipientDetails {
this.profileAvatar = record.getProfileAvatar();
this.profileAvatarFileDetails = record.getProfileAvatarFileDetails();
this.profileSharing = record.isProfileSharing();
this.isHidden = record.isHidden();
this.lastProfileFetch = record.getLastProfileFetch();
this.systemContact = systemContact;
this.isSelf = isSelf;
@@ -176,6 +178,7 @@ public class RecipientDetails {
this.profileAvatar = null;
this.profileAvatarFileDetails = ProfileAvatarFileDetails.NO_DETAILS;
this.profileSharing = false;
this.isHidden = false;
this.lastProfileFetch = 0;
this.systemContact = true;
this.isSelf = false;

View File

@@ -198,6 +198,22 @@ public class RecipientUtil {
StorageSyncHelper.scheduleSyncForDataChange();
}
@WorkerThread
public static boolean isRecipientHidden(long threadId) {
if (threadId < 0) {
return false;
}
ThreadTable threadTable = SignalDatabase.threads();
Recipient threadRecipient = threadTable.getRecipientForThreadId(threadId);
if (threadRecipient == null) {
return false;
}
return threadRecipient.isHidden();
}
/**
* If true, the new message request UI does not need to be shown, and it's safe to send read
* receipts.
@@ -281,7 +297,8 @@ public class RecipientUtil {
threadRecipient.isProfileSharing() ||
threadRecipient.isSystemContact() ||
!threadRecipient.isRegistered() ||
threadRecipient.isForceSmsSelection();
threadRecipient.isForceSmsSelection() ||
threadRecipient.isHidden();
}
/**
@@ -331,9 +348,11 @@ public class RecipientUtil {
threadRecipient.isSystemContact() ||
threadRecipient.isForceSmsSelection() ||
!threadRecipient.isRegistered() ||
hasSentMessageInThread(threadId) ||
noSecureMessagesAndNoCallsInThread(threadId) ||
isPreMessageRequestThread(threadId);
(!threadRecipient.isHidden() && (
hasSentMessageInThread(threadId) ||
noSecureMessagesAndNoCallsInThread(threadId) ||
isPreMessageRequestThread(threadId))
);
}
@WorkerThread