|
|
|
|
@ -4,6 +4,7 @@ public final class LokiDatabaseUtilities : NSObject {
|
|
|
|
|
|
|
|
|
|
private override init() { }
|
|
|
|
|
|
|
|
|
|
// MARK: Quotes
|
|
|
|
|
@objc(getServerIDForQuoteWithID:quoteeHexEncodedPublicKey:threadID:transaction:)
|
|
|
|
|
public static func getServerID(quoteID: UInt64, quoteeHexEncodedPublicKey: String, threadID: String, transaction: YapDatabaseReadTransaction) -> UInt64 {
|
|
|
|
|
guard let message = TSInteraction.interactions(withTimestamp: quoteID, filter: { interaction in
|
|
|
|
|
@ -20,28 +21,37 @@ public final class LokiDatabaseUtilities : NSObject {
|
|
|
|
|
return message.groupChatServerID
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// MARK: Device Links
|
|
|
|
|
@objc(getMasterHexEncodedPublicKeyFor:in:)
|
|
|
|
|
public static func objc_getMasterHexEncodedPublicKey(for slaveHexEncodedPublicKey: String, in transaction: YapDatabaseReadTransaction) -> String? {
|
|
|
|
|
return OWSPrimaryStorage.shared().getMasterHexEncodedPublicKey(for: slaveHexEncodedPublicKey, in: transaction)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// MARK: Group Chats
|
|
|
|
|
private static let groupChatCollection = "LokiGroupChatCollection"
|
|
|
|
|
|
|
|
|
|
@objc(getAllGroupChats:)
|
|
|
|
|
public static func getAllGroupChats(in transaction: YapDatabaseReadTransaction) -> [String:LokiGroupChat] {
|
|
|
|
|
return OWSPrimaryStorage.shared().getAllGroupChats(in: transaction)
|
|
|
|
|
var result = [String:LokiGroupChat]()
|
|
|
|
|
transaction.enumerateKeysAndObjects(inCollection: groupChatCollection) { threadID, object, _ in
|
|
|
|
|
guard let groupChat = object as? LokiGroupChat else { return }
|
|
|
|
|
result[threadID] = groupChat
|
|
|
|
|
}
|
|
|
|
|
return result
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@objc(getGroupChatForThreadID:transaction:)
|
|
|
|
|
public static func getGroupChat(for threadID: String, in transaction: YapDatabaseReadTransaction) -> LokiGroupChat? {
|
|
|
|
|
return OWSPrimaryStorage.shared().getGroupChat(for: threadID, in: transaction)
|
|
|
|
|
return transaction.object(forKey: threadID, inCollection: groupChatCollection) as? LokiGroupChat
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@objc(setGroupChat:threadID:transaction:)
|
|
|
|
|
public static func setGroupChat(_ groupChat: LokiGroupChat, for threadID: String, in transaction: YapDatabaseReadWriteTransaction) {
|
|
|
|
|
return OWSPrimaryStorage.shared().setGroupChat(groupChat, for: threadID, in: transaction)
|
|
|
|
|
transaction.setObject(groupChat, forKey: threadID, inCollection: groupChatCollection)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@objc(removeGroupChatForThreadID:transaction:)
|
|
|
|
|
public static func removeGroupChat(for threadID: String, in transaction: YapDatabaseReadWriteTransaction) {
|
|
|
|
|
return OWSPrimaryStorage.shared().removeGroupChat(for: threadID, in: transaction)
|
|
|
|
|
transaction.removeObject(forKey: threadID, inCollection: groupChatCollection)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|