mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 18:00:02 +01:00
Remove concept of 'highTrust' that is no longer necessary.
This commit is contained in:
committed by
Alex Hart
parent
d17896ea09
commit
04cf8676cc
@@ -50,7 +50,7 @@ class AvatarPickerRepository(context: Context) {
|
||||
}
|
||||
|
||||
fun getAvatarForGroup(groupId: GroupId): Single<Avatar> = Single.fromCallable {
|
||||
val recipient = Recipient.externalGroupExact(applicationContext, groupId)
|
||||
val recipient = Recipient.externalGroupExact(groupId)
|
||||
|
||||
if (AvatarHelper.hasAvatar(applicationContext, recipient.id)) {
|
||||
try {
|
||||
@@ -161,7 +161,7 @@ class AvatarPickerRepository(context: Context) {
|
||||
}
|
||||
|
||||
fun getDefaultAvatarForGroup(groupId: GroupId): Avatar {
|
||||
val recipient = Recipient.externalGroupExact(applicationContext, groupId)
|
||||
val recipient = Recipient.externalGroupExact(groupId)
|
||||
|
||||
return getDefaultAvatarForGroup(recipient.avatarColor)
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ class ConversationSettingsRepository(
|
||||
|
||||
fun getThreadId(groupId: GroupId, consumer: (Long) -> Unit) {
|
||||
SignalExecutors.BOUNDED.execute {
|
||||
val recipientId = Recipient.externalGroupExact(context, groupId).id
|
||||
val recipientId = Recipient.externalGroupExact(groupId).id
|
||||
consumer(SignalDatabase.threads.getThreadIdIfExistsFor(recipientId))
|
||||
}
|
||||
}
|
||||
@@ -156,7 +156,7 @@ class ConversationSettingsRepository(
|
||||
|
||||
fun setMuteUntil(groupId: GroupId, until: Long) {
|
||||
SignalExecutors.BOUNDED.execute {
|
||||
val recipientId = Recipient.externalGroupExact(context, groupId).id
|
||||
val recipientId = Recipient.externalGroupExact(groupId).id
|
||||
SignalDatabase.recipients.setMuted(recipientId, until)
|
||||
}
|
||||
}
|
||||
@@ -181,14 +181,14 @@ class ConversationSettingsRepository(
|
||||
|
||||
fun block(groupId: GroupId) {
|
||||
SignalExecutors.BOUNDED.execute {
|
||||
val recipient = Recipient.externalGroupExact(context, groupId)
|
||||
val recipient = Recipient.externalGroupExact(groupId)
|
||||
RecipientUtil.block(context, recipient)
|
||||
}
|
||||
}
|
||||
|
||||
fun unblock(groupId: GroupId) {
|
||||
SignalExecutors.BOUNDED.execute {
|
||||
val recipient = Recipient.externalGroupExact(context, groupId)
|
||||
val recipient = Recipient.externalGroupExact(groupId)
|
||||
RecipientUtil.unblock(context, recipient)
|
||||
}
|
||||
}
|
||||
@@ -204,7 +204,7 @@ class ConversationSettingsRepository(
|
||||
|
||||
fun getExternalPossiblyMigratedGroupRecipientId(groupId: GroupId, consumer: (RecipientId) -> Unit) {
|
||||
SignalExecutors.BOUNDED.execute {
|
||||
consumer(Recipient.externalPossiblyMigratedGroup(context, groupId).id)
|
||||
consumer(Recipient.externalPossiblyMigratedGroup(groupId).id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -322,7 +322,7 @@ object ContactDiscovery {
|
||||
}
|
||||
|
||||
handle.setSystemContactInfo(
|
||||
Recipient.externalContact(context, realNumber).id,
|
||||
Recipient.externalContact(realNumber).id,
|
||||
profileName,
|
||||
phoneDetails.displayName,
|
||||
phoneDetails.photoUri,
|
||||
|
||||
@@ -139,7 +139,7 @@ public class ConversationDataSource implements PagedDataSource<MessageId, Conver
|
||||
stopwatch.split("attachment-models");
|
||||
|
||||
for (ServiceId serviceId : referencedIds) {
|
||||
Recipient.resolved(RecipientId.from(serviceId, null));
|
||||
Recipient.resolved(RecipientId.from(serviceId));
|
||||
}
|
||||
stopwatch.split("recipient-resolves");
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ abstract class ConversationListDataSource implements PagedDataSource<Long, Conve
|
||||
needsResolve.add(record.getRecipient().getId());
|
||||
} else if (SmsDatabase.Types.isGroupUpdate(record.getType())) {
|
||||
UpdateDescription description = MessageRecord.getGv2ChangeDescription(ApplicationDependencies.getApplication(), record.getBody(), null);
|
||||
needsResolve.addAll(description.getMentioned().stream().map(sid -> RecipientId.from(sid, null)).collect(Collectors.toList()));
|
||||
needsResolve.addAll(description.getMentioned().stream().map(RecipientId::from).collect(Collectors.toList()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ public class SignalBaseIdentityKeyStore {
|
||||
public @NonNull SaveResult saveIdentity(SignalProtocolAddress address, IdentityKey identityKey, boolean nonBlockingApproval) {
|
||||
synchronized (LOCK) {
|
||||
IdentityStoreRecord identityRecord = cache.get(address.getName());
|
||||
RecipientId recipientId = RecipientId.fromExternalPush(address.getName());
|
||||
RecipientId recipientId = RecipientId.fromSidOrE164(address.getName());
|
||||
|
||||
if (identityRecord == null) {
|
||||
Log.i(TAG, "Saving new identity for " + address);
|
||||
|
||||
@@ -231,7 +231,7 @@ public class GroupDatabase extends Database {
|
||||
|
||||
databaseHelper.getSignalWritableDatabase().update(TABLE_NAME, values, GROUP_ID + " = ?", SqlUtil.buildArgs(id));
|
||||
|
||||
Recipient.live(Recipient.externalGroupExact(context, id).getId()).refresh();
|
||||
Recipient.live(Recipient.externalGroupExact(id).getId()).refresh();
|
||||
}
|
||||
|
||||
Optional<GroupRecord> getGroup(Cursor cursor) {
|
||||
@@ -915,7 +915,7 @@ public class GroupDatabase extends Database {
|
||||
if (UuidUtil.UNKNOWN_UUID.equals(uuid)) {
|
||||
Log.w(TAG, "Seen unknown UUID in members list");
|
||||
} else {
|
||||
RecipientId id = RecipientId.from(ServiceId.from(uuid), null);
|
||||
RecipientId id = RecipientId.from(ServiceId.from(uuid));
|
||||
Optional<RecipientId> remapped = RemappedRecords.getInstance().getRecipient(id);
|
||||
|
||||
if (remapped.isPresent()) {
|
||||
@@ -1373,7 +1373,7 @@ public class GroupDatabase extends Database {
|
||||
if (UuidUtil.UNKNOWN_UUID.equals(uuid)) {
|
||||
unknownMembers++;
|
||||
} else if (includeSelf || !selfUuid.equals(uuid)) {
|
||||
recipients.add(RecipientId.from(ServiceId.from(uuid), null));
|
||||
recipients.add(RecipientId.from(ServiceId.from(uuid)));
|
||||
}
|
||||
}
|
||||
if (memberSet.includePending) {
|
||||
@@ -1381,7 +1381,7 @@ public class GroupDatabase extends Database {
|
||||
if (UuidUtil.UNKNOWN_UUID.equals(uuid)) {
|
||||
unknownPending++;
|
||||
} else if (includeSelf || !selfUuid.equals(uuid)) {
|
||||
recipients.add(RecipientId.from(ServiceId.from(uuid), null));
|
||||
recipients.add(RecipientId.from(ServiceId.from(uuid)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -250,7 +250,7 @@ public class IdentityDatabase extends Database {
|
||||
boolean firstUse = CursorUtil.requireBoolean(cursor, FIRST_USE);
|
||||
IdentityKey identity = new IdentityKey(Base64.decode(serializedIdentity), 0);
|
||||
|
||||
return new IdentityRecord(RecipientId.fromExternalPush(addressName), identity, VerifiedStatus.forState(verifiedStatus), firstUse, timestamp, nonblockingApproval);
|
||||
return new IdentityRecord(RecipientId.fromSidOrE164(addressName), identity, VerifiedStatus.forState(verifiedStatus), firstUse, timestamp, nonblockingApproval);
|
||||
}
|
||||
|
||||
private void saveIdentityInternal(@NonNull String addressName,
|
||||
|
||||
@@ -121,7 +121,7 @@ public final class MentionUtil {
|
||||
return Stream.of(BodyRangeList.parseFrom(data).getRangesList())
|
||||
.filter(bodyRange -> bodyRange.getAssociatedValueCase() == BodyRangeList.BodyRange.AssociatedValueCase.MENTIONUUID)
|
||||
.map(mention -> {
|
||||
RecipientId id = Recipient.externalPush(ServiceId.parseOrThrow(mention.getMentionUuid()), null, false).getId();
|
||||
RecipientId id = Recipient.externalPush(ServiceId.parseOrThrow(mention.getMentionUuid())).getId();
|
||||
return new Mention(id, mention.getStart(), mention.getLength());
|
||||
})
|
||||
.toList();
|
||||
|
||||
@@ -2162,7 +2162,7 @@ public class MmsDatabase extends MessageDatabase {
|
||||
MessageGroupContext.GroupV2Properties groupV2Properties = outgoingGroupUpdateMessage.requireGroupV2Properties();
|
||||
members.addAll(Stream.of(groupV2Properties.getAllActivePendingAndRemovedMembers())
|
||||
.distinct()
|
||||
.map(uuid -> RecipientId.from(ServiceId.from(uuid), null))
|
||||
.map(uuid -> RecipientId.from(ServiceId.from(uuid)))
|
||||
.toList());
|
||||
members.remove(Recipient.self().getId());
|
||||
} else {
|
||||
|
||||
@@ -419,11 +419,12 @@ open class RecipientDatabase(context: Context, databaseHelper: SignalDatabase) :
|
||||
return getByColumn(USERNAME, username)
|
||||
}
|
||||
|
||||
fun getAndPossiblyMerge(serviceId: ServiceId?, e164: String?, highTrust: Boolean): RecipientId {
|
||||
return getAndPossiblyMerge(serviceId, e164, highTrust, false)
|
||||
fun getAndPossiblyMerge(serviceId: ServiceId?, e164: String?): RecipientId {
|
||||
return getAndPossiblyMerge(serviceId, e164, changeSelf = false)
|
||||
}
|
||||
|
||||
fun getAndPossiblyMerge(serviceId: ServiceId?, e164: String?, highTrust: Boolean, changeSelf: Boolean): RecipientId {
|
||||
@VisibleForTesting
|
||||
fun getAndPossiblyMerge(serviceId: ServiceId?, e164: String?, changeSelf: Boolean): RecipientId {
|
||||
require(!(serviceId == null && e164 == null)) { "Must provide an ACI or E164!" }
|
||||
|
||||
val db = writableDatabase
|
||||
@@ -435,7 +436,7 @@ open class RecipientDatabase(context: Context, databaseHelper: SignalDatabase) :
|
||||
|
||||
db.beginTransaction()
|
||||
try {
|
||||
val fetch: RecipientFetch = fetchRecipient(serviceId, e164, highTrust, changeSelf)
|
||||
val fetch: RecipientFetch = fetchRecipient(serviceId, e164, changeSelf = changeSelf)
|
||||
|
||||
if (fetch.logBundle != null) {
|
||||
Log.w(TAG, fetch.toString())
|
||||
@@ -537,7 +538,7 @@ open class RecipientDatabase(context: Context, databaseHelper: SignalDatabase) :
|
||||
return serviceIdToProfileKey
|
||||
}
|
||||
|
||||
private fun fetchRecipient(serviceId: ServiceId?, e164: String?, highTrust: Boolean, changeSelf: Boolean): RecipientFetch {
|
||||
private fun fetchRecipient(serviceId: ServiceId?, e164: String?, changeSelf: Boolean): RecipientFetch {
|
||||
val byE164 = e164?.let { getByE164(it) } ?: Optional.empty()
|
||||
val byAci = serviceId?.let { getByServiceId(it) } ?: Optional.empty()
|
||||
|
||||
@@ -548,20 +549,20 @@ open class RecipientDatabase(context: Context, databaseHelper: SignalDatabase) :
|
||||
)
|
||||
|
||||
if (byAci.isPresent && byE164.isPresent && byAci.get() == byE164.get()) {
|
||||
return RecipientFetch.Match(byAci.get(), null)
|
||||
return RecipientFetch.Match(byAci.get(), logs.label("L0"))
|
||||
}
|
||||
|
||||
if (byAci.isPresent && byE164.isAbsent()) {
|
||||
val aciRecord: RecipientRecord = getRecord(byAci.get())
|
||||
logs = logs.copy(bySid = aciRecord.toLogDetails())
|
||||
|
||||
if (highTrust && e164 != null && (changeSelf || serviceId != SignalStore.account().aci)) {
|
||||
if (e164 != null && (changeSelf || serviceId != SignalStore.account().aci)) {
|
||||
val changedNumber: RecipientId? = if (aciRecord.e164 != null && aciRecord.e164 != e164) aciRecord.id else null
|
||||
return RecipientFetch.MatchAndUpdateE164(byAci.get(), e164, changedNumber, logs.label("L1"))
|
||||
} else if (e164 == null) {
|
||||
return RecipientFetch.Match(byAci.get(), null)
|
||||
} else {
|
||||
return RecipientFetch.Match(byAci.get(), logs.label("L2"))
|
||||
} else {
|
||||
return RecipientFetch.Match(byAci.get(), logs.label("L3"))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -569,25 +570,19 @@ open class RecipientDatabase(context: Context, databaseHelper: SignalDatabase) :
|
||||
val e164Record: RecipientRecord = getRecord(byE164.get())
|
||||
logs = logs.copy(byE164 = e164Record.toLogDetails())
|
||||
|
||||
if (highTrust && serviceId != null && e164Record.serviceId == null) {
|
||||
return RecipientFetch.MatchAndUpdateAci(byE164.get(), serviceId, logs.label("L3"))
|
||||
} else if (highTrust && serviceId != null && e164Record.serviceId != SignalStore.account().aci) {
|
||||
return RecipientFetch.InsertAndReassignE164(serviceId, e164, byE164.get(), logs.label("L4"))
|
||||
if (serviceId != null && e164Record.serviceId == null) {
|
||||
return RecipientFetch.MatchAndUpdateAci(byE164.get(), serviceId, logs.label("L4"))
|
||||
} else if (serviceId != null && e164Record.serviceId != SignalStore.account().aci) {
|
||||
return RecipientFetch.InsertAndReassignE164(serviceId, e164, byE164.get(), logs.label("L5"))
|
||||
} else if (serviceId != null) {
|
||||
return RecipientFetch.Insert(serviceId, null, logs.label("L5"))
|
||||
return RecipientFetch.Insert(serviceId, null, logs.label("L6"))
|
||||
} else {
|
||||
return RecipientFetch.Match(byE164.get(), null)
|
||||
return RecipientFetch.Match(byE164.get(), logs.label("L7"))
|
||||
}
|
||||
}
|
||||
|
||||
if (byAci.isAbsent() && byE164.isAbsent()) {
|
||||
if (highTrust) {
|
||||
return RecipientFetch.Insert(serviceId, e164, logs.label("L6"))
|
||||
} else if (serviceId != null) {
|
||||
return RecipientFetch.Insert(serviceId, null, logs.label("L7"))
|
||||
} else {
|
||||
return RecipientFetch.Insert(null, e164, logs.label("L8"))
|
||||
}
|
||||
return RecipientFetch.Insert(serviceId, e164, logs.label("L8"))
|
||||
}
|
||||
|
||||
require(byAci.isPresent && byE164.isPresent && byAci.get() != byE164.get()) { "Assumed conditions at this point." }
|
||||
@@ -598,18 +593,14 @@ open class RecipientDatabase(context: Context, databaseHelper: SignalDatabase) :
|
||||
logs = logs.copy(bySid = aciRecord.toLogDetails(), byE164 = e164Record.toLogDetails())
|
||||
|
||||
if (e164Record.serviceId == null) {
|
||||
if (highTrust) {
|
||||
val changedNumber: RecipientId? = if (aciRecord.e164 != null) aciRecord.id else null
|
||||
return RecipientFetch.MatchAndMerge(sidId = byAci.get(), e164Id = byE164.get(), changedNumber = changedNumber, logs.label("L9"))
|
||||
} else {
|
||||
return RecipientFetch.Match(byAci.get(), logs.label("L10"))
|
||||
}
|
||||
val changedNumber: RecipientId? = if (aciRecord.e164 != null) aciRecord.id else null
|
||||
return RecipientFetch.MatchAndMerge(sidId = byAci.get(), e164Id = byE164.get(), changedNumber = changedNumber, logs.label("L9"))
|
||||
} else {
|
||||
if (highTrust && e164Record.serviceId != SignalStore.account().aci) {
|
||||
if (e164Record.serviceId != SignalStore.account().aci) {
|
||||
val changedNumber: RecipientId? = if (aciRecord.e164 != null) aciRecord.id else null
|
||||
return RecipientFetch.MatchAndReassignE164(id = byAci.get(), e164Id = byE164.get(), e164 = e164!!, changedNumber = changedNumber, logs.label("L11"))
|
||||
return RecipientFetch.MatchAndReassignE164(id = byAci.get(), e164Id = byE164.get(), e164 = e164!!, changedNumber = changedNumber, logs.label("L10"))
|
||||
} else {
|
||||
return RecipientFetch.Match(byAci.get(), logs.label("L12"))
|
||||
return RecipientFetch.Match(byAci.get(), logs.label("L11"))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -868,7 +859,7 @@ open class RecipientDatabase(context: Context, databaseHelper: SignalDatabase) :
|
||||
val recipientId: RecipientId
|
||||
if (id < 0) {
|
||||
Log.w(TAG, "[applyStorageSyncContactInsert] Failed to insert. Possibly merging.")
|
||||
recipientId = getAndPossiblyMerge(if (insert.address.hasValidServiceId()) insert.address.serviceId else null, insert.address.number.orElse(null), true)
|
||||
recipientId = getAndPossiblyMerge(if (insert.address.hasValidServiceId()) insert.address.serviceId else null, insert.address.number.orElse(null))
|
||||
db.update(TABLE_NAME, values, ID_WHERE, SqlUtil.buildArgs(recipientId))
|
||||
} else {
|
||||
recipientId = RecipientId.from(id)
|
||||
@@ -905,7 +896,7 @@ open class RecipientDatabase(context: Context, databaseHelper: SignalDatabase) :
|
||||
var recipientId = getByColumn(STORAGE_SERVICE_ID, Base64.encodeBytes(update.old.id.raw)).get()
|
||||
|
||||
Log.w(TAG, "[applyStorageSyncContactUpdate] Found user $recipientId. Possibly merging.")
|
||||
recipientId = getAndPossiblyMerge(if (update.new.address.hasValidServiceId()) update.new.address.serviceId else null, update.new.address.number.orElse(null), true)
|
||||
recipientId = getAndPossiblyMerge(if (update.new.address.hasValidServiceId()) update.new.address.serviceId else null, update.new.address.number.orElse(null))
|
||||
|
||||
Log.w(TAG, "[applyStorageSyncContactUpdate] Merged into $recipientId")
|
||||
db.update(TABLE_NAME, values, ID_WHERE, SqlUtil.buildArgs(recipientId))
|
||||
@@ -960,7 +951,7 @@ open class RecipientDatabase(context: Context, databaseHelper: SignalDatabase) :
|
||||
throw AssertionError("Had an update, but it didn't match any rows!")
|
||||
}
|
||||
|
||||
val recipient = Recipient.externalGroupExact(context, GroupId.v1orThrow(update.old.groupId))
|
||||
val recipient = Recipient.externalGroupExact(GroupId.v1orThrow(update.old.groupId))
|
||||
threads.applyStorageSyncUpdate(recipient.id, update.new)
|
||||
recipient.live().refresh()
|
||||
}
|
||||
@@ -971,7 +962,7 @@ open class RecipientDatabase(context: Context, databaseHelper: SignalDatabase) :
|
||||
val values = getValuesForStorageGroupV2(insert, true)
|
||||
|
||||
writableDatabase.insertOrThrow(TABLE_NAME, null, values)
|
||||
val recipient = Recipient.externalGroupExact(context, groupId)
|
||||
val recipient = Recipient.externalGroupExact(groupId)
|
||||
|
||||
Log.i(TAG, "Creating restore placeholder for $groupId")
|
||||
groups.create(
|
||||
@@ -1001,7 +992,7 @@ open class RecipientDatabase(context: Context, databaseHelper: SignalDatabase) :
|
||||
}
|
||||
|
||||
val masterKey = update.old.masterKeyOrThrow
|
||||
val recipient = Recipient.externalGroupExact(context, GroupId.v2(masterKey))
|
||||
val recipient = Recipient.externalGroupExact(GroupId.v2(masterKey))
|
||||
|
||||
updateExtras(recipient.id) {
|
||||
it.setHideStory(update.new.shouldHideStory())
|
||||
@@ -1149,7 +1140,7 @@ open class RecipientDatabase(context: Context, databaseHelper: SignalDatabase) :
|
||||
}
|
||||
|
||||
for (id in groups.allGroupV2Ids) {
|
||||
val recipient = Recipient.externalGroupExact(context, id!!)
|
||||
val recipient = Recipient.externalGroupExact(id!!)
|
||||
val recipientId = recipient.id
|
||||
val existing: RecipientRecord = getRecordForSync(recipientId) ?: throw AssertionError()
|
||||
val key = existing.storageId ?: throw AssertionError()
|
||||
@@ -1909,7 +1900,7 @@ open class RecipientDatabase(context: Context, databaseHelper: SignalDatabase) :
|
||||
Log.w(TAG, "[setPhoneNumber] Hit a conflict when trying to update $id. Possibly merging.")
|
||||
|
||||
val existing: RecipientRecord = getRecord(id)
|
||||
val newId = getAndPossiblyMerge(existing.serviceId, e164, true)
|
||||
val newId = getAndPossiblyMerge(existing.serviceId, e164)
|
||||
Log.w(TAG, "[setPhoneNumber] Resulting id: $newId")
|
||||
|
||||
db.setTransactionSuccessful()
|
||||
@@ -1961,7 +1952,7 @@ open class RecipientDatabase(context: Context, databaseHelper: SignalDatabase) :
|
||||
db.beginTransaction()
|
||||
try {
|
||||
val id = Recipient.self().id
|
||||
val newId = getAndPossiblyMerge(SignalStore.account().requireAci(), e164, highTrust = true, changeSelf = true)
|
||||
val newId = getAndPossiblyMerge(SignalStore.account().requireAci(), e164, changeSelf = true)
|
||||
|
||||
if (id == newId) {
|
||||
Log.i(TAG, "[updateSelfPhone] Phone updated for self")
|
||||
@@ -2044,7 +2035,7 @@ open class RecipientDatabase(context: Context, databaseHelper: SignalDatabase) :
|
||||
Log.w(TAG, "[markRegistered] Hit a conflict when trying to update $id. Possibly merging.")
|
||||
|
||||
val existing = getRecord(id)
|
||||
val newId = getAndPossiblyMerge(serviceId, existing.e164, true)
|
||||
val newId = getAndPossiblyMerge(serviceId, existing.e164)
|
||||
Log.w(TAG, "[markRegistered] Merged into $newId")
|
||||
|
||||
db.setTransactionSuccessful()
|
||||
@@ -2099,7 +2090,7 @@ open class RecipientDatabase(context: Context, databaseHelper: SignalDatabase) :
|
||||
} catch (e: SQLiteConstraintException) {
|
||||
Log.w(TAG, "[bulkUpdateRegisteredStatus] Hit a conflict when trying to update $recipientId. Possibly merging.")
|
||||
val e164 = getRecord(recipientId).e164
|
||||
val newId = getAndPossiblyMerge(aci, e164, true)
|
||||
val newId = getAndPossiblyMerge(aci, e164)
|
||||
Log.w(TAG, "[bulkUpdateRegisteredStatus] Merged into $newId")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1254,14 +1254,14 @@ public class ThreadDatabase extends Database {
|
||||
pinnedRecipient = Recipient.externalPush(pinned.getContact().get());
|
||||
} else if (pinned.getGroupV1Id().isPresent()) {
|
||||
try {
|
||||
pinnedRecipient = Recipient.externalGroupExact(context, GroupId.v1(pinned.getGroupV1Id().get()));
|
||||
pinnedRecipient = Recipient.externalGroupExact(GroupId.v1(pinned.getGroupV1Id().get()));
|
||||
} catch (BadGroupIdException e) {
|
||||
Log.w(TAG, "Failed to parse pinned groupV1 ID!", e);
|
||||
pinnedRecipient = null;
|
||||
}
|
||||
} else if (pinned.getGroupV2MasterKey().isPresent()) {
|
||||
try {
|
||||
pinnedRecipient = Recipient.externalGroupExact(context, GroupId.v2(new GroupMasterKey(pinned.getGroupV2MasterKey().get())));
|
||||
pinnedRecipient = Recipient.externalGroupExact(GroupId.v2(new GroupMasterKey(pinned.getGroupV2MasterKey().get())));
|
||||
} catch (InvalidInputException e) {
|
||||
Log.w(TAG, "Failed to parse pinned groupV2 master key!", e);
|
||||
pinnedRecipient = null;
|
||||
@@ -1524,7 +1524,7 @@ public class ThreadDatabase extends Database {
|
||||
if (threadRecipient.isPushV2Group()) {
|
||||
MessageRecord.InviteAddState inviteAddState = record.getGv2AddInviteState();
|
||||
if (inviteAddState != null) {
|
||||
RecipientId from = RecipientId.from(ServiceId.from(inviteAddState.getAddedOrInvitedBy()), null);
|
||||
RecipientId from = RecipientId.from(ServiceId.from(inviteAddState.getAddedOrInvitedBy()));
|
||||
if (inviteAddState.isInvited()) {
|
||||
Log.i(TAG, "GV2 invite message request from " + from);
|
||||
return Extra.forGroupV2invite(from, individualRecipientId);
|
||||
|
||||
@@ -99,7 +99,7 @@ public class GroupCallUpdateMessageFactory implements UpdateDescription.Spannabl
|
||||
return context.getString(R.string.MessageRecord_unknown);
|
||||
}
|
||||
|
||||
Recipient recipient = Recipient.resolved(RecipientId.from(serviceId, null));
|
||||
Recipient recipient = Recipient.resolved(RecipientId.from(serviceId));
|
||||
|
||||
if (recipient.isSelf()) {
|
||||
return context.getString(R.string.MessageRecord_you);
|
||||
|
||||
@@ -779,7 +779,7 @@ final class GroupsV2UpdateMessageProducer {
|
||||
@DrawableRes int iconResource)
|
||||
{
|
||||
ServiceId serviceId = ServiceId.fromByteStringOrUnknown(uuid1Bytes);
|
||||
RecipientId recipientId = RecipientId.from(serviceId, null);
|
||||
RecipientId recipientId = RecipientId.from(serviceId);
|
||||
|
||||
return UpdateDescription.mentioning(
|
||||
Collections.singletonList(serviceId),
|
||||
@@ -800,8 +800,8 @@ final class GroupsV2UpdateMessageProducer {
|
||||
ServiceId sid1 = ServiceId.fromByteStringOrUnknown(uuid1Bytes);
|
||||
ServiceId sid2 = ServiceId.fromByteStringOrUnknown(uuid2Bytes);
|
||||
|
||||
RecipientId recipientId1 = RecipientId.from(sid1, null);
|
||||
RecipientId recipientId2 = RecipientId.from(sid2, null);
|
||||
RecipientId recipientId1 = RecipientId.from(sid1);
|
||||
RecipientId recipientId2 = RecipientId.from(sid2);
|
||||
|
||||
return UpdateDescription.mentioning(
|
||||
Arrays.asList(sid1, sid2),
|
||||
@@ -821,7 +821,7 @@ final class GroupsV2UpdateMessageProducer {
|
||||
@DrawableRes int iconResource)
|
||||
{
|
||||
ServiceId serviceId = ServiceId.fromByteStringOrUnknown(uuid1Bytes);
|
||||
RecipientId recipientId = RecipientId.from(serviceId, null);
|
||||
RecipientId recipientId = RecipientId.from(serviceId);
|
||||
|
||||
return UpdateDescription.mentioning(
|
||||
Collections.singletonList(serviceId),
|
||||
@@ -842,7 +842,7 @@ final class GroupsV2UpdateMessageProducer {
|
||||
@DrawableRes int iconResource)
|
||||
{
|
||||
ServiceId serviceId = ServiceId.fromByteStringOrUnknown(uuid1Bytes);
|
||||
RecipientId recipientId = RecipientId.from(serviceId, null);
|
||||
RecipientId recipientId = RecipientId.from(serviceId);
|
||||
|
||||
return UpdateDescription.mentioning(
|
||||
Collections.singletonList(serviceId),
|
||||
|
||||
@@ -46,7 +46,7 @@ public final class LiveUpdateMessage {
|
||||
}
|
||||
|
||||
List<LiveData<Recipient>> allMentionedRecipients = Stream.of(updateDescription.getMentioned())
|
||||
.map(uuid -> Recipient.resolved(RecipientId.from(uuid, null)).live().getLiveData())
|
||||
.map(uuid -> Recipient.resolved(RecipientId.from(uuid)).live().getLiveData())
|
||||
.toList();
|
||||
|
||||
LiveData<?> mentionedRecipientChangeStream = allMentionedRecipients.isEmpty() ? LiveDataUtil.just(new Object())
|
||||
|
||||
@@ -196,7 +196,7 @@ final class GroupManagerV1 {
|
||||
static void updateGroupTimer(@NonNull Context context, @NonNull GroupId.V1 groupId, int expirationTime) {
|
||||
RecipientDatabase recipientDatabase = SignalDatabase.recipients();
|
||||
ThreadDatabase threadDatabase = SignalDatabase.threads();
|
||||
Recipient recipient = Recipient.externalGroupExact(context, groupId);
|
||||
Recipient recipient = Recipient.externalGroupExact(groupId);
|
||||
long threadId = threadDatabase.getOrCreateThreadIdFor(recipient);
|
||||
|
||||
recipientDatabase.setExpireMessages(recipient.getId(), expirationTime);
|
||||
|
||||
@@ -400,7 +400,7 @@ final class GroupManagerV2 {
|
||||
GroupManager.GroupActionResult groupActionResult = commitChangeWithConflictResolution(selfAci, change);
|
||||
|
||||
if (avatarChanged) {
|
||||
AvatarHelper.setAvatar(context, Recipient.externalGroupExact(context, groupId).getId(), avatarBytes != null ? new ByteArrayInputStream(avatarBytes) : null);
|
||||
AvatarHelper.setAvatar(context, Recipient.externalGroupExact(groupId).getId(), avatarBytes != null ? new ByteArrayInputStream(avatarBytes) : null);
|
||||
groupDatabase.onAvatarUpdated(groupId, avatarBytes != null);
|
||||
}
|
||||
|
||||
@@ -643,7 +643,7 @@ final class GroupManagerV2 {
|
||||
|
||||
if (GroupChangeUtil.changeIsEmpty(change.build())) {
|
||||
Log.i(TAG, "Change is empty after conflict resolution");
|
||||
Recipient groupRecipient = Recipient.externalGroupExact(context, groupId);
|
||||
Recipient groupRecipient = Recipient.externalGroupExact(groupId);
|
||||
long threadId = SignalDatabase.threads().getOrCreateThreadIdFor(groupRecipient);
|
||||
|
||||
return new GroupManager.GroupActionResult(groupRecipient, threadId, 0, Collections.emptyList());
|
||||
@@ -696,7 +696,7 @@ final class GroupManagerV2 {
|
||||
final DecryptedGroup decryptedGroupState;
|
||||
final DecryptedGroup previousGroupState;
|
||||
|
||||
if (!allowWhenBlocked && Recipient.externalGroupExact(context, groupId).isBlocked()) {
|
||||
if (!allowWhenBlocked && Recipient.externalGroupExact(groupId).isBlocked()) {
|
||||
throw new GroupChangeFailedException("Group is blocked.");
|
||||
}
|
||||
|
||||
@@ -1232,7 +1232,7 @@ final class GroupManagerV2 {
|
||||
boolean sendToMembers)
|
||||
{
|
||||
GroupId.V2 groupId = GroupId.v2(masterKey);
|
||||
Recipient groupRecipient = Recipient.externalGroupExact(context, groupId);
|
||||
Recipient groupRecipient = Recipient.externalGroupExact(groupId);
|
||||
DecryptedGroupV2Context decryptedGroupV2Context = GroupProtoUtil.createDecryptedGroupV2Context(masterKey, groupMutation, signedGroupChange);
|
||||
OutgoingGroupUpdateMessage outgoingMessage = new OutgoingGroupUpdateMessage(groupRecipient,
|
||||
decryptedGroupV2Context,
|
||||
@@ -1276,7 +1276,7 @@ final class GroupManagerV2 {
|
||||
|
||||
private static @NonNull List<RecipientId> getPendingMemberRecipientIds(@NonNull List<DecryptedPendingMember> newPendingMembersList) {
|
||||
return Stream.of(DecryptedGroupUtil.pendingToUuidList(newPendingMembersList))
|
||||
.map(uuid -> RecipientId.from(ServiceId.from(uuid), null))
|
||||
.map(uuid -> RecipientId.from(ServiceId.from(uuid)))
|
||||
.toList();
|
||||
}
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ public final class GroupProtoUtil {
|
||||
return Recipient.UNKNOWN;
|
||||
}
|
||||
|
||||
return Recipient.externalPush(serviceId, null, false);
|
||||
return Recipient.externalPush(serviceId);
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
@@ -102,7 +102,7 @@ public final class GroupProtoUtil {
|
||||
return RecipientId.UNKNOWN;
|
||||
}
|
||||
|
||||
return RecipientId.from(serviceId, null);
|
||||
return RecipientId.from(serviceId);
|
||||
}
|
||||
|
||||
public static boolean isMember(@NonNull UUID uuid, @NonNull List<DecryptedMember> membersList) {
|
||||
|
||||
@@ -107,11 +107,11 @@ public final class GroupV1MessageProcessor {
|
||||
database.create(id, group.getName().orElse(null), members,
|
||||
avatar != null && avatar.isPointer() ? avatar.asPointer() : null, null);
|
||||
|
||||
Recipient sender = Recipient.externalHighTrustPush(context, content.getSender());
|
||||
Recipient sender = Recipient.externalPush(content.getSender());
|
||||
|
||||
if (sender.isSystemContact() || sender.isProfileSharing()) {
|
||||
Log.i(TAG, "Auto-enabling profile sharing because 'adder' is trusted. contact: " + sender.isSystemContact() + ", profileSharing: " + sender.isProfileSharing());
|
||||
SignalDatabase.recipients().setProfileSharing(Recipient.externalGroupExact(context, id).getId(), true);
|
||||
SignalDatabase.recipients().setProfileSharing(Recipient.externalGroupExact(id).getId(), true);
|
||||
}
|
||||
|
||||
return storeMessage(context, content, group, builder.build(), outgoing);
|
||||
@@ -188,7 +188,7 @@ public final class GroupV1MessageProcessor {
|
||||
@NonNull SignalServiceContent content,
|
||||
@NonNull GroupRecord record)
|
||||
{
|
||||
Recipient sender = Recipient.externalHighTrustPush(context, content.getSender());
|
||||
Recipient sender = Recipient.externalPush(content.getSender());
|
||||
|
||||
if (record.getMembers().contains(sender.getId())) {
|
||||
ApplicationDependencies.getJobManager().add(new PushGroupUpdateJob(sender.getId(), record.getId()));
|
||||
@@ -210,7 +210,7 @@ public final class GroupV1MessageProcessor {
|
||||
GroupContext.Builder builder = createGroupContext(group);
|
||||
builder.setType(GroupContext.Type.QUIT);
|
||||
|
||||
RecipientId senderId = RecipientId.fromHighTrust(content.getSender());
|
||||
RecipientId senderId = RecipientId.from(content.getSender());
|
||||
|
||||
if (members.contains(senderId)) {
|
||||
database.remove(id, senderId);
|
||||
@@ -249,7 +249,7 @@ public final class GroupV1MessageProcessor {
|
||||
} else {
|
||||
MessageDatabase smsDatabase = SignalDatabase.sms();
|
||||
String body = Base64.encodeBytes(storage.toByteArray());
|
||||
IncomingTextMessage incoming = new IncomingTextMessage(Recipient.externalHighTrustPush(context, content.getSender()).getId(), content.getSenderDevice(), content.getTimestamp(), content.getServerReceivedTimestamp(), System.currentTimeMillis(), body, Optional.of(GroupId.v1orThrow(group.getGroupId())), 0, content.isNeedsReceipt(), content.getServerUuid());
|
||||
IncomingTextMessage incoming = new IncomingTextMessage(Recipient.externalPush(content.getSender()).getId(), content.getSenderDevice(), content.getTimestamp(), content.getServerReceivedTimestamp(), System.currentTimeMillis(), body, Optional.of(GroupId.v1orThrow(group.getGroupId())), 0, content.isNeedsReceipt(), content.getServerUuid());
|
||||
IncomingGroupUpdateMessage groupMessage = new IncomingGroupUpdateMessage(incoming, storage, body);
|
||||
|
||||
Optional<InsertResult> insertResult = smsDatabase.insertMessageInbox(groupMessage);
|
||||
|
||||
@@ -151,7 +151,7 @@ public final class GroupsV1MigrationUtil {
|
||||
return;
|
||||
}
|
||||
|
||||
Recipient recipient = Recipient.externalGroupExact(context, gv1Id);
|
||||
Recipient recipient = Recipient.externalGroupExact(gv1Id);
|
||||
long threadId = SignalDatabase.threads().getOrCreateThreadIdFor(recipient);
|
||||
|
||||
performLocalMigration(context, gv1Id, threadId, recipient);
|
||||
|
||||
@@ -84,7 +84,7 @@ public final class LiveGroup {
|
||||
this.groupLink = new MutableLiveData<>(GroupLinkUrlAndStatus.NONE);
|
||||
}
|
||||
|
||||
SignalExecutors.BOUNDED.execute(() -> liveRecipient.postValue(Recipient.externalGroupExact(context, groupId).live()));
|
||||
SignalExecutors.BOUNDED.execute(() -> liveRecipient.postValue(Recipient.externalGroupExact(groupId).live()));
|
||||
}
|
||||
|
||||
protected static LiveData<List<GroupMemberEntry.FullMember>> mapToFullMembers(@NonNull LiveData<GroupDatabase.GroupRecord> groupRecord) {
|
||||
@@ -110,7 +110,7 @@ public final class LiveGroup {
|
||||
|
||||
return Stream.of(requestingMembersList)
|
||||
.map(requestingMember -> {
|
||||
Recipient recipient = Recipient.externalPush(ServiceId.fromByteString(requestingMember.getUuid()), null, false);
|
||||
Recipient recipient = Recipient.externalPush(ServiceId.fromByteString(requestingMember.getUuid()));
|
||||
return new GroupMemberEntry.RequestingMember(recipient, selfAdmin);
|
||||
})
|
||||
.toList();
|
||||
|
||||
@@ -109,7 +109,7 @@ public final class ChooseNewAdminActivity extends PassphraseRequiredActivity {
|
||||
|
||||
private void handleUpdateAndLeaveResult(@NonNull GroupChangeResult updateResult) {
|
||||
if (updateResult.isSuccess()) {
|
||||
String title = Recipient.externalGroupExact(this, groupId).getDisplayName(this);
|
||||
String title = Recipient.externalGroupExact(groupId).getDisplayName(this);
|
||||
Toast.makeText(this, getString(R.string.ChooseNewAdminActivity_you_left, title), Toast.LENGTH_LONG).show();
|
||||
startActivity(MainActivity.clearTop(this));
|
||||
finish();
|
||||
|
||||
@@ -449,7 +449,7 @@ public class GroupsV2StateProcessor {
|
||||
return;
|
||||
}
|
||||
|
||||
Recipient groupRecipient = Recipient.externalGroupExact(context, groupId);
|
||||
Recipient groupRecipient = Recipient.externalGroupExact(groupId);
|
||||
UUID selfUuid = serviceId.uuid();
|
||||
|
||||
DecryptedGroup decryptedGroup = groupDatabase.requireGroup(groupId)
|
||||
@@ -587,7 +587,7 @@ public class GroupsV2StateProcessor {
|
||||
.filter(c -> c != null && c.getRevision() == revisionJoinedAt)
|
||||
.findFirst()
|
||||
.map(c -> Optional.ofNullable(UuidUtil.fromByteStringOrNull(c.getEditor()))
|
||||
.map(a -> Recipient.externalPush(ServiceId.fromByteStringOrNull(c.getEditor()), null, false)))
|
||||
.map(uuid -> Recipient.externalPush(ServiceId.from(uuid))))
|
||||
.orElse(Optional.empty());
|
||||
|
||||
if (addedByOptional.isPresent()) {
|
||||
@@ -603,7 +603,7 @@ public class GroupsV2StateProcessor {
|
||||
} else if (addedBy.isSystemContact() || addedBy.isProfileSharing()) {
|
||||
Log.i(TAG, "Group 'adder' is trusted. contact: " + addedBy.isSystemContact() + ", profileSharing: " + addedBy.isProfileSharing());
|
||||
Log.i(TAG, "Added to a group and auto-enabling profile sharing");
|
||||
recipientDatabase.setProfileSharing(Recipient.externalGroupExact(context, groupId).getId(), true);
|
||||
recipientDatabase.setProfileSharing(Recipient.externalGroupExact(groupId).getId(), true);
|
||||
} else {
|
||||
Log.i(TAG, "Added to a group, but not enabling profile sharing, as 'adder' is not trusted");
|
||||
}
|
||||
@@ -612,7 +612,7 @@ public class GroupsV2StateProcessor {
|
||||
}
|
||||
} else if (selfAsPendingOptional.isPresent()) {
|
||||
Optional<Recipient> addedBy = selfAsPendingOptional.flatMap(adder -> Optional.ofNullable(UuidUtil.fromByteStringOrNull(adder.getAddedByUuid()))
|
||||
.map(a -> Recipient.externalPush(ServiceId.fromByteStringOrNull(adder.getAddedByUuid()), null, false)));
|
||||
.map(uuid -> Recipient.externalPush(ServiceId.from(uuid))));
|
||||
|
||||
if (addedBy.isPresent() && addedBy.get().isBlocked()) {
|
||||
Log.i(TAG, String.format( "Added to group %s by a blocked user %s. Leaving group.", groupId, addedBy.get().getId()));
|
||||
@@ -698,7 +698,7 @@ public class GroupsV2StateProcessor {
|
||||
}
|
||||
} else {
|
||||
MessageDatabase smsDatabase = SignalDatabase.sms();
|
||||
RecipientId sender = RecipientId.from(editor.get(), null);
|
||||
RecipientId sender = RecipientId.from(editor.get());
|
||||
IncomingTextMessage incoming = new IncomingTextMessage(sender, -1, timestamp, timestamp, timestamp, "", Optional.of(groupId), 0, false, null);
|
||||
IncomingGroupUpdateMessage groupMessage = new IncomingGroupUpdateMessage(incoming, decryptedGroupV2Context);
|
||||
Optional<MessageDatabase.InsertResult> insertResult = smsDatabase.insertMessageInbox(groupMessage);
|
||||
|
||||
@@ -58,7 +58,7 @@ public class PushProcessMessageQueueJobMigration extends JobMigration {
|
||||
Log.i(TAG, "Migrating a group message.");
|
||||
try {
|
||||
GroupId groupId = GroupUtil.idFromGroupContext(content.getDataMessage().get().getGroupContext().get());
|
||||
Recipient recipient = Recipient.externalGroupExact(context, groupId);
|
||||
Recipient recipient = Recipient.externalGroupExact(groupId);
|
||||
|
||||
suffix = recipient.getId().toQueueKey();
|
||||
} catch (BadGroupIdException e) {
|
||||
@@ -75,7 +75,7 @@ public class PushProcessMessageQueueJobMigration extends JobMigration {
|
||||
GroupId exceptionGroup = GroupId.parseNullableOrThrow(data.getStringOrDefault("exception_groupId", null));
|
||||
|
||||
if (exceptionGroup != null) {
|
||||
suffix = Recipient.externalGroupExact(context, exceptionGroup).getId().toQueueKey();
|
||||
suffix = Recipient.externalGroupExact(exceptionGroup).getId().toQueueKey();
|
||||
} else if (exceptionSender != null) {
|
||||
suffix = Recipient.external(context, exceptionSender).getId().toQueueKey();
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ class LeaveGroupV2WorkerJob(parameters: Parameters, private val groupId: GroupId
|
||||
|
||||
constructor(groupId: GroupId.V2) : this(
|
||||
parameters = Parameters.Builder()
|
||||
.setQueue(PushProcessMessageJob.getQueueName(Recipient.externalGroupExact(ApplicationDependencies.getApplication(), groupId).id))
|
||||
.setQueue(PushProcessMessageJob.getQueueName(Recipient.externalGroupExact(groupId).id))
|
||||
.addConstraint(NetworkConstraint.KEY)
|
||||
.setMaxAttempts(Parameters.UNLIMITED)
|
||||
.setMaxInstancesForQueue(2)
|
||||
@@ -41,7 +41,7 @@ class LeaveGroupV2WorkerJob(parameters: Parameters, private val groupId: GroupId
|
||||
override fun onRun() {
|
||||
Log.i(TAG, "Attempting to leave group $groupId")
|
||||
|
||||
val groupRecipient = Recipient.externalGroupExact(ApplicationDependencies.getApplication(), groupId)
|
||||
val groupRecipient = Recipient.externalGroupExact(groupId)
|
||||
|
||||
GroupManager.leaveGroup(context, groupId)
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ import org.whispersystems.signalservice.api.messages.SignalServiceAttachmentPoin
|
||||
import org.whispersystems.signalservice.api.messages.multidevice.DeviceContact
|
||||
import org.whispersystems.signalservice.api.messages.multidevice.DeviceContactsInputStream
|
||||
import org.whispersystems.signalservice.api.messages.multidevice.VerifiedMessage.VerifiedState
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress
|
||||
import org.whispersystems.signalservice.api.push.exceptions.MissingConfigurationException
|
||||
import org.whispersystems.signalservice.api.util.AttachmentPointerUtil
|
||||
import java.io.File
|
||||
@@ -75,7 +76,7 @@ class MultiDeviceContactSyncJob(parameters: Parameters, private val attachmentPo
|
||||
|
||||
var contact: DeviceContact? = deviceContacts.read()
|
||||
while (contact != null) {
|
||||
val recipient = Recipient.externalPush(contact.address.serviceId, contact.address.number.orElse(null), true)
|
||||
val recipient = Recipient.externalPush(SignalServiceAddress(contact.address.serviceId, contact.address.number.orElse(null)))
|
||||
|
||||
if (recipient.isSelf) {
|
||||
contact = deviceContacts.read()
|
||||
|
||||
@@ -76,7 +76,7 @@ public final class PushGroupSilentUpdateSendJob extends BaseJob {
|
||||
Set<RecipientId> recipients = Stream.concat(Stream.of(memberUuids), Stream.of(pendingUuids))
|
||||
.filter(uuid -> !UuidUtil.UNKNOWN_UUID.equals(uuid))
|
||||
.filter(uuid -> !SignalStore.account().requireAci().uuid().equals(uuid))
|
||||
.map(uuid -> Recipient.externalPush(ServiceId.from(uuid), null, false))
|
||||
.map(uuid -> Recipient.externalPush(ServiceId.from(uuid)))
|
||||
.filter(recipient -> recipient.getRegistered() != RecipientDatabase.RegisteredState.NOT_REGISTERED)
|
||||
.map(Recipient::getId)
|
||||
.collect(Collectors.toSet());
|
||||
@@ -84,7 +84,7 @@ public final class PushGroupSilentUpdateSendJob extends BaseJob {
|
||||
MessageGroupContext.GroupV2Properties properties = groupMessage.requireGroupV2Properties();
|
||||
SignalServiceProtos.GroupContextV2 groupContext = properties.getGroupContext();
|
||||
|
||||
String queue = Recipient.externalGroupExact(context, groupId).getId().toQueueKey();
|
||||
String queue = Recipient.externalGroupExact(groupId).getId().toQueueKey();
|
||||
|
||||
return new PushGroupSilentUpdateSendJob(new ArrayList<>(recipients),
|
||||
recipients.size(),
|
||||
@@ -133,7 +133,7 @@ public final class PushGroupSilentUpdateSendJob extends BaseJob {
|
||||
|
||||
GroupId.V2 groupId = GroupId.v2(GroupUtil.requireMasterKey(groupContextV2.getMasterKey().toByteArray()));
|
||||
|
||||
if (Recipient.externalGroupExact(context, groupId).isBlocked()) {
|
||||
if (Recipient.externalGroupExact(groupId).isBlocked()) {
|
||||
Log.i(TAG, "Not updating group state for blocked group " + groupId);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ public final class PushProcessMessageJob extends BaseJob {
|
||||
try {
|
||||
GroupId groupId = GroupUtil.idFromGroupContext(signalServiceGroupContext);
|
||||
|
||||
queueName = getQueueName(Recipient.externalPossiblyMigratedGroup(context, groupId).getId());
|
||||
queueName = getQueueName(Recipient.externalPossiblyMigratedGroup(groupId).getId());
|
||||
|
||||
if (groupId.isV2()) {
|
||||
int localRevision = SignalDatabase.groups().getGroupV2Revision(groupId.requireV2());
|
||||
@@ -143,12 +143,12 @@ public final class PushProcessMessageJob extends BaseJob {
|
||||
Log.w(TAG, "Bad groupId! Using default queue. ID: " + content.getTimestamp());
|
||||
}
|
||||
} else if (content.getSyncMessage().isPresent() && content.getSyncMessage().get().getSent().isPresent() && content.getSyncMessage().get().getSent().get().getDestination().isPresent()) {
|
||||
queueName = getQueueName(RecipientId.fromHighTrust(content.getSyncMessage().get().getSent().get().getDestination().get()));
|
||||
queueName = getQueueName(RecipientId.from(content.getSyncMessage().get().getSent().get().getDestination().get()));
|
||||
} else {
|
||||
queueName = getQueueName(RecipientId.fromHighTrust(content.getSender()));
|
||||
queueName = getQueueName(RecipientId.from(content.getSender()));
|
||||
}
|
||||
} else if (exceptionMetadata != null) {
|
||||
Recipient recipient = exceptionMetadata.getGroupId() != null ? Recipient.externalPossiblyMigratedGroup(context, exceptionMetadata.getGroupId())
|
||||
Recipient recipient = exceptionMetadata.getGroupId() != null ? Recipient.externalPossiblyMigratedGroup(exceptionMetadata.getGroupId())
|
||||
: Recipient.external(context, exceptionMetadata.getSender());
|
||||
queueName = getQueueName(recipient.getId());
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import org.signal.core.util.logging.Log;
|
||||
import org.signal.libsignal.zkgroup.VerificationFailedException;
|
||||
import org.thoughtcrime.securesms.database.GroupDatabase;
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.groups.GroupChangeBusyException;
|
||||
import org.thoughtcrime.securesms.groups.GroupId;
|
||||
import org.thoughtcrime.securesms.groups.GroupManager;
|
||||
@@ -44,7 +43,7 @@ final class RequestGroupV2InfoWorkerJob extends BaseJob {
|
||||
@WorkerThread
|
||||
RequestGroupV2InfoWorkerJob(@NonNull GroupId.V2 groupId, int toRevision) {
|
||||
this(new Parameters.Builder()
|
||||
.setQueue(PushProcessMessageJob.getQueueName(Recipient.externalGroupExact(ApplicationDependencies.getApplication(), groupId).getId()))
|
||||
.setQueue(PushProcessMessageJob.getQueueName(Recipient.externalGroupExact(groupId).getId()))
|
||||
.addConstraint(NetworkConstraint.KEY)
|
||||
.setLifespan(TimeUnit.DAYS.toMillis(1))
|
||||
.setMaxAttempts(Parameters.UNLIMITED)
|
||||
@@ -87,7 +86,7 @@ final class RequestGroupV2InfoWorkerJob extends BaseJob {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Recipient.externalGroupExact(context, groupId).isBlocked()) {
|
||||
if (Recipient.externalGroupExact(groupId).isBlocked()) {
|
||||
Log.i(TAG, "Not fetching group info for blocked group " + groupId);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,6 @@ import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.whispersystems.signalservice.api.SignalSessionLock;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceGroupContext;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
@@ -89,7 +88,7 @@ public class IncomingMessageProcessor {
|
||||
}
|
||||
|
||||
if (envelope.hasSourceUuid()) {
|
||||
Recipient.externalHighTrustPush(context, envelope.getSourceAddress());
|
||||
Recipient.externalPush(envelope.getSourceAddress());
|
||||
}
|
||||
|
||||
if (envelope.isReceipt()) {
|
||||
@@ -165,7 +164,7 @@ public class IncomingMessageProcessor {
|
||||
}
|
||||
|
||||
private void processReceipt(@NonNull SignalServiceEnvelope envelope) {
|
||||
Recipient sender = Recipient.externalHighTrustPush(context, envelope.getSourceAddress());
|
||||
Recipient sender = Recipient.externalPush(envelope.getSourceAddress());
|
||||
Log.i(TAG, "Received server receipt. Sender: " + sender.getId() + ", Device: " + envelope.getSourceDevice() + ", Timestamp: " + envelope.getTimestamp());
|
||||
|
||||
mmsSmsDatabase.incrementDeliveryReceiptCount(new SyncMessageId(sender.getId(), envelope.getTimestamp()), System.currentTimeMillis());
|
||||
@@ -185,7 +184,7 @@ public class IncomingMessageProcessor {
|
||||
GroupId groupId = GroupUtil.idFromGroupContext(groupContext);
|
||||
|
||||
if (groupId.isV2()) {
|
||||
String queueName = PushProcessMessageJob.getQueueName(Recipient.externalPossiblyMigratedGroup(context, groupId).getId());
|
||||
String queueName = PushProcessMessageJob.getQueueName(Recipient.externalPossiblyMigratedGroup(groupId).getId());
|
||||
GroupDatabase groupDatabase = SignalDatabase.groups();
|
||||
|
||||
return !jobManager.isQueueEmpty(queueName) ||
|
||||
@@ -199,7 +198,7 @@ public class IncomingMessageProcessor {
|
||||
return false;
|
||||
}
|
||||
} else if (result.getContent() != null) {
|
||||
RecipientId recipientId = RecipientId.fromHighTrust(result.getContent().getSender());
|
||||
RecipientId recipientId = RecipientId.from(result.getContent().getSender());
|
||||
String queueKey = PushProcessMessageJob.getQueueName(recipientId);
|
||||
|
||||
return !jobManager.isQueueEmpty(queueKey);
|
||||
|
||||
@@ -234,7 +234,7 @@ public final class MessageContentProcessor {
|
||||
if (messageState == MessageState.DECRYPTED_OK) {
|
||||
|
||||
if (content != null) {
|
||||
Recipient senderRecipient = Recipient.externalHighTrustPush(context, content.getSender());
|
||||
Recipient senderRecipient = Recipient.externalPush(content.getSender());
|
||||
|
||||
handleMessage(content, timestamp, senderRecipient, optionalSmsMessageId);
|
||||
|
||||
@@ -1103,7 +1103,7 @@ public final class MessageContentProcessor {
|
||||
recipient = Recipient.externalPush(response.getPerson().get());
|
||||
} else if (response.getGroupId().isPresent()) {
|
||||
GroupId groupId = GroupId.v1(response.getGroupId().get());
|
||||
recipient = Recipient.externalPossiblyMigratedGroup(context, groupId);
|
||||
recipient = Recipient.externalPossiblyMigratedGroup(groupId);
|
||||
} else {
|
||||
warn("Message request response was missing a thread recipient! Skipping.");
|
||||
return;
|
||||
@@ -1562,7 +1562,7 @@ public final class MessageContentProcessor {
|
||||
database.beginTransaction();
|
||||
|
||||
try {
|
||||
RecipientId storyAuthorRecipient = RecipientId.from(storyContext.getAuthorServiceId(), null);
|
||||
RecipientId storyAuthorRecipient = RecipientId.from(storyContext.getAuthorServiceId());
|
||||
ParentStoryId parentStoryId;
|
||||
QuoteModel quoteModel = null;
|
||||
long expiresInMillis = 0;
|
||||
@@ -1656,7 +1656,7 @@ public final class MessageContentProcessor {
|
||||
database.beginTransaction();
|
||||
|
||||
try {
|
||||
RecipientId storyAuthorRecipient = RecipientId.from(storyContext.getAuthorServiceId(), null);
|
||||
RecipientId storyAuthorRecipient = RecipientId.from(storyContext.getAuthorServiceId());
|
||||
ParentStoryId parentStoryId;
|
||||
QuoteModel quoteModel = null;
|
||||
long expiresInMillis = 0L;
|
||||
@@ -1937,7 +1937,7 @@ public final class MessageContentProcessor {
|
||||
Recipient recipient = getSyncMessageDestination(message);
|
||||
QuoteModel quoteModel = null;
|
||||
long expiresInMillis = 0L;
|
||||
RecipientId storyAuthorRecipient = RecipientId.from(storyContext.getAuthorServiceId(), null);
|
||||
RecipientId storyAuthorRecipient = RecipientId.from(storyContext.getAuthorServiceId());
|
||||
MessageId storyMessageId = database.getStoryId(storyAuthorRecipient, storyContext.getSentTimestamp());
|
||||
MmsMessageRecord story = (MmsMessageRecord) database.getMessageRecord(storyMessageId.getId());
|
||||
Recipient threadRecipient = SignalDatabase.threads().getRecipientForThreadId(story.getThreadId());
|
||||
@@ -2552,7 +2552,7 @@ public final class MessageContentProcessor {
|
||||
@NonNull SignalServiceDataMessage message,
|
||||
@NonNull MessageId messageId)
|
||||
{
|
||||
ApplicationDependencies.getJobManager().add(new SendDeliveryReceiptJob(RecipientId.fromHighTrust(content.getSender()), message.getTimestamp(), messageId));
|
||||
ApplicationDependencies.getJobManager().add(new SendDeliveryReceiptJob(RecipientId.from(content.getSender()), message.getTimestamp(), messageId));
|
||||
}
|
||||
|
||||
private void handleViewedReceipt(@NonNull SignalServiceContent content,
|
||||
@@ -2666,7 +2666,7 @@ public final class MessageContentProcessor {
|
||||
return;
|
||||
}
|
||||
|
||||
Recipient groupRecipient = Recipient.externalPossiblyMigratedGroup(context, groupId);
|
||||
Recipient groupRecipient = Recipient.externalPossiblyMigratedGroup(groupId);
|
||||
|
||||
threadId = SignalDatabase.threads().getOrCreateThreadIdFor(groupRecipient);
|
||||
} else {
|
||||
@@ -2990,7 +2990,7 @@ public final class MessageContentProcessor {
|
||||
List<Mention> mentions = new ArrayList<>(signalServiceMentions.size());
|
||||
|
||||
for (SignalServiceDataMessage.Mention mention : signalServiceMentions) {
|
||||
mentions.add(new Mention(Recipient.externalPush(mention.getServiceId(), null, false).getId(), mention.getStart(), mention.getLength()));
|
||||
mentions.add(new Mention(Recipient.externalPush(mention.getServiceId()).getId(), mention.getStart(), mention.getLength()));
|
||||
}
|
||||
|
||||
return mentions;
|
||||
@@ -3026,14 +3026,14 @@ public final class MessageContentProcessor {
|
||||
|
||||
private Recipient getMessageDestination(@NonNull SignalServiceContent content) throws BadGroupIdException {
|
||||
SignalServiceDataMessage message = content.getDataMessage().orElse(null);
|
||||
return getGroupRecipient(message != null ? message.getGroupContext() : Optional.empty()).orElseGet(() -> Recipient.externalHighTrustPush(context, content.getSender()));
|
||||
return getGroupRecipient(message != null ? message.getGroupContext() : Optional.empty()).orElseGet(() -> Recipient.externalPush(content.getSender()));
|
||||
}
|
||||
|
||||
private Optional<Recipient> getGroupRecipient(Optional<SignalServiceGroupContext> message)
|
||||
throws BadGroupIdException
|
||||
{
|
||||
if (message.isPresent()) {
|
||||
return Optional.of(Recipient.externalPossiblyMigratedGroup(context, GroupUtil.idFromGroupContext(message.get())));
|
||||
return Optional.of(Recipient.externalPossiblyMigratedGroup(GroupUtil.idFromGroupContext(message.get())));
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
@@ -3093,7 +3093,7 @@ public final class MessageContentProcessor {
|
||||
|
||||
if (content.getTypingMessage().get().getGroupId().isPresent()) {
|
||||
GroupId groupId = GroupId.push(content.getTypingMessage().get().getGroupId().get());
|
||||
Recipient groupRecipient = Recipient.externalPossiblyMigratedGroup(context, groupId);
|
||||
Recipient groupRecipient = Recipient.externalPossiblyMigratedGroup(groupId);
|
||||
|
||||
if (groupRecipient.isBlocked() || !groupRecipient.isActiveGroup()) {
|
||||
return true;
|
||||
|
||||
@@ -164,7 +164,7 @@ public final class MessageDecryptionUtil {
|
||||
long threadId;
|
||||
|
||||
if (groupId.isPresent()) {
|
||||
Recipient groupRecipient = Recipient.externalPossiblyMigratedGroup(context, groupId.get());
|
||||
Recipient groupRecipient = Recipient.externalPossiblyMigratedGroup(groupId.get());
|
||||
threadId = SignalDatabase.threads().getOrCreateThreadIdFor(groupRecipient);
|
||||
} else {
|
||||
threadId = SignalDatabase.threads().getOrCreateThreadIdFor(sender);
|
||||
|
||||
@@ -132,7 +132,7 @@ public final class MessageGroupContext {
|
||||
return Stream.of(groupContext.getMembersList())
|
||||
.map(GroupContext.Member::getE164)
|
||||
.withoutNulls()
|
||||
.map(RecipientId::fromExternalPush)
|
||||
.map(RecipientId::fromE164)
|
||||
.filterNot(selfId::equals)
|
||||
.toList();
|
||||
}
|
||||
@@ -191,7 +191,7 @@ public final class MessageGroupContext {
|
||||
List<RecipientId> members = new ArrayList<>(decryptedGroupV2Context.getGroupState().getMembersCount());
|
||||
|
||||
for (DecryptedMember member : decryptedGroupV2Context.getGroupState().getMembersList()) {
|
||||
RecipientId recipient = RecipientId.from(ServiceId.fromByteString(member.getUuid()), null);
|
||||
RecipientId recipient = RecipientId.from(ServiceId.fromByteString(member.getUuid()));
|
||||
if (!Recipient.self().getId().equals(recipient)) {
|
||||
members.add(recipient);
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ public final class LiveRecipientCache {
|
||||
}
|
||||
|
||||
if (selfId == null) {
|
||||
selfId = recipientDatabase.getAndPossiblyMerge(localAci, localE164, true);
|
||||
selfId = recipientDatabase.getAndPossiblyMerge(localAci, localE164);
|
||||
}
|
||||
|
||||
synchronized (localRecipientId) {
|
||||
|
||||
@@ -199,19 +199,18 @@ public class Recipient {
|
||||
*/
|
||||
@WorkerThread
|
||||
public static @NonNull Recipient externalUsername(@NonNull ServiceId serviceId, @NonNull String username) {
|
||||
Recipient recipient = externalPush(serviceId, null, false);
|
||||
Recipient recipient = externalPush(serviceId);
|
||||
SignalDatabase.recipients().setUsername(recipient.getId(), username);
|
||||
return recipient;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a fully-populated {@link Recipient} based off of a {@link SignalServiceAddress},
|
||||
* creating one in the database if necessary. Convenience overload of
|
||||
* {@link #externalPush(ServiceId, String, boolean)}
|
||||
* creating one in the database if necessary.
|
||||
*/
|
||||
@WorkerThread
|
||||
public static @NonNull Recipient externalPush(@NonNull SignalServiceAddress signalServiceAddress) {
|
||||
return externalPush(signalServiceAddress.getServiceId(), signalServiceAddress.getNumber().orElse(null), false);
|
||||
return externalPush(signalServiceAddress.getServiceId(), signalServiceAddress.getNumber().orElse(null));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -222,46 +221,38 @@ public class Recipient {
|
||||
@WorkerThread
|
||||
public static @NonNull Recipient externalGV1Member(@NonNull SignalServiceAddress address) {
|
||||
if (address.getNumber().isPresent()) {
|
||||
return externalPush(null, address.getNumber().get(), false);
|
||||
return externalPush(null, address.getNumber().get());
|
||||
} else {
|
||||
return externalPush(address.getServiceId(), null, false);
|
||||
return externalPush(address.getServiceId());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a fully-populated {@link Recipient} based off of a {@link SignalServiceAddress},
|
||||
* creating one in the database if necessary. This should only used for high-trust sources,
|
||||
* which are limited to:
|
||||
* - Envelopes
|
||||
* - UD Certs
|
||||
* - CDS
|
||||
* - Storage Service
|
||||
* Returns a fully-populated {@link Recipient} based off of a ServiceId, creating one
|
||||
* in the database if necessary.
|
||||
*/
|
||||
@WorkerThread
|
||||
public static @NonNull Recipient externalHighTrustPush(@NonNull Context context, @NonNull SignalServiceAddress signalServiceAddress) {
|
||||
return externalPush(signalServiceAddress.getServiceId(), signalServiceAddress.getNumber().orElse(null), true);
|
||||
public static @NonNull Recipient externalPush(@NonNull ServiceId serviceId) {
|
||||
return externalPush(serviceId, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a fully-populated {@link Recipient} based off of an ACI and phone number, creating one
|
||||
* Returns a fully-populated {@link Recipient} based off of a ServiceId and phone number, creating one
|
||||
* in the database if necessary. We want both piece of information so we're able to associate them
|
||||
* both together, depending on which are available.
|
||||
*
|
||||
* In particular, while we'll eventually get the ACI of a user created via a phone number
|
||||
* (through a directory sync), the only way we can store the phone number is by retrieving it from
|
||||
* sent messages and whatnot. So we should store it when available.
|
||||
*
|
||||
* @param highTrust This should only be set to true if the source of the E164-ACI pairing is one
|
||||
* that can be trusted as accurate (like an envelope).
|
||||
*/
|
||||
@WorkerThread
|
||||
public static @NonNull Recipient externalPush(@Nullable ServiceId serviceId, @Nullable String e164, boolean highTrust) {
|
||||
static @NonNull Recipient externalPush(@Nullable ServiceId serviceId, @Nullable String e164) {
|
||||
if (ServiceId.UNKNOWN.equals(serviceId)) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
RecipientDatabase db = SignalDatabase.recipients();
|
||||
RecipientId recipientId = db.getAndPossiblyMerge(serviceId, e164, highTrust);
|
||||
RecipientId recipientId = db.getAndPossiblyMerge(serviceId, e164);
|
||||
|
||||
Recipient resolved = resolved(recipientId);
|
||||
|
||||
@@ -269,11 +260,11 @@ public class Recipient {
|
||||
Log.w(TAG, "Resolved " + recipientId + ", but got back a recipient with " + resolved.getId());
|
||||
}
|
||||
|
||||
if (highTrust && !resolved.isRegistered() && serviceId != null) {
|
||||
Log.w(TAG, "External high-trust push was locally marked unregistered. Marking as registered.");
|
||||
if (!resolved.isRegistered() && serviceId != null) {
|
||||
Log.w(TAG, "External push was locally marked unregistered. Marking as registered.");
|
||||
db.markRegistered(recipientId, serviceId);
|
||||
} else if (highTrust && !resolved.isRegistered()) {
|
||||
Log.w(TAG, "External high-trust push was locally marked unregistered, but we don't have an ACI, so we can't do anything.", new Throwable());
|
||||
} else if (!resolved.isRegistered()) {
|
||||
Log.w(TAG, "External push was locally marked unregistered, but we don't have an ACI, so we can't do anything.", new Throwable());
|
||||
}
|
||||
|
||||
return resolved;
|
||||
@@ -287,7 +278,7 @@ public class Recipient {
|
||||
* (This may seem strange, but apparently some devices are returning valid UUIDs for contacts)
|
||||
*/
|
||||
@WorkerThread
|
||||
public static @NonNull Recipient externalContact(@NonNull Context context, @NonNull String identifier) {
|
||||
public static @NonNull Recipient externalContact(@NonNull String identifier) {
|
||||
RecipientDatabase db = SignalDatabase.recipients();
|
||||
RecipientId id = null;
|
||||
|
||||
@@ -308,11 +299,11 @@ public class Recipient {
|
||||
*
|
||||
* Important: This will throw an exception if the groupId you're using could have been migrated.
|
||||
* If you're dealing with inbound data, you should be using
|
||||
* {@link #externalPossiblyMigratedGroup(Context, GroupId)}, or checking the database before
|
||||
* {@link #externalPossiblyMigratedGroup(GroupId)}, or checking the database before
|
||||
* calling this method.
|
||||
*/
|
||||
@WorkerThread
|
||||
public static @NonNull Recipient externalGroupExact(@NonNull Context context, @NonNull GroupId groupId) {
|
||||
public static @NonNull Recipient externalGroupExact(@NonNull GroupId groupId) {
|
||||
return Recipient.resolved(SignalDatabase.recipients().getOrInsertFromGroupId(groupId));
|
||||
}
|
||||
|
||||
@@ -327,7 +318,7 @@ public class Recipient {
|
||||
* You should be very cautious when using the groupId on the returned recipient.
|
||||
*/
|
||||
@WorkerThread
|
||||
public static @NonNull Recipient externalPossiblyMigratedGroup(@NonNull Context context, @NonNull GroupId groupId) {
|
||||
public static @NonNull Recipient externalPossiblyMigratedGroup(@NonNull GroupId groupId) {
|
||||
return Recipient.resolved(SignalDatabase.recipients().getOrInsertFromPossiblyMigratedGroupId(groupId));
|
||||
}
|
||||
|
||||
@@ -337,7 +328,7 @@ public class Recipient {
|
||||
* or serialized groupId.
|
||||
*
|
||||
* If the identifier is a UUID of a Signal user, prefer using
|
||||
* {@link #externalPush(ServiceId, String, boolean)} or its overload, as this will let us associate
|
||||
* {@link #externalPush(ServiceId, String)} or its overload, as this will let us associate
|
||||
* the phone number with the recipient.
|
||||
*/
|
||||
@WorkerThread
|
||||
|
||||
@@ -56,7 +56,17 @@ public class RecipientId implements Parcelable, Comparable<RecipientId>, Databas
|
||||
|
||||
@AnyThread
|
||||
public static @NonNull RecipientId from(@NonNull SignalServiceAddress address) {
|
||||
return from(address.getServiceId(), address.getNumber().orElse(null), false);
|
||||
return from(address.getServiceId(), address.getNumber().orElse(null));
|
||||
}
|
||||
|
||||
@AnyThread
|
||||
public static @NonNull RecipientId from(@NonNull ServiceId serviceId) {
|
||||
return from(serviceId, null);
|
||||
}
|
||||
|
||||
@AnyThread
|
||||
public static @NonNull RecipientId fromE164(@NonNull String identifier) {
|
||||
return from(null, identifier);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -65,35 +75,17 @@ public class RecipientId implements Parcelable, Comparable<RecipientId>, Databas
|
||||
* @param identifier A UUID or e164
|
||||
*/
|
||||
@AnyThread
|
||||
public static @NonNull RecipientId fromExternalPush(@NonNull String identifier) {
|
||||
public static @NonNull RecipientId fromSidOrE164(@NonNull String identifier) {
|
||||
if (UuidUtil.isUuid(identifier)) {
|
||||
return from(ServiceId.parseOrThrow(identifier), null);
|
||||
return from(ServiceId.parseOrThrow(identifier));
|
||||
} else {
|
||||
return from(null, identifier);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates that the pairing is from a high-trust source.
|
||||
* See {@link Recipient#externalHighTrustPush(Context, SignalServiceAddress)}
|
||||
*/
|
||||
@AnyThread
|
||||
public static @NonNull RecipientId fromHighTrust(@NonNull SignalServiceAddress address) {
|
||||
return from(address.getServiceId(), address.getNumber().orElse(null), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Always supply both {@param uuid} and {@param e164} if you have both.
|
||||
*/
|
||||
@AnyThread
|
||||
@SuppressLint("WrongThread")
|
||||
public static @NonNull RecipientId from(@Nullable ServiceId serviceId, @Nullable String e164) {
|
||||
return from(serviceId, e164, false);
|
||||
}
|
||||
|
||||
@AnyThread
|
||||
@SuppressLint("WrongThread")
|
||||
private static @NonNull RecipientId from(@Nullable ServiceId serviceId, @Nullable String e164, boolean highTrust) {
|
||||
private static @NonNull RecipientId from(@Nullable ServiceId serviceId, @Nullable String e164) {
|
||||
if (serviceId != null && serviceId.isUnknown()) {
|
||||
return RecipientId.UNKNOWN;
|
||||
}
|
||||
@@ -101,7 +93,7 @@ public class RecipientId implements Parcelable, Comparable<RecipientId>, Databas
|
||||
RecipientId recipientId = RecipientIdCache.INSTANCE.get(serviceId, e164);
|
||||
|
||||
if (recipientId == null) {
|
||||
Recipient recipient = Recipient.externalPush(serviceId, e164, highTrust);
|
||||
Recipient recipient = Recipient.externalPush(serviceId, e164);
|
||||
RecipientIdCache.INSTANCE.put(recipient);
|
||||
recipientId = recipient.getId();
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ public final class RegistrationRepository {
|
||||
}
|
||||
|
||||
RecipientDatabase recipientDatabase = SignalDatabase.recipients();
|
||||
RecipientId selfId = Recipient.externalPush(aci, registrationData.getE164(), true).getId();
|
||||
RecipientId selfId = Recipient.externalPush(new SignalServiceAddress(aci, registrationData.getE164())).getId();
|
||||
|
||||
recipientDatabase.setProfileSharing(selfId, true);
|
||||
recipientDatabase.markRegisteredOrThrow(selfId, aci);
|
||||
|
||||
@@ -83,7 +83,7 @@ public class GroupActionProcessor extends DeviceAwareActionProcessor {
|
||||
seen.add(Recipient.self());
|
||||
|
||||
for (GroupCall.RemoteDeviceState device : remoteDeviceStates) {
|
||||
Recipient recipient = Recipient.externalPush(ServiceId.from(device.getUserId()), null, false);
|
||||
Recipient recipient = Recipient.externalPush(ServiceId.from(device.getUserId()));
|
||||
CallParticipantId callParticipantId = new CallParticipantId(device.getDemuxId(), recipient.getId());
|
||||
CallParticipant callParticipant = participants.get(callParticipantId);
|
||||
|
||||
|
||||
@@ -114,7 +114,7 @@ public class GroupPreJoinActionProcessor extends GroupActionProcessor {
|
||||
}
|
||||
|
||||
List<Recipient> callParticipants = Stream.of(peekInfo.getJoinedMembers())
|
||||
.map(uuid -> Recipient.externalPush(ServiceId.from(uuid), null, false))
|
||||
.map(uuid -> Recipient.externalPush(ServiceId.from(uuid)))
|
||||
.toList();
|
||||
|
||||
WebRtcServiceStateBuilder.CallInfoStateBuilder builder = currentState.builder()
|
||||
|
||||
@@ -138,7 +138,7 @@ public final class IncomingGroupCallActionProcessor extends DeviceAwareActionPro
|
||||
.changeCallSetupState(RemotePeer.GROUP_CALL_ID)
|
||||
.isRemoteVideoOffer(true)
|
||||
.ringId(ringId)
|
||||
.ringerRecipient(Recipient.externalPush(ServiceId.from(uuid), null, false))
|
||||
.ringerRecipient(Recipient.externalPush(ServiceId.from(uuid)))
|
||||
.commit()
|
||||
.changeCallInfoState()
|
||||
.activePeer(new RemotePeer(currentState.getCallInfoState().getCallRecipient().getId(), RemotePeer.GROUP_CALL_ID))
|
||||
|
||||
@@ -639,7 +639,7 @@ private void processStateless(@NonNull Function1<WebRtcEphemeralState, WebRtcEph
|
||||
SignalServiceCallMessage callMessage = SignalServiceCallMessage.forOpaque(opaqueMessage, true, null);
|
||||
|
||||
networkExecutor.execute(() -> {
|
||||
Recipient recipient = Recipient.resolved(RecipientId.from(ServiceId.from(uuid), null));
|
||||
Recipient recipient = Recipient.resolved(RecipientId.from(ServiceId.from(uuid)));
|
||||
if (recipient.isBlocked()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user