Renamed functions to avoid confusion

pull/19/head
Mikunj 6 years ago
parent ce31576176
commit 10e5ef3e5c

@ -121,7 +121,7 @@ public final class FriendRequestExpireJob : NSObject {
guard let strongSelf = self else { return }
strongSelf.databaseConnection.readWrite { transaction in
strongSelf.messageFinder.enumurateExpiredMessages(with: { message in
strongSelf.messageFinder.enumurateMessagesPendingExpiration(with: { message in
// Sanity check
guard message.friendRequestExpiresAt <= now else {
@ -129,7 +129,7 @@ public final class FriendRequestExpireJob : NSObject {
return;
}
// Check that we only expire sent messages
// Check that we only expire sent friend requests
guard message is TSOutgoingMessage && message.isFriendRequest else {
// Set message to not expire, so our other logic works correctly
message.saveFriendRequestExpires(at: 0, with: transaction)

@ -24,14 +24,14 @@ public class FriendRequestExpireMessageFinder : NSObject {
return expireTime
}
public func enumurateExpiredMessages(with block: (TSMessage) -> Void, transaction: YapDatabaseReadTransaction) {
for messageId in fetchExpiredMessageIds(with: transaction) {
public func enumurateMessagesPendingExpiration(with block: (TSMessage) -> Void, transaction: YapDatabaseReadTransaction) {
for messageId in fetchMessagePendingExpirationIds(with: transaction) {
guard let message = TSMessage.fetch(uniqueId: messageId, transaction: transaction) else { continue }
block(message)
}
}
private func fetchExpiredMessageIds(with transaction: YapDatabaseReadTransaction) -> [String] {
private func fetchMessagePendingExpirationIds(with transaction: YapDatabaseReadTransaction) -> [String] {
var messageIds = [String]()
let now = NSDate.ows_millisecondTimeStamp()
@ -60,7 +60,7 @@ public extension FriendRequestExpireMessageFinder {
let handler = YapDatabaseSecondaryIndexHandler.withObjectBlock { (transaction, dict, collection, key, object) in
guard let message = object as? TSMessage else { return }
// Only select messages whose status is sent
// Only select sent friend requests
guard message is TSOutgoingMessage && message.isFriendRequest else { return }
// TODO: Replace this with unlock timer

Loading…
Cancel
Save