Fix check for outgoing sync messages to 1:1 chats

This commit is contained in:
Max Radermacher 2023-08-16 14:15:17 -05:00 committed by GitHub
parent 973d5a7394
commit e90d3a400d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 11 deletions

View File

@ -84,11 +84,12 @@ NS_ASSUME_NONNULL_BEGIN
OWSFailDebug(@"Invalid groupId.");
return nil;
}
} else if (sentProto.destinationServiceID) {
} else if (sentProto.destinationServiceID || sentProto.destinationE164) {
SignalServiceAddress *destinationAddress =
[[SignalServiceAddress alloc] initWithServiceIdString:sentProto.destinationServiceID];
[[SignalServiceAddress alloc] initWithServiceIdString:sentProto.destinationServiceID
phoneNumber:sentProto.destinationE164];
if (!destinationAddress.isValid) {
OWSFailDebug(@"Invalid serviceID.");
OWSFailDebug(@"Invalid destinationAddress.");
return nil;
}
_recipientAddress = destinationAddress;

View File

@ -870,19 +870,22 @@ NS_ASSUME_NONNULL_BEGIN
return;
}
// If we observe a linked device sending our profile key to another user,
// we can infer that that user belongs in our profile whitelist.
SignalServiceAddress *destinationAddress =
[[SignalServiceAddress alloc] initWithServiceIdString:syncMessage.sent.destinationServiceID];
if (dataMessage && destinationAddress.isValid && dataMessage.hasProfileKey) {
if (dataMessage && dataMessage.hasProfileKey) {
if (groupId != nil) {
[self.profileManager addGroupIdToProfileWhitelist:groupId
userProfileWriter:UserProfileWriter_LocalUser
transaction:transaction];
} else {
[self.profileManager addUserToProfileWhitelist:destinationAddress
userProfileWriter:UserProfileWriter_LocalUser
transaction:transaction];
// If we observe a linked device sending our profile key to another user,
// we can infer that that user belongs in our profile whitelist.
SignalServiceAddress *destinationAddress =
[[SignalServiceAddress alloc] initWithServiceIdString:syncMessage.sent.destinationServiceID
phoneNumber:syncMessage.sent.destinationE164];
if (destinationAddress.isValid) {
[self.profileManager addUserToProfileWhitelist:destinationAddress
userProfileWriter:UserProfileWriter_LocalUser
transaction:transaction];
}
}
}