// SPDX-License-Identifier: AGPL-3.0-or-later // Copyright (C) 2022-2026 Aykut Alparslan KOC using TLDto = Ferrite.TL.baseLayer.dto; namespace Ferrite.Data.Repositories; public interface ISecretChatsRepository { ValueTask TryCreateChatAsync(TLDto.TLSecretChatState chat, int maxPendingChatsPerAuthKey = int.MaxValue, int maxOutstandingRequestsPerAuthKey = int.MaxValue, CancellationToken cancellationToken = default); ValueTask GetChatAsync(int chatId, CancellationToken cancellationToken = default); ValueTask GetChatByInitiatorRandomIdAsync( long initiatorUserId, int randomId, CancellationToken cancellationToken = default); ValueTask> GetChatsByAuthKeyAsync( long authKeyId, CancellationToken cancellationToken = default); ValueTask> GetRequestedRecipientAuthKeysAsync(int chatId, CancellationToken cancellationToken = default); ValueTask TryAcceptChatAsync(int chatId, long recipientAuthKeyId, ReadOnlyMemory gB, long keyFingerprint, int date, int maxActiveChatsPerAuthKey = int.MaxValue, CancellationToken cancellationToken = default); ValueTask TryDiscardChatAsync(int chatId, long callerAuthKeyId, bool deleteHistory, int date, CancellationToken cancellationToken = default); ValueTask> GetControlTargetChatsAsync( long authKeyId, CancellationToken cancellationToken = default); ValueTask> GetControlTargetAuthKeyIdsAsync(int chatId, CancellationToken cancellationToken = default); ValueTask CompleteControlTransitionAsync(int chatId, SecretChatPersistenceState expectedState, int expectedDate, CancellationToken cancellationToken = default); ValueTask TryPutSendReceiptAsync( TLDto.TLSecretChatSendReceipt receipt, CancellationToken cancellationToken = default); ValueTask GetSendReceiptAsync(int chatId, long senderAuthKeyId, long randomId, int minimumDate = int.MinValue, CancellationToken cancellationToken = default); ValueTask AdvanceReadDateAsync( long callerAuthKeyId, int chatId, long accessHash, int maxDate, TLDto.TLSecretChatControlUpdate controlUpdate, CancellationToken cancellationToken = default); ValueTask AppendQtsAsync(long recipientAuthKeyId, int chatId, long randomId, int date, int expiresAt, ReadOnlyMemory encryptedMessage, int maxEvents, long maxBytes, Func> getCurrentQts, Func> incrementQts, CancellationToken cancellationToken = default); ValueTask AppendSendQtsAsync(long senderAuthKeyId, long recipientAuthKeyId, int chatId, long accessHash, long randomId, int date, int expiresAt, ReadOnlyMemory encryptedMessage, ReadOnlyMemory result, int maxEvents, long maxBytes, int receiptRetentionSeconds, Func> getCurrentQts, Func> incrementQts, CancellationToken cancellationToken = default); ValueTask RecoverPendingQtsAsync(long recipientAuthKeyId, Func> getCurrentQts, Func> incrementQts, CancellationToken cancellationToken = default); ValueTask> GetQtsEntriesAsync( long recipientAuthKeyId, int afterQts = 0, int limit = int.MaxValue, CancellationToken cancellationToken = default); ValueTask AcknowledgeQtsAsync(long recipientAuthKeyId, int maxQts, CancellationToken cancellationToken = default); ValueTask ConfirmQtsAsync(long recipientAuthKeyId, int maxQts, Func> getCurrentQts, Func> incrementQts, CancellationToken cancellationToken = default); ValueTask ReadQtsDifferenceAsync( long recipientAuthKeyId, int requestQts, int now, int limit, Func> getCurrentQts, Func> incrementQts, CancellationToken cancellationToken = default); ValueTask> GetQtsMaintenanceAuthKeyIdsAsync( long afterAuthKeyId, int limit, CancellationToken cancellationToken = default); ValueTask MaintainQtsAsync( long recipientAuthKeyId, int now, Func> getCurrentQts, Func> incrementQts, CancellationToken cancellationToken = default); ValueTask CleanupRetentionAsync( int now, int receiptRetentionSeconds, int maxItems, CancellationToken cancellationToken = default); ValueTask PutControlUpdateAsync(TLDto.TLSecretChatControlUpdate update, CancellationToken cancellationToken = default); ValueTask> GetControlUpdatesAsync( long recipientAuthKeyId, CancellationToken cancellationToken = default); ValueTask DeleteControlUpdatesAsync(long recipientAuthKeyId, CancellationToken cancellationToken = default); ValueTask DeleteControlUpdateAsync(long recipientAuthKeyId, long updateId, CancellationToken cancellationToken = default); ValueTask GetControlDifferenceAsync( long recipientAuthKeyId, int requestDate, int responseDate, int now, bool isProbe, CancellationToken cancellationToken = default); ValueTask PutEncryptedFileAsync(TLDto.TLSecretChatEncryptedFile file, CancellationToken cancellationToken = default); ValueTask GetEncryptedFileAsync(long fileId, long accessHash, CancellationToken cancellationToken = default); ValueTask GetEncryptedFileByIdAsync(long fileId, CancellationToken cancellationToken = default); ValueTask GetEncryptedFileByUploadIdAsync( long uploadFileId, CancellationToken cancellationToken = default); ValueTask TryAssociateEncryptedFileAsync( TLDto.TLSecretChatEncryptedFileAssociation association, int maxAssociations, CancellationToken cancellationToken = default); ValueTask> GetEncryptedFileAssociationsAsync(long fileId, CancellationToken cancellationToken = default); ValueTask> GetEncryptedFilesByChatAsync(int chatId, CancellationToken cancellationToken = default); ValueTask RevokeAuthKeyAsync(long authKeyId, int date, CancellationToken cancellationToken = default); ValueTask CompleteAuthKeyRevocationAsync(long authKeyId, CancellationToken cancellationToken = default); }