This commit is contained in:
nielsandriesse 2020-06-15 13:10:46 +10:00
parent 6686122461
commit b4d4522e99
3 changed files with 14 additions and 13 deletions

View file

@ -252,7 +252,7 @@ typedef void (^ProfileManagerFailureBlock)(NSError *error);
}
*/
if (requiresSync) {
[LKSyncMessagesProtocol syncProfileUpdate];
[LKSyncMessagesProtocol syncProfile];
}
dispatch_async(dispatch_get_main_queue(), ^{
@ -271,7 +271,7 @@ typedef void (^ProfileManagerFailureBlock)(NSError *error);
}
*/
if (requiresSync) {
[LKSyncMessagesProtocol syncProfileUpdate];
[LKSyncMessagesProtocol syncProfile];
}
dispatch_async(dispatch_get_main_queue(), ^{

View file

@ -24,14 +24,14 @@ public final class SyncMessagesProtocol : NSObject {
return !UserDefaults.standard[.hasLaunchedOnce]
}
@objc(syncProfileUpdate)
public static func syncProfileUpdate() {
storage.dbReadWriteConnection.readWrite{ transaction in
let userHexEncodedPublicKey = getUserHexEncodedPublicKey()
let linkedDevices = LokiDatabaseUtilities.getLinkedDeviceHexEncodedPublicKeys(for: userHexEncodedPublicKey, in: transaction)
for hexEncodedPublicKey in linkedDevices {
guard hexEncodedPublicKey != userHexEncodedPublicKey else { continue }
let thread = TSContactThread.getOrCreateThread(withContactId: hexEncodedPublicKey, transaction: transaction)
@objc(syncProfile)
public static func syncProfile() {
try! Storage.writeSync { transaction in
let userPublicKey = getUserHexEncodedPublicKey()
let linkedDevices = LokiDatabaseUtilities.getLinkedDeviceHexEncodedPublicKeys(for: userPublicKey, in: transaction)
for publicKey in linkedDevices {
guard publicKey != userPublicKey else { continue }
let thread = TSContactThread.getOrCreateThread(withContactId: publicKey, transaction: transaction)
let syncMessage = OWSOutgoingSyncMessage.init(in: thread, messageBody: "", attachmentId: nil)
syncMessage.save(with: transaction)
let messageSenderJobQueue = SSKEnvironment.shared.messageSenderJobQueue

View file

@ -1126,8 +1126,9 @@ NSString *NSStringForOutgoingMessageRecipientState(OWSOutgoingMessageRecipientSt
- (SSKProtoContentBuilder *)prepareCustomContentBuilder:(SignalRecipient *)recipient {
SSKProtoDataMessage *_Nullable dataMessage = [self buildDataMessage:recipient.recipientId];
if (!dataMessage) {
OWSFailDebug(@"could not build protobuf");
OWSFailDebug(@"Couldn't build protobuf.");
return nil;
}
@ -1140,11 +1141,11 @@ NSString *NSStringForOutgoingMessageRecipientState(OWSOutgoingMessageRecipientSt
- (nullable NSData *)buildPlainTextData:(SignalRecipient *)recipient
{
SSKProtoContentBuilder *contentBuilder = [self prepareCustomContentBuilder:recipient];
NSError *error;
NSData *_Nullable contentData = [contentBuilder buildSerializedDataAndReturnError:&error];
if (error || !contentData) {
OWSFailDebug(@"could not serialize protobuf: %@", error);
OWSFailDebug(@"Couldn't serialize protobuf due to error: %@.", error);
return nil;
}