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
|
|
|
|
2022-02-17 08:33:23 +01:00
|
|
|
public protocol SessionMessagingKitStorageProtocol {
|
2020-11-06 01:41:01 +01:00
|
|
|
|
2020-11-18 04:27:30 +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
|
|
|
|
2020-11-18 04:27:30 +01:00
|
|
|
// MARK: - General
|
|
|
|
|
2020-11-06 09:32:09 +01:00
|
|
|
func getUserPublicKey() -> String?
|
2020-11-09 01:53:07 +01:00
|
|
|
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?
|
2021-07-22 06:41:27 +02:00
|
|
|
func getAllContacts() -> Set<Contact>
|
2020-11-18 04:27:30 +01:00
|
|
|
|
2021-01-29 01:46:32 +01:00
|
|
|
// MARK: - Closed Groups
|
2020-11-18 04:27:30 +01:00
|
|
|
|
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)
|
2020-11-18 04:27:30 +01:00
|
|
|
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)
|
2020-11-18 04:27:30 +01:00
|
|
|
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)
|
2020-11-27 00:08:46 +01:00
|
|
|
func isJobCanceled(_ job: Job) -> Bool
|
2020-11-18 04:27:30 +01:00
|
|
|
|
|
|
|
// 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-18 04:27:30 +01:00
|
|
|
|
2020-11-23 05:37:25 +01:00
|
|
|
// MARK: - Open Groups
|
2021-01-13 03:38:07 +01:00
|
|
|
|
2022-02-17 08:33:23 +01:00
|
|
|
func getAllOpenGroups() -> [String: OpenGroup]
|
|
|
|
func getThreadID(for openGroupID: 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
|
|
|
|
2022-02-17 08:33:23 +01:00
|
|
|
func getOpenGroupImage(for room: String, on server: String) -> Data?
|
|
|
|
func setOpenGroupImage(to data: Data, for room: String, on server: String, using transaction: Any)
|
|
|
|
|
|
|
|
func getOpenGroup(for threadID: String) -> OpenGroup?
|
|
|
|
func setOpenGroup(_ openGroup: OpenGroup, for threadID: String, using transaction: Any)
|
|
|
|
|
|
|
|
func getUserCount(forOpenGroupWithID openGroupID: String) -> UInt64?
|
|
|
|
func setUserCount(to newValue: UInt64, forOpenGroupWithID openGroupID: String, using transaction: Any)
|
|
|
|
|
|
|
|
func getOpenGroupServer(name: String) -> OpenGroupAPI.Server?
|
|
|
|
func storeOpenGroupServer(_ server: OpenGroupAPI.Server, using transaction: Any)
|
|
|
|
|
2022-02-24 00:39:22 +01:00
|
|
|
// MARK: - -- Open Group Public Keys
|
2020-11-18 04:27:30 +01:00
|
|
|
|
2020-11-09 01:53:07 +01:00
|
|
|
func getOpenGroupPublicKey(for server: String) -> String?
|
|
|
|
func setOpenGroupPublicKey(for server: String, to newValue: String, using transaction: Any)
|
2020-11-18 04:27:30 +01:00
|
|
|
|
2022-02-24 00:39:22 +01:00
|
|
|
// MARK: - -- Open Group Sequence Number
|
2021-01-29 01:46:32 +01:00
|
|
|
|
2022-02-24 00:39:22 +01:00
|
|
|
func getOpenGroupSequenceNumber(for room: String, on server: String) -> Int64?
|
|
|
|
func setOpenGroupSequenceNumber(for room: String, on server: String, to newValue: Int64, using transaction: Any)
|
|
|
|
func removeOpenGroupSequenceNumber(for room: String, on server: String, using transaction: Any)
|
2022-02-25 01:59:29 +01:00
|
|
|
|
|
|
|
// MARK: - -- Open Group Inbox Latest Message Id
|
|
|
|
|
|
|
|
func getOpenGroupInboxLatestMessageId(for server: String) -> Int64?
|
|
|
|
func setOpenGroupInboxLatestMessageId(for server: String, to newValue: Int64, using transaction: Any)
|
|
|
|
func removeOpenGroupInboxLatestMessageId(for server: String, using transaction: Any)
|
2020-11-18 04:27:30 +01:00
|
|
|
|
|
|
|
// 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
|
|
|
}
|