pull/161/head
nielsandriesse 5 years ago
parent 9b5c61e301
commit 8672577a8b

@ -805,7 +805,7 @@ static BOOL isInternalTestVersion = NO;
NSDate *lastProfilePictureUpload = (NSDate *)[userDefaults objectForKey:@"lastProfilePictureUpload"]; NSDate *lastProfilePictureUpload = (NSDate *)[userDefaults objectForKey:@"lastProfilePictureUpload"];
if (lastProfilePictureUpload != nil && [now timeIntervalSinceDate:lastProfilePictureUpload] > 14 * 24 * 60 * 60) { if (lastProfilePictureUpload != nil && [now timeIntervalSinceDate:lastProfilePictureUpload] > 14 * 24 * 60 * 60) {
OWSProfileManager *profileManager = OWSProfileManager.sharedManager; OWSProfileManager *profileManager = OWSProfileManager.sharedManager;
NSString *displayName = [profileManager profileNameForRecipientId:userHexEncodedPublicKey]; NSString *displayName = [profileManager profileNameForRecipientWithID:userHexEncodedPublicKey];
UIImage *profilePicture = [profileManager profileAvatarForRecipientId:userHexEncodedPublicKey]; UIImage *profilePicture = [profileManager profileAvatarForRecipientId:userHexEncodedPublicKey];
[profileManager updateLocalProfileName:displayName avatarImage:profilePicture success:^{ [profileManager updateLocalProfileName:displayName avatarImage:profilePicture success:^{
// Do nothing; the user defaults flag is updated in LokiFileServerAPI // Do nothing; the user defaults flag is updated in LokiFileServerAPI

@ -80,7 +80,7 @@ final class SettingsVC : BaseVC, AvatarViewHelperDelegate {
profilePictureView.hexEncodedPublicKey = userHexEncodedPublicKey profilePictureView.hexEncodedPublicKey = userHexEncodedPublicKey
profilePictureView.update() profilePictureView.update()
// Set up display name label // Set up display name label
displayNameLabel.text = OWSProfileManager.shared().profileName(forRecipientId: userHexEncodedPublicKey) displayNameLabel.text = OWSProfileManager.shared().profileNameForRecipient(withID: userHexEncodedPublicKey)
// Set up display name container // Set up display name container
let displayNameContainer = UIView() let displayNameContainer = UIView()
displayNameContainer.addSubview(displayNameLabel) displayNameContainer.addSubview(displayNameLabel)
@ -259,7 +259,7 @@ final class SettingsVC : BaseVC, AvatarViewHelperDelegate {
} }
private func updateProfile(isUpdatingDisplayName: Bool, isUpdatingProfilePicture: Bool) { private func updateProfile(isUpdatingDisplayName: Bool, isUpdatingProfilePicture: Bool) {
let displayName = displayNameToBeUploaded ?? OWSProfileManager.shared().profileName(forRecipientId: userHexEncodedPublicKey) let displayName = displayNameToBeUploaded ?? OWSProfileManager.shared().profileNameForRecipient(withID: userHexEncodedPublicKey)
let profilePicture = profilePictureToBeUploaded ?? OWSProfileManager.shared().profileAvatar(forRecipientId: userHexEncodedPublicKey) let profilePicture = profilePictureToBeUploaded ?? OWSProfileManager.shared().profileAvatar(forRecipientId: userHexEncodedPublicKey)
ModalActivityIndicatorViewController.present(fromViewController: navigationController!, canCancel: false) { [weak self] modalActivityIndicator in ModalActivityIndicatorViewController.present(fromViewController: navigationController!, canCancel: false) { [weak self] modalActivityIndicator in
OWSProfileManager.shared().updateLocalProfileName(displayName, avatarImage: profilePicture, success: { OWSProfileManager.shared().updateLocalProfileName(displayName, avatarImage: profilePicture, success: {

@ -347,7 +347,7 @@
[nameView autoPinLeadingToTrailingEdgeOfView:avatarView offset:16.f]; [nameView autoPinLeadingToTrailingEdgeOfView:avatarView offset:16.f];
UILabel *titleLabel = [UILabel new]; UILabel *titleLabel = [UILabel new];
NSString *_Nullable localProfileName = [OWSProfileManager.sharedManager profileNameForRecipientId:hexEncodedPublicKey]; NSString *_Nullable localProfileName = [OWSProfileManager.sharedManager profileNameForRecipientWithID:hexEncodedPublicKey];
if (localProfileName.length > 0) { if (localProfileName.length > 0) {
titleLabel.text = localProfileName; titleLabel.text = localProfileName;
titleLabel.textColor = [Theme primaryColor]; titleLabel.textColor = [Theme primaryColor];

@ -2105,7 +2105,7 @@ typedef enum : NSUInteger {
[alert addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { [alert addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
uint64_t messageID = 0; uint64_t messageID = 0;
if ([conversationViewItem.interaction isKindOfClass:TSMessage.class]) { if ([conversationViewItem.interaction isKindOfClass:TSMessage.class]) {
messageID = ((TSMessage *)conversationViewItem.interaction).groupChatServerID; messageID = ((TSMessage *)conversationViewItem.interaction).openGroupServerMessageID;
} }
[LKPublicChatAPI reportMessageWithID:messageID inChannel:1 onServer:@"https://chat.getsession.org"]; [LKPublicChatAPI reportMessageWithID:messageID inChannel:1 onServer:@"https://chat.getsession.org"];
}]]; }]];

@ -1185,7 +1185,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
// Make sure it's a public chat message // Make sure it's a public chat message
TSMessage *message = (TSMessage *)self.interaction; TSMessage *message = (TSMessage *)self.interaction;
if (!message.isGroupChatMessage) return; if (!message.isOpenGroupMessage) return;
__block LKPublicChat *publicChat; __block LKPublicChat *publicChat;
[self.primaryStorage.dbReadConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) { [self.primaryStorage.dbReadConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
@ -1195,7 +1195,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
// Delete the message // Delete the message
BOOL isSentByUser = (interationType == OWSInteractionType_OutgoingMessage); BOOL isSentByUser = (interationType == OWSInteractionType_OutgoingMessage);
[[LKPublicChatAPI deleteMessageWithID:message.groupChatServerID forGroup:publicChat.channel onServer:publicChat.server isSentByUser:isSentByUser].catch(^(NSError *error) { [[LKPublicChatAPI deleteMessageWithID:message.openGroupServerMessageID forGroup:publicChat.channel onServer:publicChat.server isSentByUser:isSentByUser].catch(^(NSError *error) {
// Roll back // Roll back
[self.interaction save]; [self.interaction save];
}) retainUntilComplete]; }) retainUntilComplete];
@ -1260,7 +1260,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
// Make sure it's a public chat message // Make sure it's a public chat message
TSMessage *message = (TSMessage *)self.interaction; TSMessage *message = (TSMessage *)self.interaction;
if (!message.isGroupChatMessage) return false; if (!message.isOpenGroupMessage) return false;
// Ensure we have the details needed to contact the server // Ensure we have the details needed to contact the server
__block LKPublicChat *publicChat; __block LKPublicChat *publicChat;

@ -2822,3 +2822,4 @@
"Push Notifications" = "Push Notifications"; "Push Notifications" = "Push Notifications";
"Confirm" = "Confirm"; "Confirm" = "Confirm";
"Skip" = "Skip"; "Skip" = "Skip";
"Link Previews" = "Link Previews";

@ -188,13 +188,6 @@ const CGFloat kContactCellAvatarTextMargin = 12;
threadName = NSLocalizedString(@"NOTE_TO_SELF", @"Label for 1:1 conversation with yourself."); threadName = NSLocalizedString(@"NOTE_TO_SELF", @"Label for 1:1 conversation with yourself.");
} }
// NSAttributedString *attributedText =
// [[NSAttributedString alloc] initWithString:threadName
// attributes:@{
// NSForegroundColorAttributeName : [Theme primaryColor],
// }];
// self.nameLabel.attributedText = attributedText;
if ([thread isKindOfClass:[TSContactThread class]]) { if ([thread isKindOfClass:[TSContactThread class]]) {
self.recipientId = thread.contactIdentifier; self.recipientId = thread.contactIdentifier;

@ -59,10 +59,7 @@ NS_ASSUME_NONNULL_BEGIN
_contactsManager = Environment.shared.contactsManager; _contactsManager = Environment.shared.contactsManager;
_profileManager = [OWSProfileManager sharedManager]; _profileManager = [OWSProfileManager sharedManager];
// We don't want to notify the delegate in the `updateContacts`.
// self.shouldNotifyDelegateOfUpdatedContacts = YES;
[self updateContacts]; [self updateContacts];
self.shouldNotifyDelegateOfUpdatedContacts = NO;
[self observeNotifications]; [self observeNotifications];
@ -432,7 +429,7 @@ NS_ASSUME_NONNULL_BEGIN
[CNLabeledValue labeledValueWithLabel:CNLabelPhoneNumberMain value:phoneNumber]; [CNLabeledValue labeledValueWithLabel:CNLabelPhoneNumberMain value:phoneNumber];
newContact.phoneNumbers = @[ labeledPhoneNumber ]; newContact.phoneNumbers = @[ labeledPhoneNumber ];
newContact.givenName = [self.profileManager profileNameForRecipientId:recipientId]; newContact.givenName = [self.profileManager profileNameForRecipientWithID:recipientId];
contactViewController = [CNContactViewController viewControllerForNewContact:newContact]; contactViewController = [CNContactViewController viewControllerForNewContact:newContact];
} }

@ -118,10 +118,6 @@ public class OWSNavigationBar: UINavigationBar {
// remove hairline below bar. // remove hairline below bar.
self.shadowImage = UIImage() self.shadowImage = UIImage()
// On iOS11, despite inserting the blur at 0, other views are later inserted into the navbar behind the blur,
// so we have to set a zindex to avoid obscuring navbar title/buttons.
// blurEffectView.layer.zPosition = -1
} }
} }

@ -806,8 +806,6 @@ public class SignalAttachment: NSObject {
var maxSizeRect = CGRect.zero var maxSizeRect = CGRect.zero
maxSizeRect.size = CGSize(width: maxSize, height: maxSize) maxSizeRect.size = CGSize(width: maxSize, height: maxSize)
let newSize = AVMakeRect(aspectRatio: scrSize, insideRect: maxSizeRect).size let newSize = AVMakeRect(aspectRatio: scrSize, insideRect: maxSizeRect).size
// assert(newSize.width <= maxSize)
// assert(newSize.height <= maxSize)
let colorSpace = CGColorSpaceCreateDeviceRGB() let colorSpace = CGColorSpaceCreateDeviceRGB()
let bitmapInfo: CGBitmapInfo = [ let bitmapInfo: CGBitmapInfo = [

@ -726,7 +726,7 @@ NSString *const OWSContactsManagerKeyNextFullIntersectionDate = @"OWSContactsMan
- (nullable NSString *)formattedProfileNameForRecipientId:(NSString *)recipientId - (nullable NSString *)formattedProfileNameForRecipientId:(NSString *)recipientId
{ {
NSString *_Nullable profileName = [self.profileManager profileNameForRecipientId:recipientId]; NSString *_Nullable profileName = [self.profileManager profileNameForRecipientWithID:recipientId];
if (profileName.length == 0) { if (profileName.length == 0) {
return nil; return nil;
} }
@ -739,7 +739,7 @@ NSString *const OWSContactsManagerKeyNextFullIntersectionDate = @"OWSContactsMan
- (nullable NSString *)profileNameForRecipientId:(NSString *)recipientId - (nullable NSString *)profileNameForRecipientId:(NSString *)recipientId
{ {
return [self.profileManager profileNameForRecipientId:recipientId]; return [self.profileManager profileNameForRecipientWithID:recipientId];
} }
- (nullable NSString *)nameFromSystemContactsForRecipientId:(NSString *)recipientId - (nullable NSString *)nameFromSystemContactsForRecipientId:(NSString *)recipientId
@ -900,7 +900,7 @@ NSString *const OWSContactsManagerKeyNextFullIntersectionDate = @"OWSContactsMan
return savedContactName; return savedContactName;
} }
NSString *_Nullable profileName = [self.profileManager profileNameForRecipientId:recipientId]; NSString *_Nullable profileName = [self.profileManager profileNameForRecipientWithID:recipientId];
if (profileName.length > 0) { if (profileName.length > 0) {
NSString *numberAndProfileNameFormat = NSLocalizedString(@"PROFILE_NAME_AND_PHONE_NUMBER_LABEL_FORMAT", NSString *numberAndProfileNameFormat = NSLocalizedString(@"PROFILE_NAME_AND_PHONE_NUMBER_LABEL_FORMAT",
@"Label text combining the phone number and profile name separated by a simple demarcation character. " @"Label text combining the phone number and profile name separated by a simple demarcation character. "
@ -950,7 +950,7 @@ NSString *const OWSContactsManagerKeyNextFullIntersectionDate = @"OWSContactsMan
return [[NSAttributedString alloc] initWithString:savedContactName attributes:primaryAttributes]; return [[NSAttributedString alloc] initWithString:savedContactName attributes:primaryAttributes];
} }
NSString *_Nullable profileName = [self.profileManager profileNameForRecipientId:recipientId]; NSString *_Nullable profileName = [self.profileManager profileNameForRecipientWithID:recipientId];
if (profileName.length > 0) { if (profileName.length > 0) {
return [[NSAttributedString alloc] initWithString:profileName]; return [[NSAttributedString alloc] initWithString:profileName];
// Loki: Original code // Loki: Original code
@ -980,7 +980,7 @@ NSString *const OWSContactsManagerKeyNextFullIntersectionDate = @"OWSContactsMan
NSString *formattedPhoneNumber = NSString *formattedPhoneNumber =
[PhoneNumber bestEffortFormatPartialUserSpecifiedTextToLookLikeAPhoneNumber:recipientId]; [PhoneNumber bestEffortFormatPartialUserSpecifiedTextToLookLikeAPhoneNumber:recipientId];
NSString *_Nullable profileName = [self.profileManager profileNameForRecipientId:recipientId]; NSString *_Nullable profileName = [self.profileManager profileNameForRecipientWithID:recipientId];
if (profileName.length > 0) { if (profileName.length > 0) {
NSString *numberAndProfileNameFormat = NSLocalizedString(@"PROFILE_NAME_AND_PHONE_NUMBER_LABEL_FORMAT", NSString *numberAndProfileNameFormat = NSLocalizedString(@"PROFILE_NAME_AND_PHONE_NUMBER_LABEL_FORMAT",
@"Label text combining the phone number and profile name separated by a simple demarcation character. " @"Label text combining the phone number and profile name separated by a simple demarcation character. "

@ -75,7 +75,7 @@ extern const NSUInteger kOWSProfileManager_MaxAvatarDiameter;
- (nullable OWSAES256Key *)profileKeyForRecipientId:(NSString *)recipientId; - (nullable OWSAES256Key *)profileKeyForRecipientId:(NSString *)recipientId;
- (nullable NSString *)profileNameForRecipientId:(NSString *)recipientId; - (nullable NSString *)profileNameForRecipientWithID:(NSString *)recipientID;
- (nullable UIImage *)profileAvatarForRecipientId:(NSString *)recipientId; - (nullable UIImage *)profileAvatarForRecipientId:(NSString *)recipientId;
- (nullable NSData *)profileAvatarDataForRecipientId:(NSString *)recipientId; - (nullable NSData *)profileAvatarDataForRecipientId:(NSString *)recipientId;

@ -465,7 +465,7 @@ typedef void (^ProfileManagerFailureBlock)(NSError *error);
successBlock(); successBlock();
} }
- (void)updateServiceWithProfileName:(nullable NSString *)localProfileName avatarUrl:(nullable NSString *)avatarURL { - (void)updateServiceWithProfileName:(nullable NSString *)localProfileName avatarURL:(nullable NSString *)avatarURL {
[self updateServiceWithProfileName:localProfileName avatarUrl:avatarURL success:^{} failure:^(NSError * _Nonnull error) {}]; [self updateServiceWithProfileName:localProfileName avatarUrl:avatarURL success:^{} failure:^(NSError * _Nonnull error) {}];
} }
@ -983,7 +983,6 @@ typedef void (^ProfileManagerFailureBlock)(NSError *error);
[userProfile updateWithAvatarUrlPath:avatarURL avatarFileName:nil dbConnection:self.dbConnection completion:^{ [userProfile updateWithAvatarUrlPath:avatarURL avatarFileName:nil dbConnection:self.dbConnection completion:^{
[self downloadAvatarForUserProfile:userProfile]; [self downloadAvatarForUserProfile:userProfile];
}]; }];
// [self fetchProfileForRecipientId:recipientId];
}); });
}]; }];
}); });
@ -1012,14 +1011,14 @@ typedef void (^ProfileManagerFailureBlock)(NSError *error);
return userProfile.profileKey; return userProfile.profileKey;
} }
- (nullable NSString *)profileNameForRecipientId:(NSString *)recipientId - (nullable NSString *)profileNameForRecipientWithID:(NSString *)recipientID
{ {
OWSAssertDebug(recipientId.length > 0); OWSAssertDebug(recipientID.length > 0);
// For "local reads", use the local user profile. // For "local reads", use the local user profile.
OWSUserProfile *userProfile = ([self.tsAccountManager.localNumber isEqualToString:recipientId] OWSUserProfile *userProfile = ([self.tsAccountManager.localNumber isEqualToString:recipientID]
? self.localUserProfile ? self.localUserProfile
: [OWSUserProfile getOrBuildUserProfileForRecipientId:recipientId dbConnection:self.dbConnection]); : [OWSUserProfile getOrBuildUserProfileForRecipientId:recipientID dbConnection:self.dbConnection]);
return userProfile.profileName; return userProfile.profileName;
} }

@ -259,7 +259,6 @@ NSString *const TSGroupThread_NotificationKey_UniqueId = @"TSGroupThread_Notific
} }
self.groupModel.groupMemberIds = newGroupMemberIDs.allObjects; self.groupModel.groupMemberIds = newGroupMemberIDs.allObjects;
[self saveWithTransaction:transaction]; [self saveWithTransaction:transaction];
[transaction addCompletionQueue:dispatch_get_main_queue() completionBlock:^{ [transaction addCompletionQueue:dispatch_get_main_queue() completionBlock:^{
[NSNotificationCenter.defaultCenter postNotificationName:NSNotification.groupThreadUpdated object:self.uniqueId]; [NSNotificationCenter.defaultCenter postNotificationName:NSNotification.groupThreadUpdated object:self.uniqueId];
}]; }];

@ -105,7 +105,7 @@ NS_ASSUME_NONNULL_BEGIN
linkPreview:transcript.linkPreview]; linkPreview:transcript.linkPreview];
if (serverID != 0) { if (serverID != 0) {
outgoingMessage.groupChatServerID = serverID; outgoingMessage.openGroupServerMessageID = serverID;
} }
NSArray<TSAttachmentPointer *> *attachmentPointers = NSArray<TSAttachmentPointer *> *attachmentPointers =

@ -172,7 +172,7 @@ public final class LokiPublicChatPoller : NSObject {
if (message.displayName.count > 0) { if (message.displayName.count > 0) {
SSKEnvironment.shared.profileManager.updateProfileForContact(withID: masterHexEncodedPublicKey!, displayName: message.displayName, with: transaction) SSKEnvironment.shared.profileManager.updateProfileForContact(withID: masterHexEncodedPublicKey!, displayName: message.displayName, with: transaction)
} }
SSKEnvironment.shared.profileManager.updateService(withProfileName: message.displayName, avatarUrl: profilePicture.url) SSKEnvironment.shared.profileManager.updateService(withProfileName: message.displayName, avatarURL: profilePicture.url)
SSKEnvironment.shared.profileManager.setProfileKeyData(profilePicture.profileKey, forRecipientId: masterHexEncodedPublicKey!, avatarURL: profilePicture.url) SSKEnvironment.shared.profileManager.setProfileKeyData(profilePicture.profileKey, forRecipientId: masterHexEncodedPublicKey!, avatarURL: profilePicture.url)
} }
} }

