session-ios/SessionMessagingKit/Storage.swift

89 lines
4.1 KiB
Swift
Raw Normal View History

2020-12-07 06:00:21 +01:00
import PromiseKit
2020-12-10 06:12:22 +01:00
import Sodium
2020-11-06 01:41:01 +01:00
2020-11-10 05:48:47 +01:00
public protocol SessionMessagingKitStorageProtocol {
2020-11-06 01:41:01 +01:00
// MARK: - Shared
2020-12-07 06:00:21 +01:00
@discardableResult
func write(with block: @escaping (Any) -> Void) -> Promise<Void>
@discardableResult
func write(with block: @escaping (Any) -> Void, completion: @escaping () -> Void) -> Promise<Void>
func writeSync(with block: @escaping (Any) -> Void)
2020-11-06 01:41:01 +01:00
// MARK: - General
func getUserPublicKey() -> String?
func getUserKeyPair() -> ECKeyPair?
2020-12-10 06:12:22 +01:00
func getUserED25519KeyPair() -> Box.KeyPair?
2021-02-26 05:56:41 +01:00
func getUser() -> Contact?
func getAllContacts() -> Set<Contact>
2021-01-29 01:46:32 +01:00
// MARK: - Closed Groups
2021-01-13 03:38:07 +01:00
func getUserClosedGroupPublicKeys() -> Set<String>
2021-04-16 02:56:10 +02:00
func getZombieMembers(for groupPublicKey: String) -> Set<String>
func setZombieMembers(for groupPublicKey: String, to zombies: Set<String>, using transaction: Any)
func isClosedGroup(_ publicKey: String) -> Bool
// MARK: - Jobs
2020-11-08 03:12:38 +01:00
func persist(_ job: Job, using transaction: Any)
2020-11-08 03:54:40 +01:00
func markJobAsSucceeded(_ job: Job, using transaction: Any)
func markJobAsFailed(_ job: Job, using transaction: Any)
func getAllPendingJobs(of type: Job.Type) -> [Job]
2020-11-23 05:08:01 +01:00
func getAttachmentUploadJob(for attachmentID: String) -> AttachmentUploadJob?
2020-11-26 23:07:24 +01:00
func getMessageSendJob(for messageSendJobID: String) -> MessageSendJob?
func resumeMessageSendJobIfNeeded(_ messageSendJobID: String)
func isJobCanceled(_ job: Job) -> Bool
// MARK: - Authorization
2021-03-24 01:12:08 +01:00
func getAuthToken(for room: String, on server: String) -> String?
func setAuthToken(for room: String, on server: String, to newValue: String, using transaction: Any)
func removeAuthToken(for room: String, on server: String, using transaction: Any)
2020-11-23 05:37:25 +01:00
// MARK: - Open Groups
2021-01-13 03:38:07 +01:00
2021-03-24 02:37:33 +01:00
func getAllV2OpenGroups() -> [String:OpenGroupV2]
func getV2OpenGroup(for threadID: String) -> OpenGroupV2?
2021-05-05 05:49:24 +02:00
func v2GetThreadID(for v2OpenGroupID: String) -> String?
2021-01-13 06:10:06 +01:00
func updateMessageIDCollectionByPruningMessagesWithIDs(_ messageIDs: Set<String>, using transaction: Any)
2020-11-23 05:37:25 +01:00
// MARK: - Open Group Public Keys
func getOpenGroupPublicKey(for server: String) -> String?
func setOpenGroupPublicKey(for server: String, to newValue: String, using transaction: Any)
// MARK: - Last Message Server ID
2021-01-29 01:46:32 +01:00
func getLastMessageServerID(for room: String, on server: String) -> Int64?
func setLastMessageServerID(for room: String, on server: String, to newValue: Int64, using transaction: Any)
func removeLastMessageServerID(for room: String, on server: String, using transaction: Any)
// MARK: - Last Deletion Server ID
func getLastDeletionServerID(for room: String, on server: String) -> Int64?
func setLastDeletionServerID(for room: String, on server: String, to newValue: Int64, using transaction: Any)
func removeLastDeletionServerID(for room: String, on server: String, using transaction: Any)
// MARK: - Open Group Metadata
2021-03-26 06:31:15 +01:00
func setUserCount(to newValue: UInt64, forV2OpenGroupWithID openGroupID: String, using transaction: Any)
// MARK: - Message Handling
2020-11-27 05:13:42 +01:00
func getReceivedMessageTimestamps(using transaction: Any) -> [UInt64]
func addReceivedMessageTimestamp(_ timestamp: UInt64, using transaction: Any)
2020-11-27 06:22:15 +01:00
/// Returns the ID of the thread.
2020-11-30 01:00:28 +01:00
func getOrCreateThread(for publicKey: String, groupPublicKey: String?, openGroupID: String?, using transaction: Any) -> String?
2020-11-27 06:22:15 +01:00
/// Returns the ID of the `TSIncomingMessage` that was constructed.
2020-11-30 01:00:28 +01:00
func persist(_ message: VisibleMessage, quotedMessage: TSQuotedMessage?, linkPreview: OWSLinkPreview?, groupPublicKey: String?, openGroupID: String?, using transaction: Any) -> String?
2020-11-20 01:10:53 +01:00
/// Returns the IDs of the saved attachments.
2020-11-23 00:24:40 +01:00
func persist(_ attachments: [VisibleMessage.Attachment], using transaction: Any) -> [String]
/// Also touches the associated message.
func setAttachmentState(to state: TSAttachmentPointerState, for pointer: TSAttachmentPointer, associatedWith tsIncomingMessageID: String, using transaction: Any)
/// Also touches the associated message.
func persist(_ stream: TSAttachmentStream, associatedWith tsIncomingMessageID: String, using transaction: Any)
2020-11-06 01:41:01 +01:00
}