This commit is contained in:
nielsandriesse 2020-04-20 16:53:40 +10:00
parent 9b5c61e301
commit 8672577a8b
46 changed files with 98 additions and 139 deletions

View File

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

View File

@ -80,7 +80,7 @@ final class SettingsVC : BaseVC, AvatarViewHelperDelegate {
profilePictureView.hexEncodedPublicKey = userHexEncodedPublicKey
profilePictureView.update()
// Set up display name label
displayNameLabel.text = OWSProfileManager.shared().profileName(forRecipientId: userHexEncodedPublicKey)
displayNameLabel.text = OWSProfileManager.shared().profileNameForRecipient(withID: userHexEncodedPublicKey)
// Set up display name container
let displayNameContainer = UIView()
displayNameContainer.addSubview(displayNameLabel)
@ -259,7 +259,7 @@ final class SettingsVC : BaseVC, AvatarViewHelperDelegate {
}
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)
ModalActivityIndicatorViewController.present(fromViewController: navigationController!, canCancel: false) { [weak self] modalActivityIndicator in
OWSProfileManager.shared().updateLocalProfileName(displayName, avatarImage: profilePicture, success: {

View File

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

View File

@ -2105,7 +2105,7 @@ typedef enum : NSUInteger {
[alert addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
uint64_t messageID = 0;
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"];
}]];

View File

@ -1185,7 +1185,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
// Make sure it's a public chat message
TSMessage *message = (TSMessage *)self.interaction;
if (!message.isGroupChatMessage) return;
if (!message.isOpenGroupMessage) return;
__block LKPublicChat *publicChat;
[self.primaryStorage.dbReadConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
@ -1195,7 +1195,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
// Delete the message
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
[self.interaction save];
}) retainUntilComplete];
@ -1260,7 +1260,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
// Make sure it's a public chat message
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
__block LKPublicChat *publicChat;

View File

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

View File

@ -188,13 +188,6 @@ const CGFloat kContactCellAvatarTextMargin = 12;
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]]) {
self.recipientId = thread.contactIdentifier;

View File

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

View File

@ -118,10 +118,6 @@ public class OWSNavigationBar: UINavigationBar {
// remove hairline below bar.
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
}
}

View File

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

View File

@ -726,7 +726,7 @@ NSString *const OWSContactsManagerKeyNextFullIntersectionDate = @"OWSContactsMan
- (nullable NSString *)formattedProfileNameForRecipientId:(NSString *)recipientId
{
NSString *_Nullable profileName = [self.profileManager profileNameForRecipientId:recipientId];
NSString *_Nullable profileName = [self.profileManager profileNameForRecipientWithID:recipientId];
if (profileName.length == 0) {
return nil;
}
@ -739,7 +739,7 @@ NSString *const OWSContactsManagerKeyNextFullIntersectionDate = @"OWSContactsMan
- (nullable NSString *)profileNameForRecipientId:(NSString *)recipientId
{
return [self.profileManager profileNameForRecipientId:recipientId];
return [self.profileManager profileNameForRecipientWithID:recipientId];
}
- (nullable NSString *)nameFromSystemContactsForRecipientId:(NSString *)recipientId
@ -900,7 +900,7 @@ NSString *const OWSContactsManagerKeyNextFullIntersectionDate = @"OWSContactsMan
return savedContactName;
}
NSString *_Nullable profileName = [self.profileManager profileNameForRecipientId:recipientId];
NSString *_Nullable profileName = [self.profileManager profileNameForRecipientWithID:recipientId];
if (profileName.length > 0) {
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. "
@ -950,7 +950,7 @@ NSString *const OWSContactsManagerKeyNextFullIntersectionDate = @"OWSContactsMan
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) {
return [[NSAttributedString alloc] initWithString:profileName];
// Loki: Original code
@ -980,7 +980,7 @@ NSString *const OWSContactsManagerKeyNextFullIntersectionDate = @"OWSContactsMan
NSString *formattedPhoneNumber =
[PhoneNumber bestEffortFormatPartialUserSpecifiedTextToLookLikeAPhoneNumber:recipientId];
NSString *_Nullable profileName = [self.profileManager profileNameForRecipientId:recipientId];
NSString *_Nullable profileName = [self.profileManager profileNameForRecipientWithID:recipientId];
if (profileName.length > 0) {
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. "

View File

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

View File

@ -465,7 +465,7 @@ typedef void (^ProfileManagerFailureBlock)(NSError *error);
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) {}];
}
@ -983,7 +983,6 @@ typedef void (^ProfileManagerFailureBlock)(NSError *error);
[userProfile updateWithAvatarUrlPath:avatarURL avatarFileName:nil dbConnection:self.dbConnection completion:^{
[self downloadAvatarForUserProfile:userProfile];
}];
// [self fetchProfileForRecipientId:recipientId];
});
}];
});
@ -1012,14 +1011,14 @@ typedef void (^ProfileManagerFailureBlock)(NSError *error);
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.
OWSUserProfile *userProfile = ([self.tsAccountManager.localNumber isEqualToString:recipientId]
OWSUserProfile *userProfile = ([self.tsAccountManager.localNumber isEqualToString:recipientID]
? self.localUserProfile
: [OWSUserProfile getOrBuildUserProfileForRecipientId:recipientId dbConnection:self.dbConnection]);
: [OWSUserProfile getOrBuildUserProfileForRecipientId:recipientID dbConnection:self.dbConnection]);
return userProfile.profileName;
}

