Renamed group terminology

This commit is contained in:
SessionHero01
2024-10-25 10:26:18 +11:00
parent 122838d9ae
commit e89cbdf029
49 changed files with 210 additions and 242 deletions

View File

@@ -41,7 +41,7 @@ sealed class Destination {
address.isContact -> {
Contact(address.contactIdentifier())
}
address.isLegacyClosedGroup -> {
address.isLegacyGroup -> {
val groupID = address.toGroupString()
val groupPublicKey = GroupUtil.doubleDecodeGroupID(groupID).toHexString()
LegacyClosedGroup(groupPublicKey)
@@ -61,7 +61,7 @@ sealed class Destination {
groupInboxId.last()
)
}
address.isClosedGroupV2 -> {
address.isGroupV2 -> {
ClosedGroup(address.serialize())
}
else -> {

View File

@@ -407,7 +407,7 @@ fun MessageReceiver.handleVisibleMessage(
)
}
// Handle group invite response if new closed group
if (threadRecipient?.isClosedGroupV2Recipient == true) {
if (threadRecipient?.isGroupV2Recipient == true) {
GlobalScope.launch {
try {
MessagingModuleConfiguration.shared.groupManagerV2
@@ -464,7 +464,7 @@ fun MessageReceiver.handleVisibleMessage(
// Cancel any typing indicators if needed
cancelTypingIndicatorsIfNeeded(message.sender!!)
// Parse reaction if needed
val threadIsGroup = threadRecipient?.isGroupRecipient == true
val threadIsGroup = threadRecipient?.isGroupOrCommunityRecipient == true
message.reaction?.let { reaction ->
if (reaction.react == true) {
reaction.serverId = message.openGroupServerMessageID?.toString() ?: message.serverHash.orEmpty()

View File

@@ -18,11 +18,9 @@ class Address private constructor(address: String) : Parcelable, Comparable<Addr
constructor(`in`: Parcel) : this(`in`.readString()!!) {}
val isGroup: Boolean
get() = GroupUtil.isEncodedGroup(address) || address.startsWith(IdPrefix.GROUP.value)
val isLegacyClosedGroup: Boolean
val isLegacyGroup: Boolean
get() = GroupUtil.isLegacyClosedGroup(address)
val isClosedGroupV2: Boolean
val isGroupV2: Boolean
get() = address.startsWith(IdPrefix.GROUP.value)
val isCommunity: Boolean
get() = GroupUtil.isCommunity(address)
@@ -30,19 +28,23 @@ class Address private constructor(address: String) : Parcelable, Comparable<Addr
get() = GroupUtil.isCommunityInbox(address)
val isCommunityOutbox: Boolean
get() = address.startsWith(IdPrefix.BLINDED.value) || address.startsWith(IdPrefix.BLINDEDV2.value)
val isGroupOrCommunity: Boolean
get() = isGroup || isCommunity
val isGroup: Boolean
get() = isLegacyGroup || isGroupV2
val isContact: Boolean
get() = !(isGroup || isCommunityInbox)
get() = !(isGroupOrCommunity || isCommunityInbox)
fun contactIdentifier(): String {
if (!isContact && !isCommunity) {
if (isGroup) throw AssertionError("Not e164, is group")
if (isGroupOrCommunity) throw AssertionError("Not e164, is group")
throw AssertionError("Not e164, unknown")
}
return address
}
fun toGroupString(): String {
if (!isGroup) throw AssertionError("Not group")
if (!isGroupOrCommunity) throw AssertionError("Not group")
return address
}

View File

@@ -24,9 +24,9 @@ class GroupRecord(
val isOpenGroup: Boolean
get() = Address.fromSerialized(encodedId).isCommunity
val isLegacyClosedGroup: Boolean
get() = Address.fromSerialized(encodedId).isLegacyClosedGroup
get() = Address.fromSerialized(encodedId).isLegacyGroup
val isClosedGroupV2: Boolean
get() = Address.fromSerialized(encodedId).isClosedGroupV2
get() = Address.fromSerialized(encodedId).isGroupV2
init {
if (!TextUtils.isEmpty(members)) {

View File

@@ -8,7 +8,7 @@ fun Recipient.getType(): MessageType =
when{
isCommunityRecipient -> MessageType.COMMUNITY
isLocalNumber -> MessageType.NOTE_TO_SELF
isLegacyClosedGroupRecipient -> MessageType.LEGACY_GROUP
isClosedGroupV2Recipient -> MessageType.GROUPS_V2
isLegacyGroupRecipient -> MessageType.LEGACY_GROUP
isGroupV2Recipient -> MessageType.GROUPS_V2
else -> MessageType.ONE_ON_ONE
}

View File

@@ -17,12 +17,9 @@
*/
package org.session.libsession.utilities.recipients;
import static org.session.libsession.utilities.IdUtilKt.truncateIdForDisplay;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -326,7 +323,7 @@ public class Recipient implements RecipientModifiedListener {
public synchronized @Nullable String getName() {
StorageProtocol storage = MessagingModuleConfiguration.getShared().getStorage();
String accountID = this.address.toString();
if (isGroupRecipient()) {
if (isGroupOrCommunityRecipient()) {
if (this.name == null) {
List<String> names = new LinkedList<>();
for (Recipient recipient : participants) {
@@ -336,7 +333,7 @@ public class Recipient implements RecipientModifiedListener {
} else {
return this.name;
}
} else if (isOpenGroupInboxRecipient()){
} else if (isCommunityInboxRecipient()){
String inboxID = GroupUtil.getDecodedOpenGroupInboxAccountId(accountID);
Contact contact = storage.getContactWithAccountID(inboxID);
if (contact == null) return accountID;
@@ -374,7 +371,7 @@ public class Recipient implements RecipientModifiedListener {
}
public synchronized @NonNull MaterialColor getColor() {
if (isGroupRecipient()) return MaterialColor.GROUP;
if (isGroupOrCommunityRecipient()) return MaterialColor.GROUP;
else if (color != null) return color;
else if (name != null) return ContactColors.generateFor(name);
else return ContactColors.UNKNOWN_COLOR;
@@ -458,8 +455,8 @@ public class Recipient implements RecipientModifiedListener {
notifyListeners();
}
public boolean isGroupRecipient() {
return address.isGroup();
public boolean isGroupOrCommunityRecipient() {
return address.isGroupOrCommunity();
}
public boolean isContactRecipient() {
@@ -471,26 +468,26 @@ public class Recipient implements RecipientModifiedListener {
return address.isCommunity();
}
public boolean isOpenGroupOutboxRecipient() {
public boolean isCommunityOutboxRecipient() {
return address.isCommunityOutbox();
}
public boolean isOpenGroupInboxRecipient() {
public boolean isCommunityInboxRecipient() {
return address.isCommunityInbox();
}
public boolean isLegacyClosedGroupRecipient() {
return address.isLegacyClosedGroup();
public boolean isLegacyGroupRecipient() {
return address.isLegacyGroup();
}
public boolean isClosedGroupV2Recipient() {
return address.isClosedGroupV2();
public boolean isGroupV2Recipient() {
return address.isGroupV2();
}
@Deprecated
public boolean isPushGroupRecipient() {
return address.isGroup();
return address.isGroupOrCommunity();
}
public @NonNull synchronized List<Recipient> getParticipants() {
@@ -538,7 +535,7 @@ public class Recipient implements RecipientModifiedListener {
public synchronized @Nullable ContactPhoto getContactPhoto() {
if (isLocalNumber) return new ProfileContactPhoto(address, String.valueOf(TextSecurePreferences.getProfileAvatarId(context)));
else if (isGroupRecipient() && groupAvatarId != null) return new GroupRecordContactPhoto(address, groupAvatarId);
else if (isGroupOrCommunityRecipient() && groupAvatarId != null) return new GroupRecordContactPhoto(address, groupAvatarId);
else if (systemContactPhoto != null) return new SystemContactPhoto(address, systemContactPhoto, 0);
else if (profileAvatar != null) return new ProfileContactPhoto(address, profileAvatar);
else return null;
@@ -813,7 +810,7 @@ public class Recipient implements RecipientModifiedListener {
}
public synchronized boolean showCallMenu() {
return !isGroupRecipient() && hasApprovedMe();
return !isGroupOrCommunityRecipient() && hasApprovedMe();
}
@Override

View File

@@ -84,9 +84,9 @@ class RecipientProvider {
@NonNull Optional<RecipientSettings> settings,
@NonNull Optional<GroupRecord> groupRecord)
{
if (address.isGroup() && settings.isPresent() && groupRecord.isPresent()) {
if (address.isGroupOrCommunity() && settings.isPresent() && groupRecord.isPresent()) {
return Optional.of(getGroupRecipientDetails(context, address, groupRecord, settings, true));
} else if (!address.isGroup() && settings.isPresent()) {
} else if (!address.isGroupOrCommunity() && settings.isPresent()) {
boolean isLocalNumber = address.serialize().equals(TextSecurePreferences.getLocalNumber(context));
return Optional.of(new RecipientDetails(null, null, !TextUtils.isEmpty(settings.get().getSystemDisplayName()), isLocalNumber, settings.get(), null));
}
@@ -104,7 +104,7 @@ class RecipientProvider {
}
private @NonNull RecipientDetails getRecipientDetailsSync(Context context, @NonNull Address address, Optional<RecipientSettings> settings, Optional<GroupRecord> groupRecord, boolean nestedAsynchronous) {
if (address.isGroup() && !address.isClosedGroupV2()) return getGroupRecipientDetails(context, address, groupRecord, settings, nestedAsynchronous);
if (address.isGroupOrCommunity() && !address.isGroupV2()) return getGroupRecipientDetails(context, address, groupRecord, settings, nestedAsynchronous);
else return getIndividualRecipientDetails(context, address, settings);
}