@ -18,7 +18,7 @@ public final class LokiDatabaseUtilities : NSObject {
} }
return (senderHexEncodedPublicKey == quoteeHexEncodedPublicKey) && (interaction.uniqueThreadId == threadID) return (senderHexEncodedPublicKey == quoteeHexEncodedPublicKey) && (interaction.uniqueThreadId == threadID)
}, with: transaction).first as! TSMessage? else { return 0 } }, with: transaction).first as! TSMessage? else { return 0 }
return message.groupChatServerID return message.openGroupServerMessageID
} }
// MARK: Device Links // MARK: Device Links

@ -3,17 +3,17 @@
This class is used for finding friend request messages which are pending expiration. This class is used for finding friend request messages which are pending expiration.
Modeled after `OWSDisappearingMessagesFinder`. Modeled after `OWSDisappearingMessagesFinder`.
*/ */
@objc(LKFriendRequestExpirationMessageFinder) @objc(LKExpiringFriendRequestFinder)
public final class FriendRequestExpirationMessageFinder : NSObject { public final class ExpiringFriendRequestFinder : NSObject {
private static let friendRequestExpireColumn = "friend_request_expires_at" private static let friendRequestExpireColumn = "friend_request_expires_at"
private static let friendRequestExpireIndex = "loki_index_friend_request_expires_at" private static let friendRequestExpireIndex = "loki_index_friend_request_expires_at"
public func nextExpirationTimestamp(with transaction: YapDatabaseReadTransaction) -> UInt64? { public func nextExpirationTimestamp(with transaction: YapDatabaseReadTransaction) -> UInt64? {
let query = "WHERE \(FriendRequestExpirationMessageFinder.friendRequestExpireColumn) > 0 ORDER BY \(FriendRequestExpirationMessageFinder.friendRequestExpireColumn) ASC" let query = "WHERE \(ExpiringFriendRequestFinder.friendRequestExpireColumn) > 0 ORDER BY \(ExpiringFriendRequestFinder.friendRequestExpireColumn) ASC"
let dbQuery = YapDatabaseQuery(string: query, parameters: []) let dbQuery = YapDatabaseQuery(string: query, parameters: [])
let ext = transaction.ext(FriendRequestExpirationMessageFinder.friendRequestExpireIndex) as? YapDatabaseSecondaryIndexTransaction let ext = transaction.ext(ExpiringFriendRequestFinder.friendRequestExpireIndex) as? YapDatabaseSecondaryIndexTransaction
var firstMessage: TSMessage? = nil var firstMessage: TSMessage? = nil
ext?.enumerateKeysAndObjects(matching: dbQuery) { (collection, key, object, stop) in ext?.enumerateKeysAndObjects(matching: dbQuery) { (collection, key, object, stop) in
firstMessage = object as? TSMessage firstMessage = object as? TSMessage
@ -36,10 +36,10 @@ public final class FriendRequestExpirationMessageFinder : NSObject {
var messageIds = [String]() var messageIds = [String]()
let now = NSDate.ows_millisecondTimeStamp() let now = NSDate.ows_millisecondTimeStamp()
let query = "WHERE \(FriendRequestExpirationMessageFinder.friendRequestExpireColumn) > 0 AND \(FriendRequestExpirationMessageFinder.friendRequestExpireColumn) <= \(now)" let query = "WHERE \(ExpiringFriendRequestFinder.friendRequestExpireColumn) > 0 AND \(ExpiringFriendRequestFinder.friendRequestExpireColumn) <= \(now)"
// When (friendRequestExpiresAt == 0) then the friend request SHOULD NOT be set to expired // When (friendRequestExpiresAt == 0) then the friend request SHOULD NOT be set to expired
let dbQuery = YapDatabaseQuery(string: query, parameters: []) let dbQuery = YapDatabaseQuery(string: query, parameters: [])
if let ext = transaction.ext(FriendRequestExpirationMessageFinder.friendRequestExpireIndex) as? YapDatabaseSecondaryIndexTransaction { if let ext = transaction.ext(ExpiringFriendRequestFinder.friendRequestExpireIndex) as? YapDatabaseSecondaryIndexTransaction {
ext.enumerateKeys(matching: dbQuery) { (_, key, _) in ext.enumerateKeys(matching: dbQuery) { (_, key, _) in
messageIds.append(key) messageIds.append(key)
} }
@ -52,7 +52,7 @@ public final class FriendRequestExpirationMessageFinder : NSObject {
// MARK: Database Extension // MARK: Database Extension
public extension FriendRequestExpirationMessageFinder { public extension ExpiringFriendRequestFinder {
@objc public static var indexDatabaseExtension: YapDatabaseSecondaryIndex { @objc public static var indexDatabaseExtension: YapDatabaseSecondaryIndex {
let setup = YapDatabaseSecondaryIndexSetup() let setup = YapDatabaseSecondaryIndexSetup()

@ -5,7 +5,7 @@
@objc(LKFriendRequestExpirationJob) @objc(LKFriendRequestExpirationJob)
public final class FriendRequestExpirationJob : NSObject { public final class FriendRequestExpirationJob : NSObject {
private let databaseConnection: YapDatabaseConnection private let databaseConnection: YapDatabaseConnection
private let messageFinder = FriendRequestExpirationMessageFinder() private let messageFinder = ExpiringFriendRequestFinder()
// These properties should only be accessed on the main thread. // These properties should only be accessed on the main thread.
private var hasStarted = false private var hasStarted = false

@ -1,5 +1,5 @@
// For some reason NSLog doesn't seem to work. This is a workaround to still allow debugging from Obj-C. // For some reason NSLog doesn't seem to work from SignalServiceKit. This is a workaround to still allow debugging from Obj-C.
@objc(LKLogger) @objc(LKLogger)
public final class ObjC_Logger : NSObject { public final class ObjC_Logger : NSObject {

@ -19,7 +19,7 @@ public final class UserDisplayNameUtilities : NSObject {
if hexEncodedPublicKey == userHexEncodedPublicKey { if hexEncodedPublicKey == userHexEncodedPublicKey {
return userDisplayName return userDisplayName
} else { } else {
return SSKEnvironment.shared.profileManager.profileName(forRecipientId: hexEncodedPublicKey) return SSKEnvironment.shared.profileManager.profileNameForRecipient(withID: hexEncodedPublicKey)
} }
} }

@ -500,7 +500,7 @@ typedef void (^AttachmentDownloadFailure)(NSError *error);
manager.completionQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); manager.completionQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
// We want to avoid large downloads from a compromised or buggy service. // We want to avoid large downloads from a compromised or buggy service.
const long kMaxDownloadSize = 12 * 1024 * 1024; const long kMaxDownloadSize = 10 * 1024 * 1024;
__block BOOL hasCheckedContentLength = NO; __block BOOL hasCheckedContentLength = NO;
NSString *tempFilePath = NSString *tempFilePath =

@ -36,7 +36,6 @@ NSUInteger const TSAttachmentSchemaVersion = 4;
albumMessageId:(nullable NSString *)albumMessageId albumMessageId:(nullable NSString *)albumMessageId
{ {
OWSAssertDebug(serverId > 0); OWSAssertDebug(serverId > 0);
// OWSAssertDebug(encryptionKey.length > 0);
if (byteCount <= 0) { if (byteCount <= 0) {
// This will fail with legacy iOS clients which don't upload attachment size. // This will fail with legacy iOS clients which don't upload attachment size.
OWSLogWarn(@"Missing byteCount for attachment with serverId: %lld", serverId); OWSLogWarn(@"Missing byteCount for attachment with serverId: %lld", serverId);
@ -138,7 +137,6 @@ NSUInteger const TSAttachmentSchemaVersion = 4;
{ {
if (!pointer.lazyRestoreFragment) { if (!pointer.lazyRestoreFragment) {
OWSAssertDebug(pointer.serverId > 0); OWSAssertDebug(pointer.serverId > 0);
// OWSAssertDebug(pointer.encryptionKey.length > 0);
if (pointer.byteCount <= 0) { if (pointer.byteCount <= 0) {
// This will fail with legacy iOS clients which don't upload attachment size. // This will fail with legacy iOS clients which don't upload attachment size.
OWSLogWarn(@"Missing pointer.byteCount for attachment with serverId: %lld", pointer.serverId); OWSLogWarn(@"Missing pointer.byteCount for attachment with serverId: %lld", pointer.serverId);

@ -80,7 +80,6 @@ NS_ASSUME_NONNULL_BEGIN
TSOutgoingMessageRecipientState *_Nullable recipientState = TSOutgoingMessageRecipientState *_Nullable recipientState =
[self.message recipientStateForRecipientId:recipientId]; [self.message recipientStateForRecipientId:recipientId];
if (!recipientState) { if (!recipientState) {
// OWSFailDebug(@"missing recipient state for: %@", recipientId);
continue; continue;
} }
if (recipientState.state != OWSOutgoingMessageRecipientStateSent) { if (recipientState.state != OWSOutgoingMessageRecipientStateSent) {

@ -188,10 +188,7 @@ NSString *NSStringFromOWSInteractionType(OWSInteractionType value)
{ {
OWSAssertDebug(other); OWSAssertDebug(other);
// uint64_t sortId1 = self.sortId; // Loki: Sort the messages by the sender's timestamp (Signal uses sortId)
// uint64_t sortId2 = other.sortId;
// Loki: Sort the messages by sender's timestamp
uint64_t sortId1 = self.timestamp; uint64_t sortId1 = self.timestamp;
uint64_t sortId2 = other.timestamp; uint64_t sortId2 = other.timestamp;

@ -47,9 +47,9 @@ typedef NS_ENUM(NSInteger, LKMessageFriendRequestStatus) {
@property BOOL skipSave; @property BOOL skipSave;
// P2P // P2P
@property (nonatomic) BOOL isP2P; @property (nonatomic) BOOL isP2P;
// Group chat // Open groups
@property (nonatomic) uint64_t groupChatServerID; // Should ideally be publicChatServerID @property (nonatomic) uint64_t openGroupServerMessageID;
@property (nonatomic, readonly) BOOL isGroupChatMessage; // Should ideally be isPublicChatMessage @property (nonatomic, readonly) BOOL isOpenGroupMessage;
- (instancetype)initInteractionWithTimestamp:(uint64_t)timestamp inThread:(TSThread *)thread NS_UNAVAILABLE; - (instancetype)initInteractionWithTimestamp:(uint64_t)timestamp inThread:(TSThread *)thread NS_UNAVAILABLE;
@ -96,9 +96,9 @@ typedef NS_ENUM(NSInteger, LKMessageFriendRequestStatus) {
- (void)saveFriendRequestStatus:(LKMessageFriendRequestStatus)friendRequestStatus withTransaction:(YapDatabaseReadWriteTransaction *_Nullable)transaction; - (void)saveFriendRequestStatus:(LKMessageFriendRequestStatus)friendRequestStatus withTransaction:(YapDatabaseReadWriteTransaction *_Nullable)transaction;
- (void)saveFriendRequestExpiresAt:(u_int64_t)expiresAt withTransaction:(YapDatabaseReadWriteTransaction *_Nullable)transaction; - (void)saveFriendRequestExpiresAt:(u_int64_t)expiresAt withTransaction:(YapDatabaseReadWriteTransaction *_Nullable)transaction;
#pragma mark - Group Chat #pragma mark - Open Groups
- (void)saveGroupChatServerID:(uint64_t)serverMessageID in:(YapDatabaseReadWriteTransaction *_Nullable)transaction; - (void)saveOpenGroupServerMessageID:(uint64_t)serverMessageID in:(YapDatabaseReadWriteTransaction *_Nullable)transaction;
#pragma mark - Link Preview #pragma mark - Link Preview

@ -82,7 +82,7 @@ static const NSUInteger OWSMessageSchemaVersion = 4;
_linkPreview = linkPreview; _linkPreview = linkPreview;
_friendRequestStatus = LKMessageFriendRequestStatusNone; _friendRequestStatus = LKMessageFriendRequestStatusNone;
_friendRequestExpiresAt = 0; _friendRequestExpiresAt = 0;
_groupChatServerID = -1; _openGroupServerMessageID = -1;
return self; return self;
} }
@ -350,23 +350,22 @@ static const NSUInteger OWSMessageSchemaVersion = 4;
if (attachmentDescription.length > 0 && bodyDescription.length > 0) { if (attachmentDescription.length > 0 && bodyDescription.length > 0) {
// Attachment with caption. // Attachment with caption.
// if ([CurrentAppContext() isRTL]) { if ([CurrentAppContext() isRTL]) {
// return [[bodyDescription stringByAppendingString:@": "] stringByAppendingString:attachmentDescription]; return [[bodyDescription stringByAppendingString:@": "] stringByAppendingString:attachmentDescription];
// } else { } else {
return [[attachmentDescription stringByAppendingString:@": "] stringByAppendingString:bodyDescription]; return [[attachmentDescription stringByAppendingString:@": "] stringByAppendingString:bodyDescription];
// } }
} else if (bodyDescription.length > 0) { } else if (bodyDescription.length > 0) {
return bodyDescription; return bodyDescription;
} else if (attachmentDescription.length > 0) { } else if (attachmentDescription.length > 0) {
return attachmentDescription; return attachmentDescription;
} else if (self.contactShare) { } else if (self.contactShare) {
// if (CurrentAppContext().isRTL) { if (CurrentAppContext().isRTL) {
// return [self.contactShare.name.displayName stringByAppendingString:@" 👤"]; return [self.contactShare.name.displayName stringByAppendingString:@" 👤"];
// } else { } else {
return [@"👤 " stringByAppendingString:self.contactShare.name.displayName]; return [@"👤 " stringByAppendingString:self.contactShare.name.displayName];
// } }
} else { } else {
// OWSFailDebug(@"message has neither body nor attachment.");
// TODO: We should do better here. // TODO: We should do better here.
return @""; return @"";
} }
@ -495,14 +494,14 @@ static const NSUInteger OWSMessageSchemaVersion = 4;
return self.isFriendRequest && self.friendRequestStatus != LKMessageFriendRequestStatusSendingOrFailed; return self.isFriendRequest && self.friendRequestStatus != LKMessageFriendRequestStatusSendingOrFailed;
} }
#pragma mark - Group Chat #pragma mark - Open Groups
- (BOOL)isGroupChatMessage { - (BOOL)isOpenGroupMessage {
return self.groupChatServerID > 0; return self.openGroupServerMessageID > 0;
} }
- (void)saveGroupChatServerID:(uint64_t)serverMessageID in:(YapDatabaseReadWriteTransaction *_Nullable)transaction { - (void)saveOpenGroupServerMessageID:(uint64_t)serverMessageID in:(YapDatabaseReadWriteTransaction *_Nullable)transaction {
self.groupChatServerID = serverMessageID; self.openGroupServerMessageID = serverMessageID;
if (transaction == nil) { if (transaction == nil) {
[self save]; [self save];
[self.dbReadWriteConnection flushTransactionsWithCompletionQueue:dispatch_get_main_queue() completionBlock:^{}]; [self.dbReadWriteConnection flushTransactionsWithCompletionQueue:dispatch_get_main_queue() completionBlock:^{}];
@ -512,7 +511,7 @@ static const NSUInteger OWSMessageSchemaVersion = 4;
} }
} }
#pragma mark - Link Preview #pragma mark - Link Previews
- (void)generateLinkPreviewIfNeededFromURL:(NSString *)url { - (void)generateLinkPreviewIfNeededFromURL:(NSString *)url {
[OWSLinkPreview tryToBuildPreviewInfoObjcWithPreviewUrl:url] [OWSLinkPreview tryToBuildPreviewInfoObjcWithPreviewUrl:url]

@ -693,10 +693,7 @@ NSString *NSStringForOutgoingMessageRecipientState(OWSOutgoingMessageRecipientSt
changeBlock:^(TSOutgoingMessage *message) { changeBlock:^(TSOutgoingMessage *message) {
TSOutgoingMessageRecipientState *_Nullable recipientState TSOutgoingMessageRecipientState *_Nullable recipientState
= message.recipientStateMap[recipientId]; = message.recipientStateMap[recipientId];
if (!recipientState) { if (!recipientState) { return; }
// OWSFailDebug(@"Missing recipient state for recipient: %@", recipientId);
return;
}
recipientState.state = OWSOutgoingMessageRecipientStateSent; recipientState.state = OWSOutgoingMessageRecipientStateSent;
recipientState.wasSentByUD = wasSentByUD; recipientState.wasSentByUD = wasSentByUD;
[message setIsCalculatingPoW:NO]; [message setIsCalculatingPoW:NO];
@ -712,10 +709,7 @@ NSString *NSStringForOutgoingMessageRecipientState(OWSOutgoingMessageRecipientSt
changeBlock:^(TSOutgoingMessage *message) { changeBlock:^(TSOutgoingMessage *message) {
TSOutgoingMessageRecipientState *_Nullable recipientState TSOutgoingMessageRecipientState *_Nullable recipientState
= message.recipientStateMap[recipientId]; = message.recipientStateMap[recipientId];
if (!recipientState) { if (!recipientState) { return; }
// OWSFailDebug(@"Missing recipient state for recipient: %@", recipientId);
return;
}
recipientState.state = OWSOutgoingMessageRecipientStateSkipped; recipientState.state = OWSOutgoingMessageRecipientStateSkipped;
[message setIsCalculatingPoW:NO]; [message setIsCalculatingPoW:NO];
}]; }];

@ -157,8 +157,6 @@ NS_ASSUME_NONNULL_BEGIN
} }
} }
// OWSAssertDebug(bodySource != TSQuotedMessageContentSourceUnknown);
NSMutableArray<OWSAttachmentInfo *> *attachmentInfos = [NSMutableArray new]; NSMutableArray<OWSAttachmentInfo *> *attachmentInfos = [NSMutableArray new];
for (SSKProtoDataMessageQuoteQuotedAttachment *quotedAttachment in quoteProto.attachments) { for (SSKProtoDataMessageQuoteQuotedAttachment *quotedAttachment in quoteProto.attachments) {
hasAttachment = YES; hasAttachment = YES;
@ -208,7 +206,6 @@ NS_ASSUME_NONNULL_BEGIN
} }
if (body.length == 0 && !hasAttachment) { if (body.length == 0 && !hasAttachment) {
// OWSFailDebug(@"quoted message has neither text nor attachment");
return nil; return nil;
} }

@ -78,10 +78,6 @@ NSString *envelopeAddress(SSKProtoEnvelope *envelope)
} else { } else {
// Don't fire an analytics event; if we ever add a new content type, we'd generate a ton of // Don't fire an analytics event; if we ever add a new content type, we'd generate a ton of
// analytics traffic. // analytics traffic.
// Loki: Original code
// ========
// OWSFailDebug(@"Unknown content type.");
// ========
return @"UnknownContent"; return @"UnknownContent";
} }
} }

@ -1601,7 +1601,7 @@ NS_ASSUME_NONNULL_BEGIN
// Loki: Parse Loki specific properties if needed // Loki: Parse Loki specific properties if needed
if (envelope.isPtpMessage) { incomingMessage.isP2P = YES; } if (envelope.isPtpMessage) { incomingMessage.isP2P = YES; }
if (dataMessage.publicChatInfo != nil && dataMessage.publicChatInfo.hasServerID) { incomingMessage.groupChatServerID = dataMessage.publicChatInfo.serverID; } if (dataMessage.publicChatInfo != nil && dataMessage.publicChatInfo.hasServerID) { incomingMessage.openGroupServerMessageID = dataMessage.publicChatInfo.serverID; }
NSArray<TSAttachmentPointer *> *attachmentPointers = NSArray<TSAttachmentPointer *> *attachmentPointers =
[TSAttachmentPointer attachmentPointersFromProtos:dataMessage.attachments [TSAttachmentPointer attachmentPointersFromProtos:dataMessage.attachments

@ -398,8 +398,8 @@ NSString *const OWSMessageDecryptJobFinderExtensionGroup = @"OWSMessageProcessin
OWSAssertDebug(transaction); OWSAssertDebug(transaction);
// Loki: Don't process any messages from ourself // Loki: Don't process any messages from ourself
ECKeyPair *_Nullable keyPair = OWSIdentityManager.sharedManager.identityKeyPair; ECKeyPair *_Nullable userKeyPair = OWSIdentityManager.sharedManager.identityKeyPair;
if (keyPair && [result.source isEqualToString:keyPair.hexEncodedPublicKey]) { if (userKeyPair && [result.source isEqualToString:userKeyPair.hexEncodedPublicKey]) {
dispatch_async(self.serialQueue, ^{ dispatch_async(self.serialQueue, ^{
completion(YES); completion(YES);
}); });

@ -21,7 +21,7 @@ public class OWSMessageSend: NSObject {
@objc @objc
public let recipient: SignalRecipient public let recipient: SignalRecipient
private static let kMaxRetriesPerRecipient: Int = 1 private static let kMaxRetriesPerRecipient: Int = 1 // Loki: We have our own retrying
@objc @objc
public var remainingAttempts = OWSMessageSend.kMaxRetriesPerRecipient public var remainingAttempts = OWSMessageSend.kMaxRetriesPerRecipient

@ -1280,7 +1280,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
[[LKPublicChatAPI sendMessage:groupMessage toGroup:publicChat.channel onServer:publicChat.server] [[LKPublicChatAPI sendMessage:groupMessage toGroup:publicChat.channel onServer:publicChat.server]
.thenOn(OWSDispatch.sendingQueue, ^(LKGroupMessage *groupMessage) { .thenOn(OWSDispatch.sendingQueue, ^(LKGroupMessage *groupMessage) {
[self.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) { [self.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
[message saveGroupChatServerID:groupMessage.serverID in:transaction]; [message saveOpenGroupServerMessageID:groupMessage.serverID in:transaction];
[OWSPrimaryStorage.sharedManager setIDForMessageWithServerID:groupMessage.serverID to:message.uniqueId in:transaction]; [OWSPrimaryStorage.sharedManager setIDForMessageWithServerID:groupMessage.serverID to:message.uniqueId in:transaction];
}]; }];
[self messageSendDidSucceed:messageSend deviceMessages:deviceMessages wasSentByUD:messageSend.isUDSend wasSentByWebsocket:false]; [self messageSendDidSucceed:messageSend deviceMessages:deviceMessages wasSentByUD:messageSend.isUDSend wasSentByWebsocket:false];

@ -151,22 +151,21 @@ const int32_t kGroupIdLength = 16;
if ([newModel.removedMembers containsObject:hexEncodedPublicKey]) { if ([newModel.removedMembers containsObject:hexEncodedPublicKey]) {
updatedGroupInfoString = [updatedGroupInfoString updatedGroupInfoString = [updatedGroupInfoString
stringByAppendingString:NSLocalizedString(@"YOU_WERE_REMOVED", @"")]; stringByAppendingString:NSLocalizedString(@"YOU_WERE_REMOVED", @"")];
} } else {
else { NSArray *removedMemberNames = [[newModel.removedMembers allObjects] map:^NSString*(NSString* item) {
NSArray *removedMembersNames = [[newModel.removedMembers allObjects] map:^NSString*(NSString* item) {
return [contactsManager displayNameForPhoneIdentifier:item]; return [contactsManager displayNameForPhoneIdentifier:item];
}]; }];
if ([removedMembersNames count] > 1) { if ([removedMemberNames count] > 1) {
updatedGroupInfoString = [updatedGroupInfoString updatedGroupInfoString = [updatedGroupInfoString
stringByAppendingString:[NSString stringByAppendingString:[NSString
stringWithFormat:NSLocalizedString(@"GROUP_MEMBERS_REMOVED", @""), stringWithFormat:NSLocalizedString(@"GROUP_MEMBERS_REMOVED", @""),
[removedMembersNames componentsJoinedByString:@", "]]]; [removedMemberNames componentsJoinedByString:@", "]]];
} }
else { else {
updatedGroupInfoString = [updatedGroupInfoString updatedGroupInfoString = [updatedGroupInfoString
stringByAppendingString:[NSString stringByAppendingString:[NSString
stringWithFormat:NSLocalizedString(@"GROUP_MEMBER_REMOVED", @""), stringWithFormat:NSLocalizedString(@"GROUP_MEMBER_REMOVED", @""),
[removedMembersNames componentsJoinedByString:@", "]]]; removedMemberNames[0]]];
} }
} }
} }

@ -64,7 +64,6 @@ NS_ASSUME_NONNULL_BEGIN
+ (TSRequest *)acknowledgeMessageDeliveryRequestWithSource:(NSString *)source timestamp:(UInt64)timestamp + (TSRequest *)acknowledgeMessageDeliveryRequestWithSource:(NSString *)source timestamp:(UInt64)timestamp
{ {
// OWSAssertDebug(source.length > 0);
OWSAssertDebug(timestamp > 0); OWSAssertDebug(timestamp > 0);
NSString *path = [NSString stringWithFormat:@"v1/messages/%@/%llu", source, timestamp]; NSString *path = [NSString stringWithFormat:@"v1/messages/%@/%llu", source, timestamp];
@ -220,7 +219,6 @@ NS_ASSUME_NONNULL_BEGIN
NSString *path = [textSecureAccountsAPI stringByAppendingString:textSecureAttributesAPI]; NSString *path = [textSecureAccountsAPI stringByAppendingString:textSecureAttributesAPI];
NSString *authKey = self.tsAccountManager.serverAuthToken; NSString *authKey = self.tsAccountManager.serverAuthToken;
// OWSAssertDebug(authKey.length > 0);
NSString *_Nullable pin = [self.ows2FAManager pinCode]; NSString *_Nullable pin = [self.ows2FAManager pinCode];
NSDictionary<NSString *, id> *accountAttributes = [self accountAttributesWithPin:pin authKey:authKey]; NSDictionary<NSString *, id> *accountAttributes = [self accountAttributesWithPin:pin authKey:authKey];
@ -321,7 +319,6 @@ NS_ASSUME_NONNULL_BEGIN
+ (NSDictionary<NSString *, id> *)accountAttributesWithPin:(nullable NSString *)pin + (NSDictionary<NSString *, id> *)accountAttributesWithPin:(nullable NSString *)pin
authKey:(NSString *)authKey authKey:(NSString *)authKey
{ {
// OWSAssertDebug(authKey.length > 0);
uint32_t registrationId = [self.tsAccountManager getOrGenerateRegistrationId]; uint32_t registrationId = [self.tsAccountManager getOrGenerateRegistrationId];
BOOL isManualMessageFetchEnabled = self.tsAccountManager.isManualMessageFetchEnabled; BOOL isManualMessageFetchEnabled = self.tsAccountManager.isManualMessageFetchEnabled;

@ -384,7 +384,6 @@ dispatch_queue_t NetworkManagerQueue()
{ {
OWSAssertDebug(failureBlock); OWSAssertDebug(failureBlock);
OWSAssertDebug(request); OWSAssertDebug(request);
// OWSAssertDebug(task);
OWSAssertDebug(networkError); OWSAssertDebug(networkError);
NSInteger statusCode = [task statusCode]; NSInteger statusCode = [task statusCode];
@ -504,7 +503,7 @@ dispatch_queue_t NetworkManagerQueue()
request:(TSRequest *)request request:(TSRequest *)request
statusCode:(NSInteger)statusCode { statusCode:(NSInteger)statusCode {
/* Loki: Original code /* Loki: Original code
* We don't really care about invalid auth * We don't care about invalid auth
* ======== * ========
OWSLogVerbose(@"Invalid auth: %@", task.originalRequest.allHTTPHeaderFields); OWSLogVerbose(@"Invalid auth: %@", task.originalRequest.allHTTPHeaderFields);

@ -79,7 +79,7 @@ public class MessageSenderJobQueue: NSObject, JobQueue {
public typealias DurableOperationType = MessageSenderOperation public typealias DurableOperationType = MessageSenderOperation
public static let jobRecordLabel: String = "MessageSender" public static let jobRecordLabel: String = "MessageSender"
public static let maxRetries: UInt = 1 public static let maxRetries: UInt = 1 // Loki: We have our own retrying
public let requiresInternet: Bool = true public let requiresInternet: Bool = true
public var runningOperations: [MessageSenderOperation] = [] public var runningOperations: [MessageSenderOperation] = []
@ -94,9 +94,10 @@ public class MessageSenderJobQueue: NSObject, JobQueue {
public var isSetup: Bool = false public var isSetup: Bool = false
/// Used when the user clears their database to cancel any outstanding jobs.
@objc public func clearAllJobs() { @objc public func clearAllJobs() {
self.dbConnection.readWrite { transaction in self.dbConnection.readWrite { transaction in
let statuses: [SSKJobRecordStatus] = [ .unknown, .ready, .running, .permanentlyFailed, .unknown ] let statuses: [SSKJobRecordStatus] = [ .unknown, .ready, .running, .permanentlyFailed ]
var records: [SSKJobRecord] = [] var records: [SSKJobRecord] = []
statuses.forEach { statuses.forEach {
records += self.finder.allRecords(label: self.jobRecordLabel, status: $0, transaction: transaction) records += self.finder.allRecords(label: self.jobRecordLabel, status: $0, transaction: transaction)

@ -188,6 +188,7 @@ NSString *const kNSNotificationName_IsCensorshipCircumventionActiveDidChange =
NSURLSessionConfiguration *configuration = NSURLSessionConfiguration.ephemeralSessionConfiguration; NSURLSessionConfiguration *configuration = NSURLSessionConfiguration.ephemeralSessionConfiguration;
AFHTTPSessionManager *sessionManager = [[AFHTTPSessionManager alloc] initWithSessionConfiguration:configuration]; AFHTTPSessionManager *sessionManager = [[AFHTTPSessionManager alloc] initWithSessionConfiguration:configuration];
AFSecurityPolicy *securityPolicy = AFSecurityPolicy.defaultPolicy; AFSecurityPolicy *securityPolicy = AFSecurityPolicy.defaultPolicy;
// Snode to snode communication uses self-signed certificates but clients can safely ignore this
securityPolicy.allowInvalidCertificates = YES; securityPolicy.allowInvalidCertificates = YES;
securityPolicy.validatesDomainName = NO; securityPolicy.validatesDomainName = NO;
sessionManager.securityPolicy = securityPolicy; sessionManager.securityPolicy = securityPolicy;

@ -14,7 +14,7 @@ NS_ASSUME_NONNULL_BEGIN
- (OWSAES256Key *)localProfileKey; - (OWSAES256Key *)localProfileKey;
- (nullable NSString *)localProfileName; - (nullable NSString *)localProfileName;
- (nullable NSString *)profileNameForRecipientId:(NSString *)recipientId; - (nullable NSString *)profileNameForRecipientWithID:(NSString *)recipientID;
- (nullable NSString *)profilePictureURL; - (nullable NSString *)profilePictureURL;
- (nullable NSData *)profileKeyDataForRecipientId:(NSString *)recipientId; - (nullable NSData *)profileKeyDataForRecipientId:(NSString *)recipientId;
@ -33,7 +33,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)fetchProfileForRecipientId:(NSString *)recipientId; - (void)fetchProfileForRecipientId:(NSString *)recipientId;
- (void)updateProfileForContactWithID:(NSString *)contactID displayName:(NSString *)displayName with:(YapDatabaseReadWriteTransaction *)transaction; - (void)updateProfileForContactWithID:(NSString *)contactID displayName:(NSString *)displayName with:(YapDatabaseReadWriteTransaction *)transaction;
- (void)updateServiceWithProfileName:(nullable NSString *)localProfileName avatarUrl:(nullable NSString *)avatarURL; - (void)updateServiceWithProfileName:(nullable NSString *)localProfileName avatarURL:(nullable NSString *)avatarURL;
@end @end

@ -157,25 +157,26 @@ static SSKEnvironment *sharedSSKEnvironment;
} }
#pragma mark - Mutable Accessors #pragma mark - Mutable Accessors
/*
- (nullable id<OWSCallMessageHandler>)callMessageHandler
{
@synchronized(self) {
OWSAssertDebug(_callMessageHandler);
//- (nullable id<OWSCallMessageHandler>)callMessageHandler return _callMessageHandler;
//{ }
// @synchronized(self) { }
// OWSAssertDebug(_callMessageHandler);
// - (void)setCallMessageHandler:(nullable id<OWSCallMessageHandler>)callMessageHandler
// return _callMessageHandler; {
// } @synchronized(self) {
//} OWSAssertDebug(callMessageHandler);
// OWSAssertDebug(!_callMessageHandler);
//- (void)setCallMessageHandler:(nullable id<OWSCallMessageHandler>)callMessageHandler
//{ _callMessageHandler = callMessageHandler;
// @synchronized(self) { }
// OWSAssertDebug(callMessageHandler); }
// OWSAssertDebug(!_callMessageHandler); */
//
// _callMessageHandler = callMessageHandler;
// }
//}
- (nullable id<NotificationsProtocol>)notificationsManager - (nullable id<NotificationsProtocol>)notificationsManager
{ {

@ -216,7 +216,7 @@ void VerifyRegistrationsForPrimaryStorage(OWSStorage *storage)
[SSKJobRecordFinder asyncRegisterDatabaseExtensionObjCWithStorage:self]; [SSKJobRecordFinder asyncRegisterDatabaseExtensionObjCWithStorage:self];
// Loki // Loki
[LKFriendRequestExpirationMessageFinder asyncRegisterDatabaseExtensions:self]; [LKExpiringFriendRequestFinder asyncRegisterDatabaseExtensions:self];
[LKDeviceLinkIndex asyncRegisterDatabaseExtensions:self]; [LKDeviceLinkIndex asyncRegisterDatabaseExtensions:self];
[self.database [self.database

@ -496,8 +496,7 @@ NSString *const kNSUserDefaults_DatabaseExtensionVersionMap = @"kNSUserDefaults_
unarchiver.delegate = unarchiverDelegate; unarchiver.delegate = unarchiverDelegate;
return [unarchiver decodeObjectForKey:@"root"]; return [unarchiver decodeObjectForKey:@"root"];
} @catch (NSException *exception) { } @catch (NSException *exception) {
// Sync log in case we bail. // Sync log in case we bail
// OWSFailDebug(@"error deserializing object: %@, %@", collection, exception);
OWSProdCritical([OWSAnalyticsEvents storageErrorDeserialization]); OWSProdCritical([OWSAnalyticsEvents storageErrorDeserialization]);
@throw exception; @throw exception;
} }

@ -21,7 +21,7 @@ typedef NS_ENUM(NSInteger, TSWhisperMessageType) {
#define textSecureHTTPTimeOut 10 #define textSecureHTTPTimeOut 10
#define kLegalTermsUrlString @"https://github.com/loki-project/loki-messenger-ios/blob/master/privacy-policy.md" #define kLegalTermsUrlString @"https://getsession.org/legal/#privacy-policy"
//#ifndef DEBUG //#ifndef DEBUG

@ -22,7 +22,6 @@ static void *kNSError_MessageSender_IsFatal = &kNSError_MessageSender_IsFatal;
NSNumber *value = objc_getAssociatedObject(self, kNSError_MessageSender_IsRetryable); NSNumber *value = objc_getAssociatedObject(self, kNSError_MessageSender_IsRetryable);
// This value should always be set for all errors by the time OWSSendMessageOperation // This value should always be set for all errors by the time OWSSendMessageOperation
// queries it's value. If not, default to retrying in production. // queries it's value. If not, default to retrying in production.
// OWSAssertDebug(value);
return value ? [value boolValue] : YES; return value ? [value boolValue] : YES;
} }

@ -360,7 +360,7 @@ NSString *NSStringForOWSAnalyticsSeverity(OWSAnalyticsSeverity severity)
location:(const char *)location location:(const char *)location
line:(int)line line:(int)line
{ {
// Loki: Do nothing return; // Loki: Do nothing
DDLogFlag logFlag; DDLogFlag logFlag;
switch (severity) { switch (severity) {
case OWSAnalyticsSeverityInfo: case OWSAnalyticsSeverityInfo:

Loading…
Cancel
Save