View File

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

View File

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

View File

@ -172,7 +172,7 @@ public final class LokiPublicChatPoller : NSObject {
if (message.displayName.count > 0) {
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)
}
}

View File

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

View File

@ -3,17 +3,17 @@
This class is used for finding friend request messages which are pending expiration.
Modeled after `OWSDisappearingMessagesFinder`.
*/
@objc(LKFriendRequestExpirationMessageFinder)
public final class FriendRequestExpirationMessageFinder : NSObject {
@objc(LKExpiringFriendRequestFinder)
public final class ExpiringFriendRequestFinder : NSObject {
private static let friendRequestExpireColumn = "friend_request_expires_at"
private static let friendRequestExpireIndex = "loki_index_friend_request_expires_at"
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 ext = transaction.ext(FriendRequestExpirationMessageFinder.friendRequestExpireIndex) as? YapDatabaseSecondaryIndexTransaction
let ext = transaction.ext(ExpiringFriendRequestFinder.friendRequestExpireIndex) as? YapDatabaseSecondaryIndexTransaction
var firstMessage: TSMessage? = nil
ext?.enumerateKeysAndObjects(matching: dbQuery) { (collection, key, object, stop) in
firstMessage = object as? TSMessage
@ -36,10 +36,10 @@ public final class FriendRequestExpirationMessageFinder : NSObject {
var messageIds = [String]()
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
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
messageIds.append(key)
}
@ -52,7 +52,7 @@ public final class FriendRequestExpirationMessageFinder : NSObject {
// MARK: Database Extension
public extension FriendRequestExpirationMessageFinder {
public extension ExpiringFriendRequestFinder {
@objc public static var indexDatabaseExtension: YapDatabaseSecondaryIndex {
let setup = YapDatabaseSecondaryIndexSetup()

View File

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

View File

@ -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)
public final class ObjC_Logger : NSObject {

View File

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

View File

@ -500,7 +500,7 @@ typedef void (^AttachmentDownloadFailure)(NSError *error);
manager.completionQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
// 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;
NSString *tempFilePath =

View File

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

View File

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

View File

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

View File

@ -47,9 +47,9 @@ typedef NS_ENUM(NSInteger, LKMessageFriendRequestStatus) {
@property BOOL skipSave;
// P2P
@property (nonatomic) BOOL isP2P;
// Group chat
@property (nonatomic) uint64_t groupChatServerID; // Should ideally be publicChatServerID
@property (nonatomic, readonly) BOOL isGroupChatMessage; // Should ideally be isPublicChatMessage
// Open groups
@property (nonatomic) uint64_t openGroupServerMessageID;
@property (nonatomic, readonly) BOOL isOpenGroupMessage;
- (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)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

View File

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

View File

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

View File

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

View File

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

View File

@ -1601,7 +1601,7 @@ NS_ASSUME_NONNULL_BEGIN
// Loki: Parse Loki specific properties if needed
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 =
[TSAttachmentPointer attachmentPointersFromProtos:dataMessage.attachments

View File

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

View File

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

View File

@ -1280,7 +1280,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
[[LKPublicChatAPI sendMessage:groupMessage toGroup:publicChat.channel onServer:publicChat.server]
.thenOn(OWSDispatch.sendingQueue, ^(LKGroupMessage *groupMessage) {
[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];
}];
[self messageSendDidSucceed:messageSend deviceMessages:deviceMessages wasSentByUD:messageSend.isUDSend wasSentByWebsocket:false];

View File

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

View File

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

View File

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

View File

@ -79,7 +79,7 @@ public class MessageSenderJobQueue: NSObject, JobQueue {
public typealias DurableOperationType = MessageSenderOperation
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 var runningOperations: [MessageSenderOperation] = []
@ -94,9 +94,10 @@ public class MessageSenderJobQueue: NSObject, JobQueue {
public var isSetup: Bool = false
/// Used when the user clears their database to cancel any outstanding jobs.
@objc public func clearAllJobs() {
self.dbConnection.readWrite { transaction in
let statuses: [SSKJobRecordStatus] = [ .unknown, .ready, .running, .permanentlyFailed, .unknown ]
let statuses: [SSKJobRecordStatus] = [ .unknown, .ready, .running, .permanentlyFailed ]
var records: [SSKJobRecord] = []
statuses.forEach {
records += self.finder.allRecords(label: self.jobRecordLabel, status: $0, transaction: transaction)

View File

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

View File

@ -14,7 +14,7 @@ NS_ASSUME_NONNULL_BEGIN
- (OWSAES256Key *)localProfileKey;
- (nullable NSString *)localProfileName;
- (nullable NSString *)profileNameForRecipientId:(NSString *)recipientId;
- (nullable NSString *)profileNameForRecipientWithID:(NSString *)recipientID;
- (nullable NSString *)profilePictureURL;
- (nullable NSData *)profileKeyDataForRecipientId:(NSString *)recipientId;
@ -33,7 +33,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)fetchProfileForRecipientId:(NSString *)recipientId;
- (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

View File

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

View File

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

View File

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

View File

@ -21,7 +21,7 @@ typedef NS_ENUM(NSInteger, TSWhisperMessageType) {
#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

View File

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

View File

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