pull/213/head
nielsandriesse 5 years ago
parent 6686122461
commit b4d4522e99

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

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

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

Loading…
Cancel
Save