matrix-js-sdk 41.8.0 → 41.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/README.md +1 -1
- package/lib/@types/AESEncryptedSecretStoragePayload.js +3 -1
- package/lib/@types/IIdentityServerProvider.js +3 -1
- package/lib/@types/PushRules.js +7 -7
- package/lib/@types/PushRules.js.map +1 -1
- package/lib/@types/auth.js +4 -4
- package/lib/@types/auth.js.map +1 -1
- package/lib/@types/beacon.js +2 -2
- package/lib/@types/beacon.js.map +1 -1
- package/lib/@types/common.js +3 -1
- package/lib/@types/crypto.js +3 -1
- package/lib/@types/event.js +20 -20
- package/lib/@types/event.js.map +1 -1
- package/lib/@types/events.js +3 -1
- package/lib/@types/extensible_events.js +6 -6
- package/lib/@types/extensible_events.js.map +1 -1
- package/lib/@types/global.d.js.map +1 -1
- package/lib/@types/json.js +3 -1
- package/lib/@types/local_notifications.js +3 -1
- package/lib/@types/location.js +4 -4
- package/lib/@types/location.js.map +1 -1
- package/lib/@types/matrix-sdk-crypto-wasm.d.js +3 -1
- package/lib/@types/media.js +3 -1
- package/lib/@types/membership.js +1 -1
- package/lib/@types/membership.js.map +1 -1
- package/lib/@types/partials.js +6 -6
- package/lib/@types/partials.js.map +1 -1
- package/lib/@types/polls.js +5 -5
- package/lib/@types/polls.js.map +1 -1
- package/lib/@types/read_receipts.js +2 -2
- package/lib/@types/read_receipts.js.map +1 -1
- package/lib/@types/registration.js +3 -1
- package/lib/@types/requests.js +1 -1
- package/lib/@types/requests.js.map +1 -1
- package/lib/@types/retention.js +1 -1
- package/lib/@types/retention.js.map +1 -1
- package/lib/@types/search.js +1 -1
- package/lib/@types/search.js.map +1 -1
- package/lib/@types/signed.js +3 -1
- package/lib/@types/spaces.js +3 -1
- package/lib/@types/state_events.js +3 -1
- package/lib/@types/synapse.js +3 -1
- package/lib/@types/sync.js +1 -1
- package/lib/@types/sync.js.map +1 -1
- package/lib/@types/threepids.js +1 -1
- package/lib/@types/threepids.js.map +1 -1
- package/lib/@types/topic.js +1 -1
- package/lib/@types/topic.js.map +1 -1
- package/lib/@types/uia.js +3 -1
- package/lib/NamespacedValue.js +8 -8
- package/lib/NamespacedValue.js.map +1 -1
- package/lib/ReEmitter.js +9 -16
- package/lib/ReEmitter.js.map +1 -1
- package/lib/ToDeviceMessageQueue.js +49 -57
- package/lib/ToDeviceMessageQueue.js.map +1 -1
- package/lib/autodiscovery.js +232 -247
- package/lib/autodiscovery.js.map +1 -1
- package/lib/base64.js +1 -1
- package/lib/base64.js.map +1 -1
- package/lib/browser-index.d.ts +2 -2
- package/lib/browser-index.d.ts.map +1 -1
- package/lib/browser-index.js +5 -5
- package/lib/browser-index.js.map +1 -1
- package/lib/capabilityPoller.js +19 -22
- package/lib/capabilityPoller.js.map +1 -1
- package/lib/client.d.ts +2 -8
- package/lib/client.d.ts.map +1 -1
- package/lib/client.js +2043 -2487
- package/lib/client.js.map +1 -1
- package/lib/common-crypto/CryptoBackend.js +2 -2
- package/lib/common-crypto/CryptoBackend.js.map +1 -1
- package/lib/common-crypto/key-passphrase.js.map +1 -1
- package/lib/content-helpers.js +43 -48
- package/lib/content-helpers.js.map +1 -1
- package/lib/content-repo.js +14 -24
- package/lib/content-repo.js.map +1 -1
- package/lib/crypto/store/base.js +6 -6
- package/lib/crypto/store/base.js.map +1 -1
- package/lib/crypto/store/indexeddb-crypto-store-backend.js +190 -238
- package/lib/crypto/store/indexeddb-crypto-store-backend.js.map +1 -1
- package/lib/crypto/store/indexeddb-crypto-store.js +25 -30
- package/lib/crypto/store/indexeddb-crypto-store.js.map +1 -1
- package/lib/crypto/store/localStorage-crypto-store.js +113 -145
- package/lib/crypto/store/localStorage-crypto-store.js.map +1 -1
- package/lib/crypto/store/memory-crypto-store.js +74 -105
- package/lib/crypto/store/memory-crypto-store.js.map +1 -1
- package/lib/crypto-api/CryptoEvent.js +1 -1
- package/lib/crypto-api/CryptoEvent.js.map +1 -1
- package/lib/crypto-api/CryptoEventHandlerMap.js +3 -1
- package/lib/crypto-api/index.d.ts +15 -6
- package/lib/crypto-api/index.d.ts.map +1 -1
- package/lib/crypto-api/index.js +22 -22
- package/lib/crypto-api/index.js.map +1 -1
- package/lib/crypto-api/key-passphrase.js +15 -23
- package/lib/crypto-api/key-passphrase.js.map +1 -1
- package/lib/crypto-api/keybackup.js +3 -1
- package/lib/crypto-api/recovery-key.js +11 -12
- package/lib/crypto-api/recovery-key.js.map +1 -1
- package/lib/crypto-api/verification.js +3 -3
- package/lib/crypto-api/verification.js.map +1 -1
- package/lib/digest.js +7 -14
- package/lib/digest.js.map +1 -1
- package/lib/embedded.d.ts.map +1 -1
- package/lib/embedded.js +380 -505
- package/lib/embedded.js.map +1 -1
- package/lib/errors.js +2 -2
- package/lib/errors.js.map +1 -1
- package/lib/event-mapper.js +10 -12
- package/lib/event-mapper.js.map +1 -1
- package/lib/extensible_events_v1/ExtensibleEvent.js.map +1 -1
- package/lib/extensible_events_v1/InvalidEventError.js.map +1 -1
- package/lib/extensible_events_v1/MessageEvent.js +11 -13
- package/lib/extensible_events_v1/MessageEvent.js.map +1 -1
- package/lib/extensible_events_v1/PollEndEvent.js +3 -4
- package/lib/extensible_events_v1/PollEndEvent.js.map +1 -1
- package/lib/extensible_events_v1/PollResponseEvent.js +5 -6
- package/lib/extensible_events_v1/PollResponseEvent.js.map +1 -1
- package/lib/extensible_events_v1/PollStartEvent.js +8 -10
- package/lib/extensible_events_v1/PollStartEvent.js.map +1 -1
- package/lib/extensible_events_v1/utilities.js.map +1 -1
- package/lib/feature.js +18 -31
- package/lib/feature.js.map +1 -1
- package/lib/filter-component.d.ts.map +1 -1
- package/lib/filter-component.js +20 -26
- package/lib/filter-component.js.map +1 -1
- package/lib/filter.js +14 -17
- package/lib/filter.js.map +1 -1
- package/lib/http-api/errors.js +28 -43
- package/lib/http-api/errors.js.map +1 -1
- package/lib/http-api/fetch.js +141 -159
- package/lib/http-api/fetch.js.map +1 -1
- package/lib/http-api/index.js +17 -20
- package/lib/http-api/index.js.map +1 -1
- package/lib/http-api/interface.js +1 -1
- package/lib/http-api/interface.js.map +1 -1
- package/lib/http-api/method.js +1 -1
- package/lib/http-api/method.js.map +1 -1
- package/lib/http-api/prefix.js +3 -3
- package/lib/http-api/prefix.js.map +1 -1
- package/lib/http-api/refresh.js +74 -94
- package/lib/http-api/refresh.js.map +1 -1
- package/lib/http-api/utils.d.ts +1 -1
- package/lib/http-api/utils.d.ts.map +1 -1
- package/lib/http-api/utils.js +34 -42
- package/lib/http-api/utils.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/indexeddb-helpers.js +3 -3
- package/lib/indexeddb-helpers.js.map +1 -1
- package/lib/indexeddb-worker.js.map +1 -1
- package/lib/interactive-auth.d.ts +5 -5
- package/lib/interactive-auth.d.ts.map +1 -1
- package/lib/interactive-auth.js +172 -204
- package/lib/interactive-auth.js.map +1 -1
- package/lib/logger.js +21 -57
- package/lib/logger.js.map +1 -1
- package/lib/matrix.js +7 -11
- package/lib/matrix.js.map +1 -1
- package/lib/matrixrtc/CallMembership.js +80 -74
- package/lib/matrixrtc/CallMembership.js.map +1 -1
- package/lib/matrixrtc/EncryptionManager.js +1 -1
- package/lib/matrixrtc/EncryptionManager.js.map +1 -1
- package/lib/matrixrtc/IKeyTransport.js +1 -1
- package/lib/matrixrtc/IKeyTransport.js.map +1 -1
- package/lib/matrixrtc/IMembershipManager.js +1 -1
- package/lib/matrixrtc/IMembershipManager.js.map +1 -1
- package/lib/matrixrtc/LivekitTransport.d.ts +1 -1
- package/lib/matrixrtc/LivekitTransport.js +4 -4
- package/lib/matrixrtc/LivekitTransport.js.map +1 -1
- package/lib/matrixrtc/MatrixRTCSession.js +137 -187
- package/lib/matrixrtc/MatrixRTCSession.js.map +1 -1
- package/lib/matrixrtc/MatrixRTCSessionManager.js +36 -41
- package/lib/matrixrtc/MatrixRTCSessionManager.js.map +1 -1
- package/lib/matrixrtc/MembershipManager.js +332 -378
- package/lib/matrixrtc/MembershipManager.js.map +1 -1
- package/lib/matrixrtc/MembershipManagerActionScheduler.js +54 -63
- package/lib/matrixrtc/MembershipManagerActionScheduler.js.map +1 -1
- package/lib/matrixrtc/RTCEncryptionManager.js +119 -143
- package/lib/matrixrtc/RTCEncryptionManager.js.map +1 -1
- package/lib/matrixrtc/ToDeviceKeyTransport.js +53 -58
- package/lib/matrixrtc/ToDeviceKeyTransport.js.map +1 -1
- package/lib/matrixrtc/index.js.map +1 -1
- package/lib/matrixrtc/membershipData/common.js +1 -1
- package/lib/matrixrtc/membershipData/common.js.map +1 -1
- package/lib/matrixrtc/membershipData/index.js.map +1 -1
- package/lib/matrixrtc/membershipData/rtc.js +15 -23
- package/lib/matrixrtc/membershipData/rtc.js.map +1 -1
- package/lib/matrixrtc/membershipData/session.js +4 -5
- package/lib/matrixrtc/membershipData/session.js.map +1 -1
- package/lib/matrixrtc/types.js +4 -6
- package/lib/matrixrtc/types.js.map +1 -1
- package/lib/matrixrtc/utils.js +4 -11
- package/lib/matrixrtc/utils.js.map +1 -1
- package/lib/models/MSC3089Branch.js +91 -116
- package/lib/models/MSC3089Branch.js.map +1 -1
- package/lib/models/MSC3089TreeSpace.js +209 -245
- package/lib/models/MSC3089TreeSpace.js.map +1 -1
- package/lib/models/ToDeviceMessage.js +3 -1
- package/lib/models/beacon.js +14 -13
- package/lib/models/beacon.js.map +1 -1
- package/lib/models/compare-event-ordering.js +13 -13
- package/lib/models/compare-event-ordering.js.map +1 -1
- package/lib/models/device.js +3 -3
- package/lib/models/device.js.map +1 -1
- package/lib/models/event-context.js +5 -8
- package/lib/models/event-context.js.map +1 -1
- package/lib/models/event-status.js +1 -1
- package/lib/models/event-status.js.map +1 -1
- package/lib/models/event-timeline-set.js +88 -94
- package/lib/models/event-timeline-set.js.map +1 -1
- package/lib/models/event-timeline.js +28 -30
- package/lib/models/event-timeline.js.map +1 -1
- package/lib/models/event.js +182 -226
- package/lib/models/event.js.map +1 -1
- package/lib/models/invites-ignorer-types.js +4 -4
- package/lib/models/invites-ignorer-types.js.map +1 -1
- package/lib/models/invites-ignorer.js +159 -179
- package/lib/models/invites-ignorer.js.map +1 -1
- package/lib/models/poll.js +71 -81
- package/lib/models/poll.js.map +1 -1
- package/lib/models/profile-keys.js +2 -2
- package/lib/models/profile-keys.js.map +1 -1
- package/lib/models/read-receipt.js +40 -56
- package/lib/models/read-receipt.js.map +1 -1
- package/lib/models/related-relations.js.map +1 -1
- package/lib/models/relations-container.js +22 -23
- package/lib/models/relations-container.js.map +1 -1
- package/lib/models/relations.js +133 -159
- package/lib/models/relations.js.map +1 -1
- package/lib/models/room-member.js +24 -29
- package/lib/models/room-member.js.map +1 -1
- package/lib/models/room-receipts.js +29 -43
- package/lib/models/room-receipts.js.map +1 -1
- package/lib/models/room-retention.js +74 -83
- package/lib/models/room-retention.js.map +1 -1
- package/lib/models/room-state.js +143 -172
- package/lib/models/room-state.js.map +1 -1
- package/lib/models/room-sticky-events.d.ts +1 -0
- package/lib/models/room-sticky-events.d.ts.map +1 -1
- package/lib/models/room-sticky-events.js +45 -65
- package/lib/models/room-sticky-events.js.map +1 -1
- package/lib/models/room-summary.js.map +1 -1
- package/lib/models/room.d.ts.map +1 -1
- package/lib/models/room.js +765 -909
- package/lib/models/room.js.map +1 -1
- package/lib/models/search-result.js +5 -5
- package/lib/models/search-result.js.map +1 -1
- package/lib/models/thread.js +225 -285
- package/lib/models/thread.js.map +1 -1
- package/lib/models/typed-event-emitter.js +7 -18
- package/lib/models/typed-event-emitter.js.map +1 -1
- package/lib/models/user.js +8 -8
- package/lib/models/user.js.map +1 -1
- package/lib/oidc/authorize.js +208 -241
- package/lib/oidc/authorize.js.map +1 -1
- package/lib/oidc/discovery.js +23 -36
- package/lib/oidc/discovery.js.map +1 -1
- package/lib/oidc/error.js +1 -1
- package/lib/oidc/error.js.map +1 -1
- package/lib/oidc/index.js +1 -0
- package/lib/oidc/index.js.map +1 -1
- package/lib/oidc/register.js +60 -66
- package/lib/oidc/register.js.map +1 -1
- package/lib/oidc/tokenRefresher.js +77 -91
- package/lib/oidc/tokenRefresher.js.map +1 -1
- package/lib/oidc/validate.js +18 -18
- package/lib/oidc/validate.js.map +1 -1
- package/lib/pushprocessor.js +71 -82
- package/lib/pushprocessor.js.map +1 -1
- package/lib/randomstring.js +9 -9
- package/lib/randomstring.js.map +1 -1
- package/lib/realtime-callbacks.js +25 -28
- package/lib/realtime-callbacks.js.map +1 -1
- package/lib/receipt-accumulator.d.ts +2 -0
- package/lib/receipt-accumulator.d.ts.map +1 -1
- package/lib/receipt-accumulator.js +14 -22
- package/lib/receipt-accumulator.js.map +1 -1
- package/lib/rendezvous/MSC4108SignInWithQR.js +271 -302
- package/lib/rendezvous/MSC4108SignInWithQR.js.map +1 -1
- package/lib/rendezvous/RendezvousChannel.js +3 -1
- package/lib/rendezvous/RendezvousCode.js +3 -1
- package/lib/rendezvous/RendezvousError.js.map +1 -1
- package/lib/rendezvous/RendezvousFailureReason.js +2 -2
- package/lib/rendezvous/RendezvousFailureReason.js.map +1 -1
- package/lib/rendezvous/RendezvousIntent.js +1 -1
- package/lib/rendezvous/RendezvousIntent.js.map +1 -1
- package/lib/rendezvous/RendezvousTransport.js +3 -1
- package/lib/rendezvous/channels/MSC4108SecureChannel.js +123 -147
- package/lib/rendezvous/channels/MSC4108SecureChannel.js.map +1 -1
- package/lib/rendezvous/index.js +44 -69
- package/lib/rendezvous/index.js.map +1 -1
- package/lib/rendezvous/transports/MSC4108RendezvousSession.d.ts +1 -1
- package/lib/rendezvous/transports/MSC4108RendezvousSession.js +134 -152
- package/lib/rendezvous/transports/MSC4108RendezvousSession.js.map +1 -1
- package/lib/retentionPolicy.js +6 -9
- package/lib/retentionPolicy.js.map +1 -1
- package/lib/room-hierarchy.js +52 -60
- package/lib/room-hierarchy.js.map +1 -1
- package/lib/rust-crypto/CrossSigningIdentity.js +94 -104
- package/lib/rust-crypto/CrossSigningIdentity.js.map +1 -1
- package/lib/rust-crypto/DehydratedDeviceManager.js +157 -190
- package/lib/rust-crypto/DehydratedDeviceManager.js.map +1 -1
- package/lib/rust-crypto/KeyClaimManager.js +18 -22
- package/lib/rust-crypto/KeyClaimManager.js.map +1 -1
- package/lib/rust-crypto/OutgoingRequestProcessor.js +109 -139
- package/lib/rust-crypto/OutgoingRequestProcessor.js.map +1 -1
- package/lib/rust-crypto/OutgoingRequestsManager.js +66 -80
- package/lib/rust-crypto/OutgoingRequestsManager.js.map +1 -1
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.d.ts +1 -1
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.js +196 -224
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.js.map +1 -1
- package/lib/rust-crypto/RoomEncryptor.js +127 -143
- package/lib/rust-crypto/RoomEncryptor.js.map +1 -1
- package/lib/rust-crypto/backup.js +453 -549
- package/lib/rust-crypto/backup.js.map +1 -1
- package/lib/rust-crypto/constants.js +1 -1
- package/lib/rust-crypto/constants.js.map +1 -1
- package/lib/rust-crypto/device-converter.js +15 -28
- package/lib/rust-crypto/device-converter.js.map +1 -1
- package/lib/rust-crypto/index.js +103 -116
- package/lib/rust-crypto/index.js.map +1 -1
- package/lib/rust-crypto/libolm_migration.js +303 -365
- package/lib/rust-crypto/libolm_migration.js.map +1 -1
- package/lib/rust-crypto/rust-crypto.d.ts +5 -1
- package/lib/rust-crypto/rust-crypto.d.ts.map +1 -1
- package/lib/rust-crypto/rust-crypto.js +1067 -1332
- package/lib/rust-crypto/rust-crypto.js.map +1 -1
- package/lib/rust-crypto/secret-storage.js +12 -25
- package/lib/rust-crypto/secret-storage.js.map +1 -1
- package/lib/rust-crypto/verification.js +137 -189
- package/lib/rust-crypto/verification.js.map +1 -1
- package/lib/scheduler.js +44 -19
- package/lib/scheduler.js.map +1 -1
- package/lib/secret-storage.js +179 -213
- package/lib/secret-storage.js.map +1 -1
- package/lib/serverCapabilities.js +6 -9
- package/lib/serverCapabilities.js.map +1 -1
- package/lib/service-types.js +1 -1
- package/lib/service-types.js.map +1 -1
- package/lib/sliding-sync-sdk.d.ts.map +1 -1
- package/lib/sliding-sync-sdk.js +368 -424
- package/lib/sliding-sync-sdk.js.map +1 -1
- package/lib/sliding-sync.js +135 -171
- package/lib/sliding-sync.js.map +1 -1
- package/lib/store/index.js +3 -1
- package/lib/store/indexeddb-backend.js +3 -1
- package/lib/store/indexeddb-local-backend.js +194 -253
- package/lib/store/indexeddb-local-backend.js.map +1 -1
- package/lib/store/indexeddb-remote-backend.js +33 -63
- package/lib/store/indexeddb-remote-backend.js.map +1 -1
- package/lib/store/indexeddb-store-worker.js +22 -23
- package/lib/store/indexeddb-store-worker.js.map +1 -1
- package/lib/store/indexeddb.js +44 -71
- package/lib/store/indexeddb.js.map +1 -1
- package/lib/store/local-storage-events-emitter.js +2 -2
- package/lib/store/local-storage-events-emitter.js.map +1 -1
- package/lib/store/memory.js +34 -57
- package/lib/store/memory.js.map +1 -1
- package/lib/store/stub.js +22 -35
- package/lib/store/stub.js.map +1 -1
- package/lib/sync-accumulator.js +54 -66
- package/lib/sync-accumulator.js.map +1 -1
- package/lib/sync.d.ts.map +1 -1
- package/lib/sync.js +905 -998
- package/lib/sync.js.map +1 -1
- package/lib/testing.js +63 -105
- package/lib/testing.js.map +1 -1
- package/lib/thread-utils.js +1 -4
- package/lib/thread-utils.js.map +1 -1
- package/lib/timeline-window.js +89 -102
- package/lib/timeline-window.js.map +1 -1
- package/lib/types.js +1 -1
- package/lib/types.js.map +1 -1
- package/lib/utils/decryptAESSecretStorageItem.js +14 -25
- package/lib/utils/decryptAESSecretStorageItem.js.map +1 -1
- package/lib/utils/encryptAESSecretStorageItem.js +27 -38
- package/lib/utils/encryptAESSecretStorageItem.js.map +1 -1
- package/lib/utils/internal/deriveKeys.js +25 -32
- package/lib/utils/internal/deriveKeys.js.map +1 -1
- package/lib/utils/roomVersion.js +1 -1
- package/lib/utils/roomVersion.js.map +1 -1
- package/lib/utils.js +83 -135
- package/lib/utils.js.map +1 -1
- package/lib/version-support.js +3 -3
- package/lib/version-support.js.map +1 -1
- package/lib/webrtc/audioContext.js +5 -6
- package/lib/webrtc/audioContext.js.map +1 -1
- package/lib/webrtc/call.js +1081 -1250
- package/lib/webrtc/call.js.map +1 -1
- package/lib/webrtc/callEventHandler.js +202 -214
- package/lib/webrtc/callEventHandler.js.map +1 -1
- package/lib/webrtc/callEventTypes.js +2 -2
- package/lib/webrtc/callEventTypes.js.map +1 -1
- package/lib/webrtc/callFeed.js +18 -20
- package/lib/webrtc/callFeed.js.map +1 -1
- package/lib/webrtc/groupCall.js +513 -602
- package/lib/webrtc/groupCall.js.map +1 -1
- package/lib/webrtc/groupCallEventHandler.js +59 -62
- package/lib/webrtc/groupCallEventHandler.js.map +1 -1
- package/lib/webrtc/mediaHandler.js +198 -232
- package/lib/webrtc/mediaHandler.js.map +1 -1
- package/lib/webrtc/stats/callFeedStatsReporter.js +16 -20
- package/lib/webrtc/stats/callFeedStatsReporter.js.map +1 -1
- package/lib/webrtc/stats/callStatsReportGatherer.js +67 -75
- package/lib/webrtc/stats/callStatsReportGatherer.js.map +1 -1
- package/lib/webrtc/stats/callStatsReportSummary.js +3 -1
- package/lib/webrtc/stats/connectionStats.js.map +1 -1
- package/lib/webrtc/stats/connectionStatsBuilder.js +2 -2
- package/lib/webrtc/stats/connectionStatsBuilder.js.map +1 -1
- package/lib/webrtc/stats/connectionStatsReportBuilder.js +20 -24
- package/lib/webrtc/stats/connectionStatsReportBuilder.js.map +1 -1
- package/lib/webrtc/stats/groupCallStats.js +6 -8
- package/lib/webrtc/stats/groupCallStats.js.map +1 -1
- package/lib/webrtc/stats/media/mediaSsrcHandler.js +7 -8
- package/lib/webrtc/stats/media/mediaSsrcHandler.js.map +1 -1
- package/lib/webrtc/stats/media/mediaTrackHandler.js +7 -9
- package/lib/webrtc/stats/media/mediaTrackHandler.js.map +1 -1
- package/lib/webrtc/stats/media/mediaTrackStats.js +3 -3
- package/lib/webrtc/stats/media/mediaTrackStats.js.map +1 -1
- package/lib/webrtc/stats/media/mediaTrackStatsHandler.js +7 -7
- package/lib/webrtc/stats/media/mediaTrackStatsHandler.js.map +1 -1
- package/lib/webrtc/stats/statsReport.js +1 -1
- package/lib/webrtc/stats/statsReport.js.map +1 -1
- package/lib/webrtc/stats/statsReportEmitter.js.map +1 -1
- package/lib/webrtc/stats/summaryStatsReportGatherer.js +14 -14
- package/lib/webrtc/stats/summaryStatsReportGatherer.js.map +1 -1
- package/lib/webrtc/stats/trackStatsBuilder.js +32 -34
- package/lib/webrtc/stats/trackStatsBuilder.js.map +1 -1
- package/lib/webrtc/stats/transportStats.js +3 -1
- package/lib/webrtc/stats/transportStatsBuilder.js +9 -9
- package/lib/webrtc/stats/transportStatsBuilder.js.map +1 -1
- package/lib/webrtc/stats/valueFormatter.js +1 -1
- package/lib/webrtc/stats/valueFormatter.js.map +1 -1
- package/package.json +18 -33
- package/src/@types/global.d.ts +2 -2
- package/src/ToDeviceMessageQueue.ts +2 -2
- package/src/browser-index.ts +4 -4
- package/src/client.ts +15 -20
- package/src/crypto-api/index.ts +17 -6
- package/src/embedded.ts +4 -6
- package/src/filter-component.ts +1 -0
- package/src/http-api/utils.ts +1 -1
- package/src/interactive-auth.ts +11 -5
- package/src/matrixrtc/LivekitTransport.ts +1 -1
- package/src/matrixrtc/MatrixRTCSession.ts +1 -1
- package/src/models/MSC3089Branch.ts +1 -1
- package/src/models/room-sticky-events.ts +1 -0
- package/src/models/room.ts +9 -11
- package/src/receipt-accumulator.ts +2 -0
- package/src/rendezvous/index.ts +1 -1
- package/src/rendezvous/transports/MSC4108RendezvousSession.ts +2 -2
- package/src/rust-crypto/PerSessionKeyBackupDownloader.ts +1 -1
- package/src/rust-crypto/index.ts +6 -6
- package/src/rust-crypto/rust-crypto.ts +31 -7
- package/src/rust-crypto/verification.ts +1 -1
- package/src/sliding-sync-sdk.ts +5 -7
- package/src/store/indexeddb-local-backend.ts +3 -3
- package/src/sync.ts +6 -8
package/lib/models/thread.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
3
|
/*
|
|
6
4
|
Copyright 2021 - 2023 The Matrix.org Foundation C.I.C.
|
|
7
5
|
|
|
@@ -30,7 +28,7 @@ import { logger } from "../logger.js";
|
|
|
30
28
|
import { ReadReceipt } from "./read-receipt.js";
|
|
31
29
|
import { ReceiptType } from "../@types/read_receipts.js";
|
|
32
30
|
import { Feature, ServerSupport } from "../feature.js";
|
|
33
|
-
export
|
|
31
|
+
export let ThreadEvent = /*#__PURE__*/function (ThreadEvent) {
|
|
34
32
|
ThreadEvent["New"] = "Thread.new";
|
|
35
33
|
ThreadEvent["Update"] = "Thread.update";
|
|
36
34
|
ThreadEvent["NewReply"] = "Thread.newReply";
|
|
@@ -38,7 +36,7 @@ export var ThreadEvent = /*#__PURE__*/function (ThreadEvent) {
|
|
|
38
36
|
ThreadEvent["Delete"] = "Thread.delete";
|
|
39
37
|
return ThreadEvent;
|
|
40
38
|
}({});
|
|
41
|
-
export
|
|
39
|
+
export let FeatureSupport = /*#__PURE__*/function (FeatureSupport) {
|
|
42
40
|
FeatureSupport[FeatureSupport["None"] = 0] = "None";
|
|
43
41
|
FeatureSupport[FeatureSupport["Experimental"] = 1] = "Experimental";
|
|
44
42
|
FeatureSupport[FeatureSupport["Stable"] = 2] = "Stable";
|
|
@@ -55,12 +53,9 @@ export function determineFeatureSupport(stable, unstable) {
|
|
|
55
53
|
}
|
|
56
54
|
export class Thread extends ReadReceipt {
|
|
57
55
|
constructor(id, rootEvent, opts) {
|
|
58
|
-
var _this, _opts$pendingEventOrd;
|
|
59
|
-
// each Event in the thread adds a reemitter, so we could hit the listener limit.
|
|
60
56
|
super();
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
this.rootEvent = rootEvent;
|
|
57
|
+
|
|
58
|
+
// each Event in the thread adds a reemitter, so we could hit the listener limit.
|
|
64
59
|
/**
|
|
65
60
|
* A reference to all the events ID at the bottom of the threads
|
|
66
61
|
*/
|
|
@@ -119,13 +114,13 @@ export class Thread extends ReadReceipt {
|
|
|
119
114
|
* with server suppport.
|
|
120
115
|
*/
|
|
121
116
|
_defineProperty(this, "replayEvents", []);
|
|
122
|
-
_defineProperty(this, "onTimelineReset",
|
|
117
|
+
_defineProperty(this, "onTimelineReset", async () => {
|
|
123
118
|
// We hit a gappy sync, ask the server for an update
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
})
|
|
119
|
+
await this.processRootEventPromise;
|
|
120
|
+
this.processRootEventPromise = undefined;
|
|
121
|
+
});
|
|
127
122
|
_defineProperty(this, "onBeforeRedaction", (event, redaction) => {
|
|
128
|
-
if (event
|
|
123
|
+
if (event?.isRelation(THREAD_RELATION_TYPE.name) && this.room.eventShouldLiveIn(event).threadId === this.id && event.getId() !== this.id &&
|
|
129
124
|
// the root event isn't counted in the length so ignore this redaction
|
|
130
125
|
!redaction.status // only respect it when it succeeds
|
|
131
126
|
) {
|
|
@@ -134,34 +129,28 @@ export class Thread extends ReadReceipt {
|
|
|
134
129
|
this.emit(ThreadEvent.Update, this);
|
|
135
130
|
}
|
|
136
131
|
});
|
|
137
|
-
_defineProperty(this, "onRedaction",
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
_this.clearEventMetadata(threadEvent);
|
|
143
|
-
}
|
|
144
|
-
_this.lastEvent = _this.rootEvent;
|
|
145
|
-
_this._currentUserParticipated = false;
|
|
146
|
-
_this.emit(ThreadEvent.Delete, _this);
|
|
147
|
-
} else {
|
|
148
|
-
var _this$lastEvent;
|
|
149
|
-
if (((_this$lastEvent = _this.lastEvent) === null || _this$lastEvent === void 0 ? void 0 : _this$lastEvent.getId()) === event.getAssociatedId()) {
|
|
150
|
-
// XXX: If our last event got redacted we query the server for the last event once again
|
|
151
|
-
yield _this.processRootEventPromise;
|
|
152
|
-
_this.processRootEventPromise = undefined;
|
|
153
|
-
}
|
|
154
|
-
yield _this.updateThreadMetadata();
|
|
132
|
+
_defineProperty(this, "onRedaction", async (event, room, threadRootId) => {
|
|
133
|
+
if (threadRootId !== this.id) return; // ignore redactions for other timelines
|
|
134
|
+
if (this.replyCount <= 0) {
|
|
135
|
+
for (const threadEvent of this.timeline) {
|
|
136
|
+
this.clearEventMetadata(threadEvent);
|
|
155
137
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}
|
|
160
|
-
|
|
138
|
+
this.lastEvent = this.rootEvent;
|
|
139
|
+
this._currentUserParticipated = false;
|
|
140
|
+
this.emit(ThreadEvent.Delete, this);
|
|
141
|
+
} else {
|
|
142
|
+
if (this.lastEvent?.getId() === event.getAssociatedId()) {
|
|
143
|
+
// XXX: If our last event got redacted we query the server for the last event once again
|
|
144
|
+
await this.processRootEventPromise;
|
|
145
|
+
this.processRootEventPromise = undefined;
|
|
146
|
+
}
|
|
147
|
+
await this.updateThreadMetadata();
|
|
148
|
+
}
|
|
149
|
+
});
|
|
161
150
|
_defineProperty(this, "onTimelineEvent", (event, room, toStartOfTimeline) => {
|
|
162
151
|
// Add a synthesized receipt when paginating forward in the timeline
|
|
163
152
|
if (!toStartOfTimeline) {
|
|
164
|
-
|
|
153
|
+
const sender = event.getSender();
|
|
165
154
|
if (sender && room && this.shouldSendLocalEchoReceipt(sender, event)) {
|
|
166
155
|
room.addLocalEchoReceipt(sender, event, ReceiptType.Read);
|
|
167
156
|
}
|
|
@@ -169,35 +158,32 @@ export class Thread extends ReadReceipt {
|
|
|
169
158
|
this.replyCount++;
|
|
170
159
|
}
|
|
171
160
|
}
|
|
172
|
-
this.onEcho(event, toStartOfTimeline
|
|
161
|
+
this.onEcho(event, toStartOfTimeline ?? false);
|
|
173
162
|
});
|
|
174
163
|
_defineProperty(this, "onLocalEcho", event => {
|
|
175
164
|
this.onEcho(event, false);
|
|
176
165
|
});
|
|
177
|
-
_defineProperty(this, "onEcho",
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
return _ref3.apply(this, arguments);
|
|
190
|
-
};
|
|
191
|
-
}());
|
|
166
|
+
_defineProperty(this, "onEcho", async (event, toStartOfTimeline) => {
|
|
167
|
+
if (event.threadRootId !== this.id) return; // ignore echoes for other timelines
|
|
168
|
+
if (this.lastEvent === event) return; // ignore duplicate events
|
|
169
|
+
await this.updateThreadMetadata();
|
|
170
|
+
if (!event.isRelation(THREAD_RELATION_TYPE.name)) return; // don't send a new reply event for reactions or edits
|
|
171
|
+
if (toStartOfTimeline) return; // ignore messages added to the start of the timeline
|
|
172
|
+
// Clear the lastEvent and instead start tracking locally using lastReply
|
|
173
|
+
this.lastEvent = undefined;
|
|
174
|
+
this.emit(ThreadEvent.NewReply, this, event);
|
|
175
|
+
});
|
|
176
|
+
this.id = id;
|
|
177
|
+
this.rootEvent = rootEvent;
|
|
192
178
|
this.setMaxListeners(1000);
|
|
193
|
-
if (!
|
|
179
|
+
if (!opts?.room) {
|
|
194
180
|
// Logging/debugging for https://github.com/vector-im/element-web/issues/22141
|
|
195
181
|
// Hope is that we end up with a more obvious stack trace.
|
|
196
182
|
throw new Error("element-web#22141: A thread requires a room in order to function");
|
|
197
183
|
}
|
|
198
184
|
this.room = opts.room;
|
|
199
185
|
this.client = opts.client;
|
|
200
|
-
this.pendingEventOrdering =
|
|
186
|
+
this.pendingEventOrdering = opts.pendingEventOrdering ?? PendingEventOrdering.Chronological;
|
|
201
187
|
this.timelineSet = new EventTimelineSet(this.room, {
|
|
202
188
|
timelineSupport: true,
|
|
203
189
|
pendingEvents: true
|
|
@@ -216,20 +202,17 @@ export class Thread extends ReadReceipt {
|
|
|
216
202
|
this.updateThreadMetadata();
|
|
217
203
|
this.setEventMetadata(this.rootEvent);
|
|
218
204
|
}
|
|
219
|
-
fetchRootEvent() {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
}
|
|
231
|
-
yield _this2.processEvent(_this2.rootEvent);
|
|
232
|
-
})();
|
|
205
|
+
async fetchRootEvent() {
|
|
206
|
+
// Always fetch the root event, even if we already have it, so we can get the latest
|
|
207
|
+
// state (via unsigned).
|
|
208
|
+
try {
|
|
209
|
+
const eventData = await this.client.fetchRoomEvent(this.roomId, this.id);
|
|
210
|
+
const mapper = this.client.getEventMapper();
|
|
211
|
+
this.rootEvent = mapper(eventData); // will merge with existing event object if such is known
|
|
212
|
+
} catch (e) {
|
|
213
|
+
logger.error("Failed to fetch thread root to construct thread with", e);
|
|
214
|
+
}
|
|
215
|
+
await this.processEvent(this.rootEvent);
|
|
233
216
|
}
|
|
234
217
|
static setServerSideSupport(status) {
|
|
235
218
|
Thread.hasServerSideSupport = status;
|
|
@@ -247,16 +230,14 @@ export class Thread extends ReadReceipt {
|
|
|
247
230
|
Thread.hasServerSideFwdPaginationSupport = status;
|
|
248
231
|
}
|
|
249
232
|
shouldSendLocalEchoReceipt(sender, event) {
|
|
250
|
-
|
|
251
|
-
var recursionSupport = (_this$client$canSuppo = this.client.canSupport.get(Feature.RelationsRecursion)) !== null && _this$client$canSuppo !== void 0 ? _this$client$canSuppo : ServerSupport.Unsupported;
|
|
233
|
+
const recursionSupport = this.client.canSupport.get(Feature.RelationsRecursion) ?? ServerSupport.Unsupported;
|
|
252
234
|
if (recursionSupport === ServerSupport.Unsupported) {
|
|
253
|
-
var _this$getReadReceiptF;
|
|
254
235
|
// Normally we add a local receipt, but if we don't have
|
|
255
236
|
// recursion support, then events may arrive out of order, so we
|
|
256
237
|
// only create a receipt if it's after our existing receipt.
|
|
257
|
-
|
|
238
|
+
const oldReceiptEventId = this.getReadReceiptForUserId(sender)?.eventId;
|
|
258
239
|
if (oldReceiptEventId) {
|
|
259
|
-
|
|
240
|
+
const receiptEvent = this.findEventById(oldReceiptEventId);
|
|
260
241
|
if (receiptEvent && receiptEvent.getTs() > event.getTs()) {
|
|
261
242
|
return false;
|
|
262
243
|
}
|
|
@@ -292,7 +273,7 @@ export class Thread extends ReadReceipt {
|
|
|
292
273
|
* @internal
|
|
293
274
|
*/
|
|
294
275
|
insertEventIntoTimeline(event) {
|
|
295
|
-
|
|
276
|
+
const eventId = event.getId();
|
|
296
277
|
if (!eventId) {
|
|
297
278
|
return;
|
|
298
279
|
}
|
|
@@ -316,15 +297,14 @@ export class Thread extends ReadReceipt {
|
|
|
316
297
|
* to the start (and not the end) of the timeline.
|
|
317
298
|
* @param emit - whether to emit the Update event if the thread was updated or not.
|
|
318
299
|
*/
|
|
319
|
-
addEvent(event, toStartOfTimeline) {
|
|
320
|
-
var emit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
300
|
+
addEvent(event, toStartOfTimeline, emit = true) {
|
|
321
301
|
// Modify this event to point at our room's state, and mark its thread
|
|
322
302
|
// as this.
|
|
323
303
|
this.setEventMetadata(event);
|
|
324
304
|
|
|
325
305
|
// Decide whether this event is going to be added at the end of the timeline.
|
|
326
|
-
|
|
327
|
-
|
|
306
|
+
const lastReply = this.lastReply();
|
|
307
|
+
const isNewestReply = !lastReply || event.localTimestamp >= lastReply.localTimestamp;
|
|
328
308
|
if (!Thread.hasServerSideSupport) {
|
|
329
309
|
// When there's no server-side support, just add it to the end of the timeline.
|
|
330
310
|
this.addEventToTimeline(event, toStartOfTimeline);
|
|
@@ -369,7 +349,6 @@ export class Thread extends ReadReceipt {
|
|
|
369
349
|
// reference to something that is, then we have two cases:
|
|
370
350
|
|
|
371
351
|
if (!this.initialEventsFetched) {
|
|
372
|
-
var _this$replayEvents;
|
|
373
352
|
// Case 1: we haven't yet fetched events from the server. In
|
|
374
353
|
// this case, when we do, the events we get back might only be
|
|
375
354
|
// the first-order ones, so this event (which is second-order -
|
|
@@ -385,17 +364,15 @@ export class Thread extends ReadReceipt {
|
|
|
385
364
|
* This fix keeps a reference to those events and replay them once the thread
|
|
386
365
|
* has been initialised properly.
|
|
387
366
|
*/
|
|
388
|
-
|
|
367
|
+
this.replayEvents?.push(event);
|
|
389
368
|
|
|
390
369
|
// For annotations (reactions), aggregate immediately (pre-init) to keep
|
|
391
370
|
// reaction counts/summary visible while the thread is still initialising.
|
|
392
371
|
// Only aggregate as child: parent aggregation is unnecessary here.
|
|
393
372
|
if (event.isRelation(RelationType.Annotation)) {
|
|
394
|
-
|
|
395
|
-
(_this$timelineSet$rel = this.timelineSet.relations) === null || _this$timelineSet$rel === void 0 || _this$timelineSet$rel.aggregateChildEvent(event, this.timelineSet);
|
|
373
|
+
this.timelineSet.relations?.aggregateChildEvent(event, this.timelineSet);
|
|
396
374
|
}
|
|
397
375
|
} else {
|
|
398
|
-
var _this$client$canSuppo2;
|
|
399
376
|
// Case 2: this is happening later, and we have a timeline. In
|
|
400
377
|
// this case, these events might be out-of order.
|
|
401
378
|
//
|
|
@@ -413,7 +390,7 @@ export class Thread extends ReadReceipt {
|
|
|
413
390
|
// (Note that both insertEventIntoTimeline and addEventToTimeline
|
|
414
391
|
// do nothing if we have seen this event before.)
|
|
415
392
|
|
|
416
|
-
|
|
393
|
+
const recursionSupport = this.client.canSupport.get(Feature.RelationsRecursion) ?? ServerSupport.Unsupported;
|
|
417
394
|
if (recursionSupport === ServerSupport.Unsupported) {
|
|
418
395
|
this.insertEventIntoTimeline(event);
|
|
419
396
|
} else {
|
|
@@ -422,14 +399,11 @@ export class Thread extends ReadReceipt {
|
|
|
422
399
|
// Aggregation is handled by EventTimelineSet when inserting/adding.
|
|
423
400
|
}
|
|
424
401
|
}
|
|
425
|
-
processEvent(event) {
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
yield _this3.fetchEditsWhereNeeded(event);
|
|
431
|
-
}
|
|
432
|
-
})();
|
|
402
|
+
async processEvent(event) {
|
|
403
|
+
if (event) {
|
|
404
|
+
this.setEventMetadata(event);
|
|
405
|
+
await this.fetchEditsWhereNeeded(event);
|
|
406
|
+
}
|
|
433
407
|
}
|
|
434
408
|
|
|
435
409
|
/**
|
|
@@ -438,44 +412,37 @@ export class Thread extends ReadReceipt {
|
|
|
438
412
|
* and apply them to the current thread
|
|
439
413
|
* @param receipts - A collection of the receipts cached from initial sync
|
|
440
414
|
*/
|
|
441
|
-
processReceipts() {
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
415
|
+
processReceipts(receipts = []) {
|
|
416
|
+
for (const {
|
|
417
|
+
eventId,
|
|
418
|
+
receiptType,
|
|
419
|
+
userId,
|
|
420
|
+
receipt,
|
|
421
|
+
synthetic
|
|
422
|
+
} of receipts) {
|
|
449
423
|
this.addReceiptToStructure(eventId, receiptType, userId, receipt, synthetic);
|
|
450
424
|
}
|
|
451
425
|
}
|
|
452
|
-
getRootEventBundledRelationship() {
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
_this4.updatePendingReplyCount();
|
|
469
|
-
yield _this4.processEvent(_this4.lastEvent);
|
|
470
|
-
}
|
|
471
|
-
})();
|
|
426
|
+
getRootEventBundledRelationship(rootEvent = this.rootEvent) {
|
|
427
|
+
return rootEvent?.getServerAggregatedRelation(THREAD_RELATION_TYPE.name);
|
|
428
|
+
}
|
|
429
|
+
async processRootEvent() {
|
|
430
|
+
const bundledRelationship = this.getRootEventBundledRelationship();
|
|
431
|
+
if (Thread.hasServerSideSupport && bundledRelationship) {
|
|
432
|
+
this.replyCount = bundledRelationship.count;
|
|
433
|
+
this._currentUserParticipated = !!bundledRelationship.current_user_participated;
|
|
434
|
+
const mapper = this.client.getEventMapper();
|
|
435
|
+
// re-insert roomId
|
|
436
|
+
this.lastEvent = mapper(_objectSpread(_objectSpread({}, bundledRelationship.latest_event), {}, {
|
|
437
|
+
room_id: this.roomId
|
|
438
|
+
}));
|
|
439
|
+
this.updatePendingReplyCount();
|
|
440
|
+
await this.processEvent(this.lastEvent);
|
|
441
|
+
}
|
|
472
442
|
}
|
|
473
443
|
updatePendingReplyCount() {
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
var _this$lastEvent2;
|
|
477
|
-
return ev.threadRootId === this.id && ev.isRelation(THREAD_RELATION_TYPE.name) && ev.status !== null && ev.getId() !== ((_this$lastEvent2 = this.lastEvent) === null || _this$lastEvent2 === void 0 ? void 0 : _this$lastEvent2.getId());
|
|
478
|
-
});
|
|
444
|
+
const unfilteredPendingEvents = this.pendingEventOrdering === PendingEventOrdering.Detached ? this.room.getPendingEvents() : this.events;
|
|
445
|
+
const pendingEvents = unfilteredPendingEvents.filter(ev => ev.threadRootId === this.id && ev.isRelation(THREAD_RELATION_TYPE.name) && ev.status !== null && ev.getId() !== this.lastEvent?.getId());
|
|
479
446
|
this.lastPendingEvent = pendingEvents.length ? pendingEvents[pendingEvents.length - 1] : undefined;
|
|
480
447
|
this.pendingReplyCount = pendingEvents.length;
|
|
481
448
|
}
|
|
@@ -494,147 +461,125 @@ export class Thread extends ReadReceipt {
|
|
|
494
461
|
* timeline which would otherwise be unable to paginate forwards without this token).
|
|
495
462
|
* Removing just the old live timeline whilst preserving previous ones is not supported.
|
|
496
463
|
*/
|
|
497
|
-
resetLiveTimeline(backPaginationToken, forwardPaginationToken) {
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
_this5.timelineSet.resetLiveTimeline(backPaginationToken !== null && backPaginationToken !== void 0 ? backPaginationToken : undefined, forwardPaginationToken !== null && forwardPaginationToken !== void 0 ? forwardPaginationToken : undefined);
|
|
502
|
-
var newLive = _this5.liveTimeline;
|
|
464
|
+
async resetLiveTimeline(backPaginationToken, forwardPaginationToken) {
|
|
465
|
+
const oldLive = this.liveTimeline;
|
|
466
|
+
this.timelineSet.resetLiveTimeline(backPaginationToken ?? undefined, forwardPaginationToken ?? undefined);
|
|
467
|
+
const newLive = this.liveTimeline;
|
|
503
468
|
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
469
|
+
// FIXME: Remove the following as soon as https://github.com/matrix-org/synapse/issues/14830 is resolved.
|
|
470
|
+
//
|
|
471
|
+
// The pagination API for thread timelines currently can't handle the type of pagination tokens returned by sync
|
|
472
|
+
//
|
|
473
|
+
// To make this work anyway, we'll have to transform them into one of the types that the API can handle.
|
|
474
|
+
// One option is passing the tokens to /messages, which can handle sync tokens, and returns the right format.
|
|
475
|
+
// /messages does not return new tokens on requests with a limit of 0.
|
|
476
|
+
// This means our timelines might overlap a slight bit, but that's not an issue, as we deduplicate messages
|
|
477
|
+
// anyway.
|
|
513
478
|
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
if (
|
|
538
|
-
|
|
539
|
-
// don't want the thread preview to be empty if we can avoid it
|
|
540
|
-
if (!_this6.initialEventsFetched && !_this6.lastEvent) {
|
|
541
|
-
yield _this6.processRootEvent();
|
|
542
|
-
}
|
|
543
|
-
yield _this6.fetchRootEvent();
|
|
544
|
-
}
|
|
545
|
-
yield _this6.processRootEvent();
|
|
546
|
-
})();
|
|
547
|
-
}
|
|
548
|
-
updateThreadMetadata() {
|
|
549
|
-
var _this7 = this;
|
|
550
|
-
return _asyncToGenerator(function* () {
|
|
551
|
-
_this7.updatePendingReplyCount();
|
|
552
|
-
if (!_this7.processRootEventPromise) {
|
|
553
|
-
// We only want to do this once otherwise we end up rolling back to the last unsigned summary we have for the thread
|
|
554
|
-
_this7.processRootEventPromise = _this7.updateThreadFromRootEvent();
|
|
479
|
+
let newBackward;
|
|
480
|
+
let oldForward;
|
|
481
|
+
if (backPaginationToken) {
|
|
482
|
+
const res = await this.client.createMessagesRequest(this.roomId, backPaginationToken, 1, Direction.Forward);
|
|
483
|
+
newBackward = res.end;
|
|
484
|
+
}
|
|
485
|
+
if (forwardPaginationToken) {
|
|
486
|
+
const res = await this.client.createMessagesRequest(this.roomId, forwardPaginationToken, 1, Direction.Backward);
|
|
487
|
+
oldForward = res.start;
|
|
488
|
+
}
|
|
489
|
+
// Only replace the token if we don't have paginated away from this position already. This situation doesn't
|
|
490
|
+
// occur today, but if the above issue is resolved, we'd have to go down this path.
|
|
491
|
+
if (forwardPaginationToken && oldLive.getPaginationToken(Direction.Forward) === forwardPaginationToken) {
|
|
492
|
+
oldLive.setPaginationToken(oldForward ?? null, Direction.Forward);
|
|
493
|
+
}
|
|
494
|
+
if (backPaginationToken && newLive.getPaginationToken(Direction.Backward) === backPaginationToken) {
|
|
495
|
+
newLive.setPaginationToken(newBackward ?? null, Direction.Backward);
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
async updateThreadFromRootEvent() {
|
|
499
|
+
if (Thread.hasServerSideSupport) {
|
|
500
|
+
// Ensure we show *something* as soon as possible, we'll update it as soon as we get better data, but we
|
|
501
|
+
// don't want the thread preview to be empty if we can avoid it
|
|
502
|
+
if (!this.initialEventsFetched && !this.lastEvent) {
|
|
503
|
+
await this.processRootEvent();
|
|
555
504
|
}
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
505
|
+
await this.fetchRootEvent();
|
|
506
|
+
}
|
|
507
|
+
await this.processRootEvent();
|
|
508
|
+
}
|
|
509
|
+
async updateThreadMetadata() {
|
|
510
|
+
this.updatePendingReplyCount();
|
|
511
|
+
if (!this.processRootEventPromise) {
|
|
512
|
+
// We only want to do this once otherwise we end up rolling back to the last unsigned summary we have for the thread
|
|
513
|
+
this.processRootEventPromise = this.updateThreadFromRootEvent();
|
|
514
|
+
}
|
|
515
|
+
await this.processRootEventPromise;
|
|
516
|
+
if (!this.initialEventsFetched) {
|
|
517
|
+
if (this.initalEventFetchProm) {
|
|
518
|
+
await this.initalEventFetchProm;
|
|
519
|
+
} else {
|
|
520
|
+
// fetch initial events to allow proper pagination
|
|
521
|
+
try {
|
|
522
|
+
// clear out any events that were added before the pagination request
|
|
523
|
+
// completed (eg. from sync). They'll be replaced by those from the pagination.
|
|
524
|
+
// Really, we should do this after the pagination request completes, but
|
|
525
|
+
// paginateEventTimeline does the request and adds the events in one go, so
|
|
526
|
+
// this would need a refactor in order to do. It's therefore possible there's
|
|
527
|
+
// a remaining race where an event comes in while the pagination request is
|
|
528
|
+
// happening.
|
|
529
|
+
this.timelineSet.resetLiveTimeline();
|
|
530
|
+
// if the thread has regular events, this will just load the last reply.
|
|
531
|
+
// if the thread is newly created, this will load the root event.
|
|
532
|
+
if (this.replyCount === 0 && this.rootEvent) {
|
|
533
|
+
this.timelineSet.addEventsToTimeline([this.rootEvent], true, false, this.liveTimeline, null);
|
|
534
|
+
this.liveTimeline.setPaginationToken(null, Direction.Backward);
|
|
535
|
+
} else {
|
|
536
|
+
this.initalEventFetchProm = this.client.paginateEventTimeline(this.liveTimeline, {
|
|
537
|
+
backwards: true
|
|
538
|
+
});
|
|
539
|
+
await this.initalEventFetchProm;
|
|
540
|
+
}
|
|
541
|
+
// We have now fetched the initial events, so set the flag. We need to do this before
|
|
542
|
+
// we actually add the events, so `this.addEvents` knows that it can now safely add
|
|
543
|
+
// them rather than buffer them in the pending event list. The main thing is that this
|
|
544
|
+
// must remain false while the async fetch happens, so we don't try to add events before
|
|
545
|
+
// the pagination has finished. The important thing is that we're not await-ing anything
|
|
546
|
+
// else between setting this and adding events, so no races.
|
|
547
|
+
this.initialEventsFetched = true;
|
|
548
|
+
for (const event of this.replayEvents) {
|
|
549
|
+
this.addEvent(event, false);
|
|
599
550
|
}
|
|
551
|
+
this.replayEvents = null;
|
|
552
|
+
// just to make sure that, if we've created a timeline window for this thread before the thread itself
|
|
553
|
+
// existed (e.g. when creating a new thread), we'll make sure the panel is force refreshed correctly.
|
|
554
|
+
this.emit(RoomEvent.TimelineReset, this.room, this.timelineSet, true);
|
|
555
|
+
} catch (e) {
|
|
556
|
+
logger.error("Failed to load start of newly created thread: ", e);
|
|
557
|
+
this.initialEventsFetched = false;
|
|
600
558
|
}
|
|
601
559
|
}
|
|
602
|
-
|
|
603
|
-
|
|
560
|
+
}
|
|
561
|
+
this.emit(ThreadEvent.Update, this);
|
|
604
562
|
}
|
|
605
563
|
|
|
606
564
|
// XXX: Workaround for https://github.com/matrix-org/matrix-spec-proposals/pull/2676/files#r827240084
|
|
607
|
-
fetchEditsWhereNeeded() {
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
for (var _len = _arguments.length, events = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
615
|
-
events[_key] = _arguments[_key];
|
|
616
|
-
}
|
|
617
|
-
return Promise.all(events.filter(isAnEncryptedThreadMessage).map(/*#__PURE__*/function () {
|
|
618
|
-
var _ref6 = _asyncToGenerator(function* (event) {
|
|
619
|
-
try {
|
|
620
|
-
var relations = yield _this8.client.relations(_this8.roomId, event.getId(), RelationType.Replace, event.getType(), {
|
|
621
|
-
limit: 1
|
|
622
|
-
});
|
|
623
|
-
if (relations.events.length) {
|
|
624
|
-
var editEvent = relations.events[0];
|
|
625
|
-
event.makeReplaced(editEvent);
|
|
626
|
-
_this8.insertEventIntoTimeline(editEvent);
|
|
627
|
-
}
|
|
628
|
-
} catch (e) {
|
|
629
|
-
logger.error("Failed to load edits for encrypted thread event", e);
|
|
630
|
-
}
|
|
565
|
+
async fetchEditsWhereNeeded(...events) {
|
|
566
|
+
const recursionSupport = this.client.canSupport.get(Feature.RelationsRecursion) ?? ServerSupport.Unsupported;
|
|
567
|
+
if (recursionSupport === ServerSupport.Unsupported) {
|
|
568
|
+
return Promise.all(events.filter(isAnEncryptedThreadMessage).map(async event => {
|
|
569
|
+
try {
|
|
570
|
+
const relations = await this.client.relations(this.roomId, event.getId(), RelationType.Replace, event.getType(), {
|
|
571
|
+
limit: 1
|
|
631
572
|
});
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
573
|
+
if (relations.events.length) {
|
|
574
|
+
const editEvent = relations.events[0];
|
|
575
|
+
event.makeReplaced(editEvent);
|
|
576
|
+
this.insertEventIntoTimeline(editEvent);
|
|
577
|
+
}
|
|
578
|
+
} catch (e) {
|
|
579
|
+
logger.error("Failed to load edits for encrypted thread event", e);
|
|
580
|
+
}
|
|
581
|
+
}));
|
|
582
|
+
}
|
|
638
583
|
}
|
|
639
584
|
setEventMetadata(event) {
|
|
640
585
|
if (event) {
|
|
@@ -644,9 +589,8 @@ export class Thread extends ReadReceipt {
|
|
|
644
589
|
}
|
|
645
590
|
clearEventMetadata(event) {
|
|
646
591
|
if (event) {
|
|
647
|
-
var _event$event;
|
|
648
592
|
event.setThread(undefined);
|
|
649
|
-
|
|
593
|
+
delete event.event?.unsigned?.["m.relations"]?.[THREAD_RELATION_TYPE.name];
|
|
650
594
|
}
|
|
651
595
|
}
|
|
652
596
|
|
|
@@ -660,10 +604,9 @@ export class Thread extends ReadReceipt {
|
|
|
660
604
|
/**
|
|
661
605
|
* Return last reply to the thread, if known.
|
|
662
606
|
*/
|
|
663
|
-
lastReply() {
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
var event = this.timeline[i];
|
|
607
|
+
lastReply(matches = ev => ev.isRelation(THREAD_RELATION_TYPE.name)) {
|
|
608
|
+
for (let i = this.timeline.length - 1; i >= 0; i--) {
|
|
609
|
+
const event = this.timeline[i];
|
|
667
610
|
if (matches(event)) {
|
|
668
611
|
return event;
|
|
669
612
|
}
|
|
@@ -688,8 +631,7 @@ export class Thread extends ReadReceipt {
|
|
|
688
631
|
* This might be a synthesized event, if so, it will not emit any events to listeners.
|
|
689
632
|
*/
|
|
690
633
|
get replyToEvent() {
|
|
691
|
-
|
|
692
|
-
return (_ref7 = (_this$lastPendingEven = this.lastPendingEvent) !== null && _this$lastPendingEven !== void 0 ? _this$lastPendingEven : this.lastEvent) !== null && _ref7 !== void 0 ? _ref7 : this.lastReply();
|
|
634
|
+
return this.lastPendingEvent ?? this.lastEvent ?? this.lastReply();
|
|
693
635
|
}
|
|
694
636
|
|
|
695
637
|
/**
|
|
@@ -751,32 +693,31 @@ export class Thread extends ReadReceipt {
|
|
|
751
693
|
//
|
|
752
694
|
// --- andyb
|
|
753
695
|
|
|
754
|
-
|
|
755
|
-
|
|
696
|
+
const isCurrentUser = userId === this.client.getUserId();
|
|
697
|
+
const lastReply = this.timeline[this.timeline.length - 1];
|
|
756
698
|
if (isCurrentUser && lastReply) {
|
|
757
699
|
// If the last activity in a thread is prior to the first threaded read receipt
|
|
758
700
|
// sent in the room (suggesting that it was sent before the user started
|
|
759
701
|
// using a client that supported threaded read receipts), we want to
|
|
760
702
|
// consider this thread as read.
|
|
761
|
-
|
|
762
|
-
|
|
703
|
+
const beforeFirstThreadedReceipt = lastReply.getTs() < this.room.getOldestThreadedReceiptTs();
|
|
704
|
+
const lastReplyId = lastReply.getId();
|
|
763
705
|
// Some unsent events do not have an ID, we do not want to consider them read
|
|
764
706
|
if (beforeFirstThreadedReceipt && lastReplyId) {
|
|
765
707
|
return lastReplyId;
|
|
766
708
|
}
|
|
767
709
|
}
|
|
768
|
-
|
|
710
|
+
const readUpToId = super.getEventReadUpTo(userId, ignoreSynthesized);
|
|
769
711
|
|
|
770
712
|
// Check whether the unthreaded read receipt for that user is more recent
|
|
771
713
|
// than the read receipt inside that thread.
|
|
772
714
|
if (lastReply) {
|
|
773
|
-
|
|
715
|
+
const unthreadedReceipt = this.room.getLastUnthreadedReceiptFor(userId);
|
|
774
716
|
if (!unthreadedReceipt) {
|
|
775
717
|
return readUpToId;
|
|
776
718
|
}
|
|
777
|
-
for (
|
|
778
|
-
|
|
779
|
-
var ev = this.timeline[i];
|
|
719
|
+
for (let i = this.timeline?.length - 1; i >= 0; --i) {
|
|
720
|
+
const ev = this.timeline[i];
|
|
780
721
|
// If we encounter the `readUpToId` we do not need to look further
|
|
781
722
|
// there is no "more recent" unthreaded read receipt
|
|
782
723
|
if (ev.getId() === readUpToId) return readUpToId;
|
|
@@ -785,7 +726,7 @@ export class Thread extends ReadReceipt {
|
|
|
785
726
|
// whether an unthreaded read receipt is more recent that the current event.
|
|
786
727
|
// We usually prefer relying on the order of the DAG but in this scenario
|
|
787
728
|
// it is not possible and we have to rely on timestamp
|
|
788
|
-
if (ev.getTs() < unthreadedReceipt.ts) return
|
|
729
|
+
if (ev.getTs() < unthreadedReceipt.ts) return ev.getId() ?? readUpToId;
|
|
789
730
|
}
|
|
790
731
|
}
|
|
791
732
|
return readUpToId;
|
|
@@ -804,14 +745,13 @@ export class Thread extends ReadReceipt {
|
|
|
804
745
|
*/
|
|
805
746
|
hasUserReadEvent(userId, eventId) {
|
|
806
747
|
if (userId === this.client.getUserId()) {
|
|
807
|
-
var _this$lastReply$getTs, _this$lastReply, _this$room$getLastUnt, _this$room$getLastUnt2, _this$lastReply$getTs2, _this$lastReply2;
|
|
808
748
|
// Consider an event read if it's part of a thread that is before the
|
|
809
749
|
// first threaded receipt sent in that room. It is likely that it is
|
|
810
750
|
// part of a thread that was created before MSC3771 was implemented.
|
|
811
751
|
// Or before the last unthreaded receipt for the logged in user
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
752
|
+
const beforeFirstThreadedReceipt = (this.lastReply()?.getTs() ?? 0) < this.room.getOldestThreadedReceiptTs();
|
|
753
|
+
const unthreadedReceiptTs = this.room.getLastUnthreadedReceiptFor(userId)?.ts ?? 0;
|
|
754
|
+
const beforeLastUnthreadedReceipt = (this?.lastReply()?.getTs() ?? 0) < unthreadedReceiptTs;
|
|
815
755
|
if (beforeFirstThreadedReceipt || beforeLastUnthreadedReceipt) {
|
|
816
756
|
return true;
|
|
817
757
|
}
|
|
@@ -846,10 +786,10 @@ _defineProperty(Thread, "hasServerSideFwdPaginationSupport", FeatureSupport.None
|
|
|
846
786
|
function isAnEncryptedThreadMessage(event) {
|
|
847
787
|
return event.isEncrypted() && (event.isRelation(THREAD_RELATION_TYPE.name) || event.isThreadRoot);
|
|
848
788
|
}
|
|
849
|
-
export
|
|
850
|
-
export
|
|
851
|
-
export
|
|
852
|
-
export
|
|
789
|
+
export const FILTER_RELATED_BY_SENDERS = new ServerControlledNamespacedValue("related_by_senders", "io.element.relation_senders");
|
|
790
|
+
export const FILTER_RELATED_BY_REL_TYPES = new ServerControlledNamespacedValue("related_by_rel_types", "io.element.relation_types");
|
|
791
|
+
export const THREAD_RELATION_TYPE = new ServerControlledNamespacedValue("m.thread", "io.element.thread");
|
|
792
|
+
export let ThreadFilterType = /*#__PURE__*/function (ThreadFilterType) {
|
|
853
793
|
ThreadFilterType[ThreadFilterType["My"] = 0] = "My";
|
|
854
794
|
ThreadFilterType[ThreadFilterType["All"] = 1] = "All";
|
|
855
795
|
return ThreadFilterType;
|