From bce45cbf2b16778d1cd9916e3622254c419129bc Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Fri, 22 Apr 2022 12:44:45 +0200 Subject: [PATCH] refactor: Remove old deprecations They have been lived long enough and the next version will have breaking changes anyway. --- lib/encryption/olm_manager.dart | 27 -------------------- lib/src/client.dart | 32 ------------------------ lib/src/event.dart | 9 ------- lib/src/room.dart | 44 --------------------------------- lib/src/utils/event_update.dart | 3 --- 5 files changed, 115 deletions(-) diff --git a/lib/encryption/olm_manager.dart b/lib/encryption/olm_manager.dart index 05478d18..439c370c 100644 --- a/lib/encryption/olm_manager.dart +++ b/lib/encryption/olm_manager.dart @@ -108,33 +108,6 @@ class OlmManager { return _olmAccount!.sign(s); } - /// Checks the signature of a signed json object. - @deprecated - bool checkJsonSignature(String key, Map signedJson, - String userId, String deviceId) { - if (!enabled) throw ('Encryption is disabled'); - final Map? signatures = signedJson['signatures']; - if (signatures == null || !signatures.containsKey(userId)) return false; - signedJson.remove('unsigned'); - signedJson.remove('signatures'); - if (!signatures[userId].containsKey('ed25519:$deviceId')) return false; - final String signature = signatures[userId]['ed25519:$deviceId']; - final canonical = canonicalJson.encode(signedJson); - final message = String.fromCharCodes(canonical); - var isValid = false; - final olmutil = olm.Utility(); - try { - olmutil.ed25519_verify(key, message, signature); - isValid = true; - } catch (e, s) { - isValid = false; - Logs().w('[LibOlm] Signature check failed', e, s); - } finally { - olmutil.free(); - } - return isValid; - } - bool _uploadKeysLock = false; /// Generates new one time keys, signs everything and upload it to the server. diff --git a/lib/src/client.dart b/lib/src/client.dart index 7b108628..2e8a78f8 100644 --- a/lib/src/client.dart +++ b/lib/src/client.dart @@ -63,9 +63,6 @@ class Client extends MatrixApi { DatabaseApi? get database => _database; - @deprecated - MatrixApi get api => this; - Encryption? encryption; Set verificationMethods; @@ -152,8 +149,6 @@ class Client extends MatrixApi { this.databaseDestroyer, this.legacyDatabaseBuilder, this.legacyDatabaseDestroyer, - @Deprecated('This is now always enabled by default.') - bool? enableE2eeRecovery, Set? verificationMethods, http.Client? httpClient, Set? importantStateEvents, @@ -170,7 +165,6 @@ class Client extends MatrixApi { Filter? syncFilter, this.sendTimelineEventTimeout = const Duration(minutes: 1), this.customImageResizer, - @deprecated bool? debug, }) : syncFilter = syncFilter ?? Filter( room: RoomFilter( @@ -747,9 +741,6 @@ class Client extends MatrixApi { final List _archivedRooms = []; - @Deprecated('Use [loadArchive()] instead.') - Future> get archive => loadArchive(); - Future> loadArchive() async { _archivedRooms.clear(); final syncResp = await sync( @@ -951,24 +942,6 @@ class Client extends MatrixApi { /// an error? int syncErrorTimeoutSec = 3; - @Deprecated('Use init() instead') - void connect({ - String? newToken, - Uri? newHomeserver, - String? newUserID, - String? newDeviceName, - String? newDeviceID, - String? newOlmAccount, - }) => - init( - newToken: newToken, - newHomeserver: newHomeserver, - newUserID: newUserID, - newDeviceName: newDeviceName, - newDeviceID: newDeviceID, - newOlmAccount: newOlmAccount, - ); - bool _initLock = false; /// Fetches the corresponding Event object from a notification including a @@ -2431,11 +2404,6 @@ class Client extends MatrixApi { } } - @Deprecated('Use clearCache()') - Future clearLocalCachedMessages() async { - await clearCache(); - } - /// Clear all local cached messages, room information and outbound group /// sessions and perform a new clean sync. Future clearCache() async { diff --git a/lib/src/event.dart b/lib/src/event.dart index 79e21919..55d3c5d7 100644 --- a/lib/src/event.dart +++ b/lib/src/event.dart @@ -39,15 +39,6 @@ abstract class RelationshipTypes { class Event extends MatrixEvent { User get sender => room.getUserByMXIDSync(senderId); - @Deprecated('Use [originServerTs] instead') - DateTime get time => originServerTs; - - @Deprecated('Use [type] instead') - String get typeKey => type; - - @Deprecated('Use [sender.calcDisplayname()] instead') - String? get senderName => sender.calcDisplayname(); - /// The room this event belongs to. May be null. final Room room; diff --git a/lib/src/room.dart b/lib/src/room.dart index 6f6ddba6..343f77a1 100644 --- a/lib/src/room.dart +++ b/lib/src/room.dart @@ -75,15 +75,6 @@ class Room { RoomSummary summary; - @deprecated - List? get mHeroes => summary.mHeroes; - - @deprecated - int? get mJoinedMemberCount => summary.mJoinedMemberCount; - - @deprecated - int? get mInvitedMemberCount => summary.mInvitedMemberCount; - /// The room states are a key value store of the key (`type`,`state_key`) => State(event). /// In a lot of cases the `state_key` might be an empty string. You **should** use the /// methods `getState()` and `setState()` to interact with the room states. @@ -461,9 +452,6 @@ class Room { return 'Empty chat'; } - @Deprecated('Use [lastEvent.body] instead') - String get lastMessage => lastEvent?.body ?? ''; - /// When the last message received. DateTime get timeCreated => lastEvent?.originServerTs ?? DateTime.now(); @@ -564,9 +552,6 @@ class Room { /// in muted rooms, use [hasNewMessages]. bool get isUnread => notificationCount > 0 || markedUnread; - @Deprecated('Use [markUnread] instead') - Future setUnread(bool unread) => markUnread(unread); - /// Sets an unread flag manually for this room. This changes the local account /// data model before syncing it to make sure /// this works if there is no connection to the homeserver. This does **not** @@ -617,11 +602,6 @@ class Room { {'pinned': pinnedEventIds}, ); - /// return all current emote packs for this room - @deprecated - Map> get emotePacks => - getImagePacksFlat(ImagePackUsage.emoticon); - /// returns the resolved mxid for a mention string, or null if none found String? getMention(String mention) => getParticipants() .firstWhereOrNull((u) => u.mentionFragments.contains(mention)) @@ -634,7 +614,6 @@ class Room { Event? inReplyTo, String? editEventId, bool parseMarkdown = true, - @deprecated Map>? emotePacks, bool parseCommands = true, String msgtype = MessageTypes.Text}) { if (parseCommands) { @@ -1270,19 +1249,6 @@ class Room { return; } - /// Sends *m.fully_read* and *m.read* for the given event ID. - @Deprecated('Use sendReadMarker instead') - Future sendReadReceipt(String eventID) async { - notificationCount = 0; - await client.database?.resetNotificationCount(id); - await client.setReadMarker( - id, - eventID, - mRead: eventID, - ); - return; - } - /// Creates a timeline from the store. Returns a [Timeline] object. If you /// just want to update the whole timeline on every change, use the [onUpdate] /// callback. For updating only the parts that have changed, use the @@ -1399,12 +1365,6 @@ class Room { (summary.mJoinedMemberCount ?? 0) + (summary.mInvitedMemberCount ?? 0); } - /// Returns the [User] object for the given [mxID] or requests it from - /// the homeserver and waits for a response. - @Deprecated('Use [requestUser] instead') - Future getUserByMXID(String mxID) async => - getState(EventTypes.RoomMember, mxID)?.asUser ?? await requestUser(mxID); - /// Returns the [User] object for the given [mxID] or requests it from /// the homeserver and returns a default [User] object while waiting. User getUserByMXIDSync(String mxID) { @@ -1734,10 +1694,6 @@ class Room { Future setTyping(bool isTyping, {int? timeout}) => client.setTyping(client.userID!, id, isTyping, timeout: timeout); - @Deprecated('Use sendTypingNotification instead') - Future sendTypingInfo(bool isTyping, {int? timeout}) => - setTyping(isTyping, timeout: timeout); - /// A room may be public meaning anyone can join the room without any prior action. Alternatively, /// it can be invite meaning that a user who wishes to join the room must first receive an invite /// to the room from someone already inside of the room. Currently, knock and private are reserved diff --git a/lib/src/utils/event_update.dart b/lib/src/utils/event_update.dart index 922e90e2..f6f9e74f 100644 --- a/lib/src/utils/event_update.dart +++ b/lib/src/utils/event_update.dart @@ -36,9 +36,6 @@ class EventUpdate { /// Most events belong to a room. If not, this equals to eventType. final String roomID; - @Deprecated("Use `content['type']` instead.") - String get eventType => content['type']; - // The json payload of the content of this event. final Map content;