@unwanted/matrix-sdk-mini 34.12.0-1
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +5910 -0
- package/LICENSE +177 -0
- package/README.md +459 -0
- package/git-revision.txt +1 -0
- package/lib/@types/AESEncryptedSecretStoragePayload.d.ts +14 -0
- package/lib/@types/AESEncryptedSecretStoragePayload.d.ts.map +1 -0
- package/lib/@types/AESEncryptedSecretStoragePayload.js +1 -0
- package/lib/@types/AESEncryptedSecretStoragePayload.js.map +1 -0
- package/lib/@types/IIdentityServerProvider.d.ts +9 -0
- package/lib/@types/IIdentityServerProvider.d.ts.map +1 -0
- package/lib/@types/IIdentityServerProvider.js +1 -0
- package/lib/@types/IIdentityServerProvider.js.map +1 -0
- package/lib/@types/PushRules.d.ts +140 -0
- package/lib/@types/PushRules.d.ts.map +1 -0
- package/lib/@types/PushRules.js +94 -0
- package/lib/@types/PushRules.js.map +1 -0
- package/lib/@types/another-json.d.js +0 -0
- package/lib/@types/another-json.d.js.map +1 -0
- package/lib/@types/auth.d.ts +208 -0
- package/lib/@types/auth.d.ts.map +1 -0
- package/lib/@types/auth.js +99 -0
- package/lib/@types/auth.js.map +1 -0
- package/lib/@types/beacon.d.ts +106 -0
- package/lib/@types/beacon.d.ts.map +1 -0
- package/lib/@types/beacon.js +119 -0
- package/lib/@types/beacon.js.map +1 -0
- package/lib/@types/common.d.ts +9 -0
- package/lib/@types/common.d.ts.map +1 -0
- package/lib/@types/common.js +1 -0
- package/lib/@types/common.js.map +1 -0
- package/lib/@types/crypto.d.ts +47 -0
- package/lib/@types/crypto.d.ts.map +1 -0
- package/lib/@types/crypto.js +1 -0
- package/lib/@types/crypto.js.map +1 -0
- package/lib/@types/event.d.ts +258 -0
- package/lib/@types/event.d.ts.map +1 -0
- package/lib/@types/event.js +239 -0
- package/lib/@types/event.js.map +1 -0
- package/lib/@types/events.d.ts +92 -0
- package/lib/@types/events.d.ts.map +1 -0
- package/lib/@types/events.js +1 -0
- package/lib/@types/events.js.map +1 -0
- package/lib/@types/extensible_events.d.ts +98 -0
- package/lib/@types/extensible_events.d.ts.map +1 -0
- package/lib/@types/extensible_events.js +116 -0
- package/lib/@types/extensible_events.js.map +1 -0
- package/lib/@types/global.d.js +20 -0
- package/lib/@types/global.d.js.map +1 -0
- package/lib/@types/local_notifications.d.ts +4 -0
- package/lib/@types/local_notifications.d.ts.map +1 -0
- package/lib/@types/local_notifications.js +1 -0
- package/lib/@types/local_notifications.js.map +1 -0
- package/lib/@types/location.d.ts +60 -0
- package/lib/@types/location.d.ts.map +1 -0
- package/lib/@types/location.js +67 -0
- package/lib/@types/location.js.map +1 -0
- package/lib/@types/matrix-sdk-crypto-wasm.d.js +1 -0
- package/lib/@types/matrix-sdk-crypto-wasm.d.js.map +1 -0
- package/lib/@types/media.d.ts +220 -0
- package/lib/@types/media.d.ts.map +1 -0
- package/lib/@types/media.js +1 -0
- package/lib/@types/media.js.map +1 -0
- package/lib/@types/membership.d.ts +41 -0
- package/lib/@types/membership.d.ts.map +1 -0
- package/lib/@types/membership.js +37 -0
- package/lib/@types/membership.js.map +1 -0
- package/lib/@types/oidc-client-ts.d.js +18 -0
- package/lib/@types/oidc-client-ts.d.js.map +1 -0
- package/lib/@types/partials.d.ts +39 -0
- package/lib/@types/partials.d.ts.map +1 -0
- package/lib/@types/partials.js +53 -0
- package/lib/@types/partials.js.map +1 -0
- package/lib/@types/polls.d.ts +88 -0
- package/lib/@types/polls.d.ts.map +1 -0
- package/lib/@types/polls.js +86 -0
- package/lib/@types/polls.js.map +1 -0
- package/lib/@types/read_receipts.d.ts +36 -0
- package/lib/@types/read_receipts.d.ts.map +1 -0
- package/lib/@types/read_receipts.js +27 -0
- package/lib/@types/read_receipts.js.map +1 -0
- package/lib/@types/registration.d.ts +85 -0
- package/lib/@types/registration.d.ts.map +1 -0
- package/lib/@types/registration.js +1 -0
- package/lib/@types/registration.js.map +1 -0
- package/lib/@types/requests.d.ts +241 -0
- package/lib/@types/requests.d.ts.map +1 -0
- package/lib/@types/requests.js +28 -0
- package/lib/@types/requests.js.map +1 -0
- package/lib/@types/search.d.ts +90 -0
- package/lib/@types/search.d.ts.map +1 -0
- package/lib/@types/search.js +30 -0
- package/lib/@types/search.js.map +1 -0
- package/lib/@types/signed.d.ts +9 -0
- package/lib/@types/signed.d.ts.map +1 -0
- package/lib/@types/signed.js +1 -0
- package/lib/@types/signed.js.map +1 -0
- package/lib/@types/spaces.d.ts +16 -0
- package/lib/@types/spaces.d.ts.map +1 -0
- package/lib/@types/spaces.js +1 -0
- package/lib/@types/spaces.js.map +1 -0
- package/lib/@types/state_events.d.ts +116 -0
- package/lib/@types/state_events.d.ts.map +1 -0
- package/lib/@types/state_events.js +1 -0
- package/lib/@types/state_events.js.map +1 -0
- package/lib/@types/synapse.d.ts +19 -0
- package/lib/@types/synapse.d.ts.map +1 -0
- package/lib/@types/synapse.js +1 -0
- package/lib/@types/synapse.js.map +1 -0
- package/lib/@types/sync.d.ts +8 -0
- package/lib/@types/sync.d.ts.map +1 -0
- package/lib/@types/sync.js +25 -0
- package/lib/@types/sync.js.map +1 -0
- package/lib/@types/threepids.d.ts +12 -0
- package/lib/@types/threepids.d.ts.map +1 -0
- package/lib/@types/threepids.js +24 -0
- package/lib/@types/threepids.js.map +1 -0
- package/lib/@types/topic.d.ts +48 -0
- package/lib/@types/topic.d.ts.map +1 -0
- package/lib/@types/topic.js +57 -0
- package/lib/@types/topic.js.map +1 -0
- package/lib/@types/uia.d.ts +12 -0
- package/lib/@types/uia.d.ts.map +1 -0
- package/lib/@types/uia.js +1 -0
- package/lib/@types/uia.js.map +1 -0
- package/lib/NamespacedValue.d.ts +33 -0
- package/lib/NamespacedValue.d.ts.map +1 -0
- package/lib/NamespacedValue.js +113 -0
- package/lib/NamespacedValue.js.map +1 -0
- package/lib/ReEmitter.d.ts +15 -0
- package/lib/ReEmitter.d.ts.map +1 -0
- package/lib/ReEmitter.js +87 -0
- package/lib/ReEmitter.js.map +1 -0
- package/lib/ToDeviceMessageQueue.d.ts +28 -0
- package/lib/ToDeviceMessageQueue.d.ts.map +1 -0
- package/lib/ToDeviceMessageQueue.js +135 -0
- package/lib/ToDeviceMessageQueue.js.map +1 -0
- package/lib/autodiscovery.d.ts +136 -0
- package/lib/autodiscovery.d.ts.map +1 -0
- package/lib/autodiscovery.js +464 -0
- package/lib/autodiscovery.js.map +1 -0
- package/lib/base64.d.ts +28 -0
- package/lib/base64.d.ts.map +1 -0
- package/lib/base64.js +88 -0
- package/lib/base64.js.map +1 -0
- package/lib/browser-index.d.ts +8 -0
- package/lib/browser-index.d.ts.map +1 -0
- package/lib/browser-index.js +35 -0
- package/lib/browser-index.js.map +1 -0
- package/lib/client.d.ts +4232 -0
- package/lib/client.d.ts.map +1 -0
- package/lib/client.js +8622 -0
- package/lib/client.js.map +1 -0
- package/lib/common-crypto/CryptoBackend.d.ts +240 -0
- package/lib/common-crypto/CryptoBackend.d.ts.map +1 -0
- package/lib/common-crypto/CryptoBackend.js +73 -0
- package/lib/common-crypto/CryptoBackend.js.map +1 -0
- package/lib/common-crypto/key-passphrase.d.ts +14 -0
- package/lib/common-crypto/key-passphrase.d.ts.map +1 -0
- package/lib/common-crypto/key-passphrase.js +33 -0
- package/lib/common-crypto/key-passphrase.js.map +1 -0
- package/lib/content-helpers.d.ts +90 -0
- package/lib/content-helpers.d.ts.map +1 -0
- package/lib/content-helpers.js +250 -0
- package/lib/content-helpers.js.map +1 -0
- package/lib/content-repo.d.ts +24 -0
- package/lib/content-repo.d.ts.map +1 -0
- package/lib/content-repo.js +104 -0
- package/lib/content-repo.js.map +1 -0
- package/lib/crypto/CrossSigning.d.ts +184 -0
- package/lib/crypto/CrossSigning.d.ts.map +1 -0
- package/lib/crypto/CrossSigning.js +718 -0
- package/lib/crypto/CrossSigning.js.map +1 -0
- package/lib/crypto/DeviceList.d.ts +216 -0
- package/lib/crypto/DeviceList.d.ts.map +1 -0
- package/lib/crypto/DeviceList.js +892 -0
- package/lib/crypto/DeviceList.js.map +1 -0
- package/lib/crypto/EncryptionSetup.d.ts +152 -0
- package/lib/crypto/EncryptionSetup.d.ts.map +1 -0
- package/lib/crypto/EncryptionSetup.js +356 -0
- package/lib/crypto/EncryptionSetup.js.map +1 -0
- package/lib/crypto/OlmDevice.d.ts +457 -0
- package/lib/crypto/OlmDevice.d.ts.map +1 -0
- package/lib/crypto/OlmDevice.js +1241 -0
- package/lib/crypto/OlmDevice.js.map +1 -0
- package/lib/crypto/OutgoingRoomKeyRequestManager.d.ts +109 -0
- package/lib/crypto/OutgoingRoomKeyRequestManager.d.ts.map +1 -0
- package/lib/crypto/OutgoingRoomKeyRequestManager.js +415 -0
- package/lib/crypto/OutgoingRoomKeyRequestManager.js.map +1 -0
- package/lib/crypto/RoomList.d.ts +26 -0
- package/lib/crypto/RoomList.d.ts.map +1 -0
- package/lib/crypto/RoomList.js +71 -0
- package/lib/crypto/RoomList.js.map +1 -0
- package/lib/crypto/SecretSharing.d.ts +24 -0
- package/lib/crypto/SecretSharing.d.ts.map +1 -0
- package/lib/crypto/SecretSharing.js +194 -0
- package/lib/crypto/SecretSharing.js.map +1 -0
- package/lib/crypto/SecretStorage.d.ts +55 -0
- package/lib/crypto/SecretStorage.d.ts.map +1 -0
- package/lib/crypto/SecretStorage.js +118 -0
- package/lib/crypto/SecretStorage.js.map +1 -0
- package/lib/crypto/aes.d.ts +6 -0
- package/lib/crypto/aes.d.ts.map +1 -0
- package/lib/crypto/aes.js +24 -0
- package/lib/crypto/aes.js.map +1 -0
- package/lib/crypto/algorithms/base.d.ts +156 -0
- package/lib/crypto/algorithms/base.d.ts.map +1 -0
- package/lib/crypto/algorithms/base.js +187 -0
- package/lib/crypto/algorithms/base.js.map +1 -0
- package/lib/crypto/algorithms/index.d.ts +4 -0
- package/lib/crypto/algorithms/index.d.ts.map +1 -0
- package/lib/crypto/algorithms/index.js +20 -0
- package/lib/crypto/algorithms/index.js.map +1 -0
- package/lib/crypto/algorithms/megolm.d.ts +385 -0
- package/lib/crypto/algorithms/megolm.d.ts.map +1 -0
- package/lib/crypto/algorithms/megolm.js +1822 -0
- package/lib/crypto/algorithms/megolm.js.map +1 -0
- package/lib/crypto/algorithms/olm.d.ts +5 -0
- package/lib/crypto/algorithms/olm.d.ts.map +1 -0
- package/lib/crypto/algorithms/olm.js +299 -0
- package/lib/crypto/algorithms/olm.js.map +1 -0
- package/lib/crypto/api.d.ts +32 -0
- package/lib/crypto/api.d.ts.map +1 -0
- package/lib/crypto/api.js +22 -0
- package/lib/crypto/api.js.map +1 -0
- package/lib/crypto/backup.d.ts +227 -0
- package/lib/crypto/backup.d.ts.map +1 -0
- package/lib/crypto/backup.js +824 -0
- package/lib/crypto/backup.js.map +1 -0
- package/lib/crypto/crypto.d.ts +3 -0
- package/lib/crypto/crypto.d.ts.map +1 -0
- package/lib/crypto/crypto.js +19 -0
- package/lib/crypto/crypto.js.map +1 -0
- package/lib/crypto/dehydration.d.ts +34 -0
- package/lib/crypto/dehydration.d.ts.map +1 -0
- package/lib/crypto/dehydration.js +252 -0
- package/lib/crypto/dehydration.js.map +1 -0
- package/lib/crypto/device-converter.d.ts +9 -0
- package/lib/crypto/device-converter.d.ts.map +1 -0
- package/lib/crypto/device-converter.js +42 -0
- package/lib/crypto/device-converter.js.map +1 -0
- package/lib/crypto/deviceinfo.d.ts +99 -0
- package/lib/crypto/deviceinfo.d.ts.map +1 -0
- package/lib/crypto/deviceinfo.js +148 -0
- package/lib/crypto/deviceinfo.js.map +1 -0
- package/lib/crypto/index.d.ts +1209 -0
- package/lib/crypto/index.d.ts.map +1 -0
- package/lib/crypto/index.js +4097 -0
- package/lib/crypto/index.js.map +1 -0
- package/lib/crypto/key_passphrase.d.ts +14 -0
- package/lib/crypto/key_passphrase.d.ts.map +1 -0
- package/lib/crypto/key_passphrase.js +44 -0
- package/lib/crypto/key_passphrase.js.map +1 -0
- package/lib/crypto/keybackup.d.ts +18 -0
- package/lib/crypto/keybackup.d.ts.map +1 -0
- package/lib/crypto/keybackup.js +1 -0
- package/lib/crypto/keybackup.js.map +1 -0
- package/lib/crypto/olmlib.d.ts +129 -0
- package/lib/crypto/olmlib.d.ts.map +1 -0
- package/lib/crypto/olmlib.js +492 -0
- package/lib/crypto/olmlib.js.map +1 -0
- package/lib/crypto/recoverykey.d.ts +2 -0
- package/lib/crypto/recoverykey.d.ts.map +1 -0
- package/lib/crypto/recoverykey.js +19 -0
- package/lib/crypto/recoverykey.js.map +1 -0
- package/lib/crypto/store/base.d.ts +252 -0
- package/lib/crypto/store/base.d.ts.map +1 -0
- package/lib/crypto/store/base.js +64 -0
- package/lib/crypto/store/base.js.map +1 -0
- package/lib/crypto/store/indexeddb-crypto-store-backend.d.ts +187 -0
- package/lib/crypto/store/indexeddb-crypto-store-backend.d.ts.map +1 -0
- package/lib/crypto/store/indexeddb-crypto-store-backend.js +1145 -0
- package/lib/crypto/store/indexeddb-crypto-store-backend.js.map +1 -0
- package/lib/crypto/store/indexeddb-crypto-store.d.ts +432 -0
- package/lib/crypto/store/indexeddb-crypto-store.d.ts.map +1 -0
- package/lib/crypto/store/indexeddb-crypto-store.js +728 -0
- package/lib/crypto/store/indexeddb-crypto-store.js.map +1 -0
- package/lib/crypto/store/localStorage-crypto-store.d.ts +119 -0
- package/lib/crypto/store/localStorage-crypto-store.d.ts.map +1 -0
- package/lib/crypto/store/localStorage-crypto-store.js +531 -0
- package/lib/crypto/store/localStorage-crypto-store.js.map +1 -0
- package/lib/crypto/store/memory-crypto-store.d.ts +215 -0
- package/lib/crypto/store/memory-crypto-store.d.ts.map +1 -0
- package/lib/crypto/store/memory-crypto-store.js +622 -0
- package/lib/crypto/store/memory-crypto-store.js.map +1 -0
- package/lib/crypto/verification/Base.d.ts +105 -0
- package/lib/crypto/verification/Base.d.ts.map +1 -0
- package/lib/crypto/verification/Base.js +372 -0
- package/lib/crypto/verification/Base.js.map +1 -0
- package/lib/crypto/verification/Error.d.ts +35 -0
- package/lib/crypto/verification/Error.d.ts.map +1 -0
- package/lib/crypto/verification/Error.js +86 -0
- package/lib/crypto/verification/Error.js.map +1 -0
- package/lib/crypto/verification/IllegalMethod.d.ts +15 -0
- package/lib/crypto/verification/IllegalMethod.d.ts.map +1 -0
- package/lib/crypto/verification/IllegalMethod.js +43 -0
- package/lib/crypto/verification/IllegalMethod.js.map +1 -0
- package/lib/crypto/verification/QRCode.d.ts +51 -0
- package/lib/crypto/verification/QRCode.d.ts.map +1 -0
- package/lib/crypto/verification/QRCode.js +277 -0
- package/lib/crypto/verification/QRCode.js.map +1 -0
- package/lib/crypto/verification/SAS.d.ts +27 -0
- package/lib/crypto/verification/SAS.d.ts.map +1 -0
- package/lib/crypto/verification/SAS.js +485 -0
- package/lib/crypto/verification/SAS.js.map +1 -0
- package/lib/crypto/verification/SASDecimal.d.ts +8 -0
- package/lib/crypto/verification/SASDecimal.d.ts.map +1 -0
- package/lib/crypto/verification/SASDecimal.js +34 -0
- package/lib/crypto/verification/SASDecimal.js.map +1 -0
- package/lib/crypto/verification/request/Channel.d.ts +18 -0
- package/lib/crypto/verification/request/Channel.d.ts.map +1 -0
- package/lib/crypto/verification/request/Channel.js +1 -0
- package/lib/crypto/verification/request/Channel.js.map +1 -0
- package/lib/crypto/verification/request/InRoomChannel.d.ts +113 -0
- package/lib/crypto/verification/request/InRoomChannel.d.ts.map +1 -0
- package/lib/crypto/verification/request/InRoomChannel.js +351 -0
- package/lib/crypto/verification/request/InRoomChannel.js.map +1 -0
- package/lib/crypto/verification/request/ToDeviceChannel.d.ts +105 -0
- package/lib/crypto/verification/request/ToDeviceChannel.d.ts.map +1 -0
- package/lib/crypto/verification/request/ToDeviceChannel.js +328 -0
- package/lib/crypto/verification/request/ToDeviceChannel.js.map +1 -0
- package/lib/crypto/verification/request/VerificationRequest.d.ts +227 -0
- package/lib/crypto/verification/request/VerificationRequest.d.ts.map +1 -0
- package/lib/crypto/verification/request/VerificationRequest.js +937 -0
- package/lib/crypto/verification/request/VerificationRequest.js.map +1 -0
- package/lib/crypto-api/CryptoEvent.d.ts +69 -0
- package/lib/crypto-api/CryptoEvent.d.ts.map +1 -0
- package/lib/crypto-api/CryptoEvent.js +33 -0
- package/lib/crypto-api/CryptoEvent.js.map +1 -0
- package/lib/crypto-api/CryptoEventHandlerMap.d.ts +16 -0
- package/lib/crypto-api/CryptoEventHandlerMap.d.ts.map +1 -0
- package/lib/crypto-api/CryptoEventHandlerMap.js +22 -0
- package/lib/crypto-api/CryptoEventHandlerMap.js.map +1 -0
- package/lib/crypto-api/index.d.ts +978 -0
- package/lib/crypto-api/index.d.ts.map +1 -0
- package/lib/crypto-api/index.js +304 -0
- package/lib/crypto-api/index.js.map +1 -0
- package/lib/crypto-api/key-passphrase.d.ts +11 -0
- package/lib/crypto-api/key-passphrase.d.ts.map +1 -0
- package/lib/crypto-api/key-passphrase.js +51 -0
- package/lib/crypto-api/key-passphrase.js.map +1 -0
- package/lib/crypto-api/keybackup.d.ts +88 -0
- package/lib/crypto-api/keybackup.d.ts.map +1 -0
- package/lib/crypto-api/keybackup.js +1 -0
- package/lib/crypto-api/keybackup.js.map +1 -0
- package/lib/crypto-api/recovery-key.d.ts +11 -0
- package/lib/crypto-api/recovery-key.d.ts.map +1 -0
- package/lib/crypto-api/recovery-key.js +65 -0
- package/lib/crypto-api/recovery-key.js.map +1 -0
- package/lib/crypto-api/verification.d.ts +344 -0
- package/lib/crypto-api/verification.d.ts.map +1 -0
- package/lib/crypto-api/verification.js +91 -0
- package/lib/crypto-api/verification.js.map +1 -0
- package/lib/digest.d.ts +10 -0
- package/lib/digest.d.ts.map +1 -0
- package/lib/digest.js +40 -0
- package/lib/digest.js.map +1 -0
- package/lib/embedded.d.ts +143 -0
- package/lib/embedded.d.ts.map +1 -0
- package/lib/embedded.js +567 -0
- package/lib/embedded.js.map +1 -0
- package/lib/errors.d.ts +24 -0
- package/lib/errors.d.ts.map +1 -0
- package/lib/errors.js +51 -0
- package/lib/errors.js.map +1 -0
- package/lib/event-mapper.d.ts +10 -0
- package/lib/event-mapper.d.ts.map +1 -0
- package/lib/event-mapper.js +81 -0
- package/lib/event-mapper.js.map +1 -0
- package/lib/extensible_events_v1/ExtensibleEvent.d.ts +38 -0
- package/lib/extensible_events_v1/ExtensibleEvent.d.ts.map +1 -0
- package/lib/extensible_events_v1/ExtensibleEvent.js +57 -0
- package/lib/extensible_events_v1/ExtensibleEvent.js.map +1 -0
- package/lib/extensible_events_v1/InvalidEventError.d.ts +7 -0
- package/lib/extensible_events_v1/InvalidEventError.d.ts.map +1 -0
- package/lib/extensible_events_v1/InvalidEventError.js +25 -0
- package/lib/extensible_events_v1/InvalidEventError.js.map +1 -0
- package/lib/extensible_events_v1/MessageEvent.d.ts +45 -0
- package/lib/extensible_events_v1/MessageEvent.d.ts.map +1 -0
- package/lib/extensible_events_v1/MessageEvent.js +134 -0
- package/lib/extensible_events_v1/MessageEvent.js.map +1 -0
- package/lib/extensible_events_v1/PollEndEvent.d.ts +33 -0
- package/lib/extensible_events_v1/PollEndEvent.d.ts.map +1 -0
- package/lib/extensible_events_v1/PollEndEvent.js +88 -0
- package/lib/extensible_events_v1/PollEndEvent.js.map +1 -0
- package/lib/extensible_events_v1/PollResponseEvent.d.ts +49 -0
- package/lib/extensible_events_v1/PollResponseEvent.d.ts.map +1 -0
- package/lib/extensible_events_v1/PollResponseEvent.js +135 -0
- package/lib/extensible_events_v1/PollResponseEvent.js.map +1 -0
- package/lib/extensible_events_v1/PollStartEvent.d.ts +71 -0
- package/lib/extensible_events_v1/PollStartEvent.d.ts.map +1 -0
- package/lib/extensible_events_v1/PollStartEvent.js +185 -0
- package/lib/extensible_events_v1/PollStartEvent.js.map +1 -0
- package/lib/extensible_events_v1/utilities.d.ts +14 -0
- package/lib/extensible_events_v1/utilities.d.ts.map +1 -0
- package/lib/extensible_events_v1/utilities.js +34 -0
- package/lib/extensible_events_v1/utilities.js.map +1 -0
- package/lib/feature.d.ts +20 -0
- package/lib/feature.d.ts.map +1 -0
- package/lib/feature.js +85 -0
- package/lib/feature.js.map +1 -0
- package/lib/filter-component.d.ts +64 -0
- package/lib/filter-component.d.ts.map +1 -0
- package/lib/filter-component.js +167 -0
- package/lib/filter-component.js.map +1 -0
- package/lib/filter.d.ts +97 -0
- package/lib/filter.d.ts.map +1 -0
- package/lib/filter.js +207 -0
- package/lib/filter.js.map +1 -0
- package/lib/http-api/errors.d.ts +80 -0
- package/lib/http-api/errors.d.ts.map +1 -0
- package/lib/http-api/errors.js +185 -0
- package/lib/http-api/errors.js.map +1 -0
- package/lib/http-api/fetch.d.ts +114 -0
- package/lib/http-api/fetch.d.ts.map +1 -0
- package/lib/http-api/fetch.js +346 -0
- package/lib/http-api/fetch.js.map +1 -0
- package/lib/http-api/index.d.ts +33 -0
- package/lib/http-api/index.d.ts.map +1 -0
- package/lib/http-api/index.js +180 -0
- package/lib/http-api/index.js.map +1 -0
- package/lib/http-api/interface.d.ts +142 -0
- package/lib/http-api/interface.d.ts.map +1 -0
- package/lib/http-api/interface.js +35 -0
- package/lib/http-api/interface.js.map +1 -0
- package/lib/http-api/method.d.ts +10 -0
- package/lib/http-api/method.d.ts.map +1 -0
- package/lib/http-api/method.js +27 -0
- package/lib/http-api/method.js.map +1 -0
- package/lib/http-api/prefix.d.ts +31 -0
- package/lib/http-api/prefix.d.ts.map +1 -0
- package/lib/http-api/prefix.js +32 -0
- package/lib/http-api/prefix.js.map +1 -0
- package/lib/http-api/utils.d.ts +37 -0
- package/lib/http-api/utils.d.ts.map +1 -0
- package/lib/http-api/utils.js +178 -0
- package/lib/http-api/utils.js.map +1 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +24 -0
- package/lib/index.js.map +1 -0
- package/lib/indexeddb-helpers.d.ts +10 -0
- package/lib/indexeddb-helpers.d.ts.map +1 -0
- package/lib/indexeddb-helpers.js +51 -0
- package/lib/indexeddb-helpers.js.map +1 -0
- package/lib/indexeddb-worker.d.ts +7 -0
- package/lib/indexeddb-worker.d.ts.map +1 -0
- package/lib/indexeddb-worker.js +25 -0
- package/lib/indexeddb-worker.js.map +1 -0
- package/lib/interactive-auth.d.ts +337 -0
- package/lib/interactive-auth.d.ts.map +1 -0
- package/lib/interactive-auth.js +557 -0
- package/lib/interactive-auth.js.map +1 -0
- package/lib/logger.d.ts +81 -0
- package/lib/logger.d.ts.map +1 -0
- package/lib/logger.js +139 -0
- package/lib/logger.js.map +1 -0
- package/lib/matrix.d.ts +118 -0
- package/lib/matrix.d.ts.map +1 -0
- package/lib/matrix.js +146 -0
- package/lib/matrix.js.map +1 -0
- package/lib/matrixrtc/CallMembership.d.ts +66 -0
- package/lib/matrixrtc/CallMembership.d.ts.map +1 -0
- package/lib/matrixrtc/CallMembership.js +197 -0
- package/lib/matrixrtc/CallMembership.js.map +1 -0
- package/lib/matrixrtc/LivekitFocus.d.ts +16 -0
- package/lib/matrixrtc/LivekitFocus.d.ts.map +1 -0
- package/lib/matrixrtc/LivekitFocus.js +20 -0
- package/lib/matrixrtc/LivekitFocus.js.map +1 -0
- package/lib/matrixrtc/MatrixRTCSession.d.ts +295 -0
- package/lib/matrixrtc/MatrixRTCSession.d.ts.map +1 -0
- package/lib/matrixrtc/MatrixRTCSession.js +1043 -0
- package/lib/matrixrtc/MatrixRTCSession.js.map +1 -0
- package/lib/matrixrtc/MatrixRTCSessionManager.d.ts +40 -0
- package/lib/matrixrtc/MatrixRTCSessionManager.d.ts.map +1 -0
- package/lib/matrixrtc/MatrixRTCSessionManager.js +146 -0
- package/lib/matrixrtc/MatrixRTCSessionManager.js.map +1 -0
- package/lib/matrixrtc/focus.d.ts +10 -0
- package/lib/matrixrtc/focus.d.ts.map +1 -0
- package/lib/matrixrtc/focus.js +1 -0
- package/lib/matrixrtc/focus.js.map +1 -0
- package/lib/matrixrtc/index.d.ts +7 -0
- package/lib/matrixrtc/index.d.ts.map +1 -0
- package/lib/matrixrtc/index.js +21 -0
- package/lib/matrixrtc/index.js.map +1 -0
- package/lib/matrixrtc/types.d.ts +19 -0
- package/lib/matrixrtc/types.d.ts.map +1 -0
- package/lib/matrixrtc/types.js +1 -0
- package/lib/matrixrtc/types.js.map +1 -0
- package/lib/models/MSC3089Branch.d.ts +98 -0
- package/lib/models/MSC3089Branch.d.ts.map +1 -0
- package/lib/models/MSC3089Branch.js +240 -0
- package/lib/models/MSC3089Branch.js.map +1 -0
- package/lib/models/MSC3089TreeSpace.d.ts +165 -0
- package/lib/models/MSC3089TreeSpace.d.ts.map +1 -0
- package/lib/models/MSC3089TreeSpace.js +520 -0
- package/lib/models/MSC3089TreeSpace.js.map +1 -0
- package/lib/models/ToDeviceMessage.d.ts +17 -0
- package/lib/models/ToDeviceMessage.d.ts.map +1 -0
- package/lib/models/ToDeviceMessage.js +1 -0
- package/lib/models/ToDeviceMessage.js.map +1 -0
- package/lib/models/beacon.d.ts +53 -0
- package/lib/models/beacon.d.ts.map +1 -0
- package/lib/models/beacon.js +174 -0
- package/lib/models/beacon.js.map +1 -0
- package/lib/models/compare-event-ordering.d.ts +24 -0
- package/lib/models/compare-event-ordering.d.ts.map +1 -0
- package/lib/models/compare-event-ordering.js +120 -0
- package/lib/models/compare-event-ordering.js.map +1 -0
- package/lib/models/device.d.ts +45 -0
- package/lib/models/device.d.ts.map +1 -0
- package/lib/models/device.js +77 -0
- package/lib/models/device.js.map +1 -0
- package/lib/models/event-context.d.ts +62 -0
- package/lib/models/event-context.d.ts.map +1 -0
- package/lib/models/event-context.js +113 -0
- package/lib/models/event-context.js.map +1 -0
- package/lib/models/event-status.d.ts +19 -0
- package/lib/models/event-status.d.ts.map +1 -0
- package/lib/models/event-status.js +30 -0
- package/lib/models/event-status.js.map +1 -0
- package/lib/models/event-timeline-set.d.ts +312 -0
- package/lib/models/event-timeline-set.d.ts.map +1 -0
- package/lib/models/event-timeline-set.js +813 -0
- package/lib/models/event-timeline-set.js.map +1 -0
- package/lib/models/event-timeline.d.ts +219 -0
- package/lib/models/event-timeline.d.ts.map +1 -0
- package/lib/models/event-timeline.js +455 -0
- package/lib/models/event-timeline.js.map +1 -0
- package/lib/models/event.d.ts +811 -0
- package/lib/models/event.d.ts.map +1 -0
- package/lib/models/event.js +1520 -0
- package/lib/models/event.js.map +1 -0
- package/lib/models/invites-ignorer.d.ts +136 -0
- package/lib/models/invites-ignorer.d.ts.map +1 -0
- package/lib/models/invites-ignorer.js +382 -0
- package/lib/models/invites-ignorer.js.map +1 -0
- package/lib/models/poll.d.ts +67 -0
- package/lib/models/poll.d.ts.map +1 -0
- package/lib/models/poll.js +241 -0
- package/lib/models/poll.js.map +1 -0
- package/lib/models/profile-keys.d.ts +8 -0
- package/lib/models/profile-keys.d.ts.map +1 -0
- package/lib/models/profile-keys.js +8 -0
- package/lib/models/profile-keys.js.map +1 -0
- package/lib/models/read-receipt.d.ts +115 -0
- package/lib/models/read-receipt.d.ts.map +1 -0
- package/lib/models/read-receipt.js +366 -0
- package/lib/models/read-receipt.js.map +1 -0
- package/lib/models/related-relations.d.ts +11 -0
- package/lib/models/related-relations.d.ts.map +1 -0
- package/lib/models/related-relations.js +33 -0
- package/lib/models/related-relations.js.map +1 -0
- package/lib/models/relations-container.d.ts +44 -0
- package/lib/models/relations-container.d.ts.map +1 -0
- package/lib/models/relations-container.js +132 -0
- package/lib/models/relations-container.js.map +1 -0
- package/lib/models/relations.d.ts +114 -0
- package/lib/models/relations.d.ts.map +1 -0
- package/lib/models/relations.js +354 -0
- package/lib/models/relations.js.map +1 -0
- package/lib/models/room-member.d.ts +204 -0
- package/lib/models/room-member.d.ts.map +1 -0
- package/lib/models/room-member.js +360 -0
- package/lib/models/room-member.js.map +1 -0
- package/lib/models/room-receipts.d.ts +39 -0
- package/lib/models/room-receipts.d.ts.map +1 -0
- package/lib/models/room-receipts.js +392 -0
- package/lib/models/room-receipts.js.map +1 -0
- package/lib/models/room-state.d.ts +468 -0
- package/lib/models/room-state.d.ts.map +1 -0
- package/lib/models/room-state.js +984 -0
- package/lib/models/room-state.js.map +1 -0
- package/lib/models/room-summary.d.ts +29 -0
- package/lib/models/room-summary.d.ts.map +1 -0
- package/lib/models/room-summary.js +28 -0
- package/lib/models/room-summary.js.map +1 -0
- package/lib/models/room.d.ts +1203 -0
- package/lib/models/room.d.ts.map +1 -0
- package/lib/models/room.js +3336 -0
- package/lib/models/room.js.map +1 -0
- package/lib/models/search-result.d.ts +20 -0
- package/lib/models/search-result.d.ts.map +1 -0
- package/lib/models/search-result.js +52 -0
- package/lib/models/search-result.js.map +1 -0
- package/lib/models/thread.d.ts +246 -0
- package/lib/models/thread.d.ts.map +1 -0
- package/lib/models/thread.js +861 -0
- package/lib/models/thread.js.map +1 -0
- package/lib/models/typed-event-emitter.d.ts +157 -0
- package/lib/models/typed-event-emitter.d.ts.map +1 -0
- package/lib/models/typed-event-emitter.js +227 -0
- package/lib/models/typed-event-emitter.js.map +1 -0
- package/lib/models/user.d.ts +195 -0
- package/lib/models/user.d.ts.map +1 -0
- package/lib/models/user.js +218 -0
- package/lib/models/user.js.map +1 -0
- package/lib/oidc/authorize.d.ts +90 -0
- package/lib/oidc/authorize.d.ts.map +1 -0
- package/lib/oidc/authorize.js +278 -0
- package/lib/oidc/authorize.js.map +1 -0
- package/lib/oidc/discovery.d.ts +14 -0
- package/lib/oidc/discovery.d.ts.map +1 -0
- package/lib/oidc/discovery.js +66 -0
- package/lib/oidc/discovery.js.map +1 -0
- package/lib/oidc/error.d.ts +18 -0
- package/lib/oidc/error.d.ts.map +1 -0
- package/lib/oidc/error.js +35 -0
- package/lib/oidc/error.js.map +1 -0
- package/lib/oidc/index.d.ts +17 -0
- package/lib/oidc/index.d.ts.map +1 -0
- package/lib/oidc/index.js +29 -0
- package/lib/oidc/index.js.map +1 -0
- package/lib/oidc/register.d.ts +43 -0
- package/lib/oidc/register.d.ts.map +1 -0
- package/lib/oidc/register.js +96 -0
- package/lib/oidc/register.js.map +1 -0
- package/lib/oidc/tokenRefresher.d.ts +69 -0
- package/lib/oidc/tokenRefresher.d.ts.map +1 -0
- package/lib/oidc/tokenRefresher.js +148 -0
- package/lib/oidc/tokenRefresher.js.map +1 -0
- package/lib/oidc/validate.d.ts +90 -0
- package/lib/oidc/validate.d.ts.map +1 -0
- package/lib/oidc/validate.js +194 -0
- package/lib/oidc/validate.js.map +1 -0
- package/lib/pushprocessor.d.ts +128 -0
- package/lib/pushprocessor.d.ts.map +1 -0
- package/lib/pushprocessor.js +685 -0
- package/lib/pushprocessor.js.map +1 -0
- package/lib/randomstring.d.ts +5 -0
- package/lib/randomstring.d.ts.map +1 -0
- package/lib/randomstring.js +43 -0
- package/lib/randomstring.js.map +1 -0
- package/lib/realtime-callbacks.d.ts +18 -0
- package/lib/realtime-callbacks.d.ts.map +1 -0
- package/lib/realtime-callbacks.js +177 -0
- package/lib/realtime-callbacks.js.map +1 -0
- package/lib/receipt-accumulator.d.ts +51 -0
- package/lib/receipt-accumulator.d.ts.map +1 -0
- package/lib/receipt-accumulator.js +164 -0
- package/lib/receipt-accumulator.js.map +1 -0
- package/lib/rendezvous/MSC4108SignInWithQR.d.ts +112 -0
- package/lib/rendezvous/MSC4108SignInWithQR.d.ts.map +1 -0
- package/lib/rendezvous/MSC4108SignInWithQR.js +392 -0
- package/lib/rendezvous/MSC4108SignInWithQR.js.map +1 -0
- package/lib/rendezvous/RendezvousChannel.d.ts +27 -0
- package/lib/rendezvous/RendezvousChannel.d.ts.map +1 -0
- package/lib/rendezvous/RendezvousChannel.js +1 -0
- package/lib/rendezvous/RendezvousChannel.js.map +1 -0
- package/lib/rendezvous/RendezvousCode.d.ts +9 -0
- package/lib/rendezvous/RendezvousCode.d.ts.map +1 -0
- package/lib/rendezvous/RendezvousCode.js +1 -0
- package/lib/rendezvous/RendezvousCode.js.map +1 -0
- package/lib/rendezvous/RendezvousError.d.ts +6 -0
- package/lib/rendezvous/RendezvousError.d.ts.map +1 -0
- package/lib/rendezvous/RendezvousError.js +23 -0
- package/lib/rendezvous/RendezvousError.js.map +1 -0
- package/lib/rendezvous/RendezvousFailureReason.d.ts +31 -0
- package/lib/rendezvous/RendezvousFailureReason.d.ts.map +1 -0
- package/lib/rendezvous/RendezvousFailureReason.js +38 -0
- package/lib/rendezvous/RendezvousFailureReason.js.map +1 -0
- package/lib/rendezvous/RendezvousIntent.d.ts +5 -0
- package/lib/rendezvous/RendezvousIntent.d.ts.map +1 -0
- package/lib/rendezvous/RendezvousIntent.js +22 -0
- package/lib/rendezvous/RendezvousIntent.js.map +1 -0
- package/lib/rendezvous/RendezvousTransport.d.ts +36 -0
- package/lib/rendezvous/RendezvousTransport.d.ts.map +1 -0
- package/lib/rendezvous/RendezvousTransport.js +1 -0
- package/lib/rendezvous/RendezvousTransport.js.map +1 -0
- package/lib/rendezvous/channels/MSC4108SecureChannel.d.ts +58 -0
- package/lib/rendezvous/channels/MSC4108SecureChannel.d.ts.map +1 -0
- package/lib/rendezvous/channels/MSC4108SecureChannel.js +246 -0
- package/lib/rendezvous/channels/MSC4108SecureChannel.js.map +1 -0
- package/lib/rendezvous/channels/index.d.ts +2 -0
- package/lib/rendezvous/channels/index.d.ts.map +1 -0
- package/lib/rendezvous/channels/index.js +18 -0
- package/lib/rendezvous/channels/index.js.map +1 -0
- package/lib/rendezvous/index.d.ts +10 -0
- package/lib/rendezvous/index.d.ts.map +1 -0
- package/lib/rendezvous/index.js +23 -0
- package/lib/rendezvous/index.js.map +1 -0
- package/lib/rendezvous/transports/MSC4108RendezvousSession.d.ts +61 -0
- package/lib/rendezvous/transports/MSC4108RendezvousSession.d.ts.map +1 -0
- package/lib/rendezvous/transports/MSC4108RendezvousSession.js +253 -0
- package/lib/rendezvous/transports/MSC4108RendezvousSession.js.map +1 -0
- package/lib/rendezvous/transports/index.d.ts +2 -0
- package/lib/rendezvous/transports/index.d.ts.map +1 -0
- package/lib/rendezvous/transports/index.js +18 -0
- package/lib/rendezvous/transports/index.js.map +1 -0
- package/lib/room-hierarchy.d.ts +35 -0
- package/lib/room-hierarchy.d.ts.map +1 -0
- package/lib/room-hierarchy.js +136 -0
- package/lib/room-hierarchy.js.map +1 -0
- package/lib/rust-crypto/CrossSigningIdentity.d.ts +33 -0
- package/lib/rust-crypto/CrossSigningIdentity.d.ts.map +1 -0
- package/lib/rust-crypto/CrossSigningIdentity.js +157 -0
- package/lib/rust-crypto/CrossSigningIdentity.js.map +1 -0
- package/lib/rust-crypto/DehydratedDeviceManager.d.ts +98 -0
- package/lib/rust-crypto/DehydratedDeviceManager.d.ts.map +1 -0
- package/lib/rust-crypto/DehydratedDeviceManager.js +285 -0
- package/lib/rust-crypto/DehydratedDeviceManager.js.map +1 -0
- package/lib/rust-crypto/KeyClaimManager.d.ts +33 -0
- package/lib/rust-crypto/KeyClaimManager.d.ts.map +1 -0
- package/lib/rust-crypto/KeyClaimManager.js +82 -0
- package/lib/rust-crypto/KeyClaimManager.js.map +1 -0
- package/lib/rust-crypto/OutgoingRequestProcessor.d.ts +43 -0
- package/lib/rust-crypto/OutgoingRequestProcessor.d.ts.map +1 -0
- package/lib/rust-crypto/OutgoingRequestProcessor.js +195 -0
- package/lib/rust-crypto/OutgoingRequestProcessor.js.map +1 -0
- package/lib/rust-crypto/OutgoingRequestsManager.d.ts +47 -0
- package/lib/rust-crypto/OutgoingRequestsManager.d.ts.map +1 -0
- package/lib/rust-crypto/OutgoingRequestsManager.js +148 -0
- package/lib/rust-crypto/OutgoingRequestsManager.js.map +1 -0
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.d.ts +120 -0
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.d.ts.map +1 -0
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.js +467 -0
- package/lib/rust-crypto/PerSessionKeyBackupDownloader.js.map +1 -0
- package/lib/rust-crypto/RoomEncryptor.d.ts +98 -0
- package/lib/rust-crypto/RoomEncryptor.d.ts.map +1 -0
- package/lib/rust-crypto/RoomEncryptor.js +299 -0
- package/lib/rust-crypto/RoomEncryptor.js.map +1 -0
- package/lib/rust-crypto/backup.d.ts +254 -0
- package/lib/rust-crypto/backup.d.ts.map +1 -0
- package/lib/rust-crypto/backup.js +837 -0
- package/lib/rust-crypto/backup.js.map +1 -0
- package/lib/rust-crypto/constants.d.ts +3 -0
- package/lib/rust-crypto/constants.d.ts.map +1 -0
- package/lib/rust-crypto/constants.js +19 -0
- package/lib/rust-crypto/constants.js.map +1 -0
- package/lib/rust-crypto/device-converter.d.ts +28 -0
- package/lib/rust-crypto/device-converter.d.ts.map +1 -0
- package/lib/rust-crypto/device-converter.js +123 -0
- package/lib/rust-crypto/device-converter.js.map +1 -0
- package/lib/rust-crypto/index.d.ts +61 -0
- package/lib/rust-crypto/index.d.ts.map +1 -0
- package/lib/rust-crypto/index.js +152 -0
- package/lib/rust-crypto/index.js.map +1 -0
- package/lib/rust-crypto/libolm_migration.d.ts +81 -0
- package/lib/rust-crypto/libolm_migration.d.ts.map +1 -0
- package/lib/rust-crypto/libolm_migration.js +459 -0
- package/lib/rust-crypto/libolm_migration.js.map +1 -0
- package/lib/rust-crypto/rust-crypto.d.ts +556 -0
- package/lib/rust-crypto/rust-crypto.d.ts.map +1 -0
- package/lib/rust-crypto/rust-crypto.js +2016 -0
- package/lib/rust-crypto/rust-crypto.js.map +1 -0
- package/lib/rust-crypto/secret-storage.d.ts +22 -0
- package/lib/rust-crypto/secret-storage.d.ts.map +1 -0
- package/lib/rust-crypto/secret-storage.js +63 -0
- package/lib/rust-crypto/secret-storage.js.map +1 -0
- package/lib/rust-crypto/verification.d.ts +319 -0
- package/lib/rust-crypto/verification.d.ts.map +1 -0
- package/lib/rust-crypto/verification.js +816 -0
- package/lib/rust-crypto/verification.js.map +1 -0
- package/lib/scheduler.d.ts +132 -0
- package/lib/scheduler.d.ts.map +1 -0
- package/lib/scheduler.js +259 -0
- package/lib/scheduler.js.map +1 -0
- package/lib/secret-storage.d.ts +370 -0
- package/lib/secret-storage.d.ts.map +1 -0
- package/lib/secret-storage.js +466 -0
- package/lib/secret-storage.js.map +1 -0
- package/lib/serverCapabilities.d.ts +72 -0
- package/lib/serverCapabilities.d.ts.map +1 -0
- package/lib/serverCapabilities.js +105 -0
- package/lib/serverCapabilities.js.map +1 -0
- package/lib/service-types.d.ts +5 -0
- package/lib/service-types.d.ts.map +1 -0
- package/lib/service-types.js +22 -0
- package/lib/service-types.js.map +1 -0
- package/lib/sliding-sync-sdk.d.ts +107 -0
- package/lib/sliding-sync-sdk.d.ts.map +1 -0
- package/lib/sliding-sync-sdk.js +903 -0
- package/lib/sliding-sync-sdk.js.map +1 -0
- package/lib/sliding-sync.d.ts +343 -0
- package/lib/sliding-sync.d.ts.map +1 -0
- package/lib/sliding-sync.js +817 -0
- package/lib/sliding-sync.js.map +1 -0
- package/lib/store/index.d.ts +201 -0
- package/lib/store/index.d.ts.map +1 -0
- package/lib/store/index.js +1 -0
- package/lib/store/index.js.map +1 -0
- package/lib/store/indexeddb-backend.d.ts +24 -0
- package/lib/store/indexeddb-backend.d.ts.map +1 -0
- package/lib/store/indexeddb-backend.js +1 -0
- package/lib/store/indexeddb-backend.js.map +1 -0
- package/lib/store/indexeddb-local-backend.d.ts +129 -0
- package/lib/store/indexeddb-local-backend.d.ts.map +1 -0
- package/lib/store/indexeddb-local-backend.js +597 -0
- package/lib/store/indexeddb-local-backend.js.map +1 -0
- package/lib/store/indexeddb-remote-backend.d.ts +79 -0
- package/lib/store/indexeddb-remote-backend.d.ts.map +1 -0
- package/lib/store/indexeddb-remote-backend.js +210 -0
- package/lib/store/indexeddb-remote-backend.js.map +1 -0
- package/lib/store/indexeddb-store-worker.d.ts +35 -0
- package/lib/store/indexeddb-store-worker.d.ts.map +1 -0
- package/lib/store/indexeddb-store-worker.js +146 -0
- package/lib/store/indexeddb-store-worker.js.map +1 -0
- package/lib/store/indexeddb.d.ts +142 -0
- package/lib/store/indexeddb.d.ts.map +1 -0
- package/lib/store/indexeddb.js +347 -0
- package/lib/store/indexeddb.js.map +1 -0
- package/lib/store/local-storage-events-emitter.d.ts +30 -0
- package/lib/store/local-storage-events-emitter.d.ts.map +1 -0
- package/lib/store/local-storage-events-emitter.js +37 -0
- package/lib/store/local-storage-events-emitter.js.map +1 -0
- package/lib/store/memory.d.ts +209 -0
- package/lib/store/memory.d.ts.map +1 -0
- package/lib/store/memory.js +432 -0
- package/lib/store/memory.js.map +1 -0
- package/lib/store/stub.d.ts +161 -0
- package/lib/store/stub.d.ts.map +1 -0
- package/lib/store/stub.js +268 -0
- package/lib/store/stub.js.map +1 -0
- package/lib/sync-accumulator.d.ts +172 -0
- package/lib/sync-accumulator.d.ts.map +1 -0
- package/lib/sync-accumulator.js +532 -0
- package/lib/sync-accumulator.js.map +1 -0
- package/lib/sync.d.ts +260 -0
- package/lib/sync.d.ts.map +1 -0
- package/lib/sync.js +1686 -0
- package/lib/sync.js.map +1 -0
- package/lib/testing.d.ts +81 -0
- package/lib/testing.d.ts.map +1 -0
- package/lib/testing.js +162 -0
- package/lib/testing.js.map +1 -0
- package/lib/thread-utils.d.ts +10 -0
- package/lib/thread-utils.d.ts.map +1 -0
- package/lib/thread-utils.js +31 -0
- package/lib/thread-utils.js.map +1 -0
- package/lib/timeline-window.d.ts +168 -0
- package/lib/timeline-window.d.ts.map +1 -0
- package/lib/timeline-window.js +494 -0
- package/lib/timeline-window.js.map +1 -0
- package/lib/types.d.ts +33 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +33 -0
- package/lib/types.js.map +1 -0
- package/lib/utils/decryptAESSecretStorageItem.d.ts +12 -0
- package/lib/utils/decryptAESSecretStorageItem.d.ts.map +1 -0
- package/lib/utils/decryptAESSecretStorageItem.js +50 -0
- package/lib/utils/decryptAESSecretStorageItem.js.map +1 -0
- package/lib/utils/encryptAESSecretStorageItem.d.ts +16 -0
- package/lib/utils/encryptAESSecretStorageItem.d.ts.map +1 -0
- package/lib/utils/encryptAESSecretStorageItem.js +68 -0
- package/lib/utils/encryptAESSecretStorageItem.js.map +1 -0
- package/lib/utils/internal/deriveKeys.d.ts +10 -0
- package/lib/utils/internal/deriveKeys.d.ts.map +1 -0
- package/lib/utils/internal/deriveKeys.js +60 -0
- package/lib/utils/internal/deriveKeys.js.map +1 -0
- package/lib/utils.d.ts +267 -0
- package/lib/utils.d.ts.map +1 -0
- package/lib/utils.js +749 -0
- package/lib/utils.js.map +1 -0
- package/lib/version-support.d.ts +19 -0
- package/lib/version-support.d.ts.map +1 -0
- package/lib/version-support.js +37 -0
- package/lib/version-support.js.map +1 -0
- package/lib/webrtc/audioContext.d.ts +15 -0
- package/lib/webrtc/audioContext.d.ts.map +1 -0
- package/lib/webrtc/audioContext.js +46 -0
- package/lib/webrtc/audioContext.js.map +1 -0
- package/lib/webrtc/call.d.ts +560 -0
- package/lib/webrtc/call.d.ts.map +1 -0
- package/lib/webrtc/call.js +2541 -0
- package/lib/webrtc/call.js.map +1 -0
- package/lib/webrtc/callEventHandler.d.ts +37 -0
- package/lib/webrtc/callEventHandler.d.ts.map +1 -0
- package/lib/webrtc/callEventHandler.js +344 -0
- package/lib/webrtc/callEventHandler.js.map +1 -0
- package/lib/webrtc/callEventTypes.d.ts +73 -0
- package/lib/webrtc/callEventTypes.d.ts.map +1 -0
- package/lib/webrtc/callEventTypes.js +13 -0
- package/lib/webrtc/callEventTypes.js.map +1 -0
- package/lib/webrtc/callFeed.d.ts +128 -0
- package/lib/webrtc/callFeed.d.ts.map +1 -0
- package/lib/webrtc/callFeed.js +289 -0
- package/lib/webrtc/callFeed.js.map +1 -0
- package/lib/webrtc/groupCall.d.ts +323 -0
- package/lib/webrtc/groupCall.d.ts.map +1 -0
- package/lib/webrtc/groupCall.js +1337 -0
- package/lib/webrtc/groupCall.js.map +1 -0
- package/lib/webrtc/groupCallEventHandler.d.ts +31 -0
- package/lib/webrtc/groupCallEventHandler.d.ts.map +1 -0
- package/lib/webrtc/groupCallEventHandler.js +178 -0
- package/lib/webrtc/groupCallEventHandler.js.map +1 -0
- package/lib/webrtc/mediaHandler.d.ts +89 -0
- package/lib/webrtc/mediaHandler.d.ts.map +1 -0
- package/lib/webrtc/mediaHandler.js +437 -0
- package/lib/webrtc/mediaHandler.js.map +1 -0
- package/lib/webrtc/stats/callFeedStatsReporter.d.ts +8 -0
- package/lib/webrtc/stats/callFeedStatsReporter.d.ts.map +1 -0
- package/lib/webrtc/stats/callFeedStatsReporter.js +82 -0
- package/lib/webrtc/stats/callFeedStatsReporter.js.map +1 -0
- package/lib/webrtc/stats/callStatsReportGatherer.d.ts +25 -0
- package/lib/webrtc/stats/callStatsReportGatherer.d.ts.map +1 -0
- package/lib/webrtc/stats/callStatsReportGatherer.js +199 -0
- package/lib/webrtc/stats/callStatsReportGatherer.js.map +1 -0
- package/lib/webrtc/stats/callStatsReportSummary.d.ts +17 -0
- package/lib/webrtc/stats/callStatsReportSummary.d.ts.map +1 -0
- package/lib/webrtc/stats/callStatsReportSummary.js +1 -0
- package/lib/webrtc/stats/callStatsReportSummary.js.map +1 -0
- package/lib/webrtc/stats/connectionStats.d.ts +28 -0
- package/lib/webrtc/stats/connectionStats.d.ts.map +1 -0
- package/lib/webrtc/stats/connectionStats.js +26 -0
- package/lib/webrtc/stats/connectionStats.js.map +1 -0
- package/lib/webrtc/stats/connectionStatsBuilder.d.ts +5 -0
- package/lib/webrtc/stats/connectionStatsBuilder.d.ts.map +1 -0
- package/lib/webrtc/stats/connectionStatsBuilder.js +27 -0
- package/lib/webrtc/stats/connectionStatsBuilder.js.map +1 -0
- package/lib/webrtc/stats/connectionStatsReportBuilder.d.ts +7 -0
- package/lib/webrtc/stats/connectionStatsReportBuilder.d.ts.map +1 -0
- package/lib/webrtc/stats/connectionStatsReportBuilder.js +121 -0
- package/lib/webrtc/stats/connectionStatsReportBuilder.js.map +1 -0
- package/lib/webrtc/stats/groupCallStats.d.ts +22 -0
- package/lib/webrtc/stats/groupCallStats.d.ts.map +1 -0
- package/lib/webrtc/stats/groupCallStats.js +78 -0
- package/lib/webrtc/stats/groupCallStats.js.map +1 -0
- package/lib/webrtc/stats/media/mediaSsrcHandler.d.ts +10 -0
- package/lib/webrtc/stats/media/mediaSsrcHandler.d.ts.map +1 -0
- package/lib/webrtc/stats/media/mediaSsrcHandler.js +57 -0
- package/lib/webrtc/stats/media/mediaSsrcHandler.js.map +1 -0
- package/lib/webrtc/stats/media/mediaTrackHandler.d.ts +12 -0
- package/lib/webrtc/stats/media/mediaTrackHandler.d.ts.map +1 -0
- package/lib/webrtc/stats/media/mediaTrackHandler.js +62 -0
- package/lib/webrtc/stats/media/mediaTrackHandler.js.map +1 -0
- package/lib/webrtc/stats/media/mediaTrackStats.d.ts +86 -0
- package/lib/webrtc/stats/media/mediaTrackStats.d.ts.map +1 -0
- package/lib/webrtc/stats/media/mediaTrackStats.js +142 -0
- package/lib/webrtc/stats/media/mediaTrackStats.js.map +1 -0
- package/lib/webrtc/stats/media/mediaTrackStatsHandler.d.ts +22 -0
- package/lib/webrtc/stats/media/mediaTrackStatsHandler.d.ts.map +1 -0
- package/lib/webrtc/stats/media/mediaTrackStatsHandler.js +76 -0
- package/lib/webrtc/stats/media/mediaTrackStatsHandler.js.map +1 -0
- package/lib/webrtc/stats/statsReport.d.ts +99 -0
- package/lib/webrtc/stats/statsReport.d.ts.map +1 -0
- package/lib/webrtc/stats/statsReport.js +32 -0
- package/lib/webrtc/stats/statsReport.js.map +1 -0
- package/lib/webrtc/stats/statsReportEmitter.d.ts +15 -0
- package/lib/webrtc/stats/statsReportEmitter.d.ts.map +1 -0
- package/lib/webrtc/stats/statsReportEmitter.js +33 -0
- package/lib/webrtc/stats/statsReportEmitter.js.map +1 -0
- package/lib/webrtc/stats/summaryStatsReportGatherer.d.ts +16 -0
- package/lib/webrtc/stats/summaryStatsReportGatherer.d.ts.map +1 -0
- package/lib/webrtc/stats/summaryStatsReportGatherer.js +116 -0
- package/lib/webrtc/stats/summaryStatsReportGatherer.js.map +1 -0
- package/lib/webrtc/stats/trackStatsBuilder.d.ts +19 -0
- package/lib/webrtc/stats/trackStatsBuilder.d.ts.map +1 -0
- package/lib/webrtc/stats/trackStatsBuilder.js +168 -0
- package/lib/webrtc/stats/trackStatsBuilder.js.map +1 -0
- package/lib/webrtc/stats/transportStats.d.ts +11 -0
- package/lib/webrtc/stats/transportStats.d.ts.map +1 -0
- package/lib/webrtc/stats/transportStats.js +1 -0
- package/lib/webrtc/stats/transportStats.js.map +1 -0
- package/lib/webrtc/stats/transportStatsBuilder.d.ts +5 -0
- package/lib/webrtc/stats/transportStatsBuilder.d.ts.map +1 -0
- package/lib/webrtc/stats/transportStatsBuilder.js +34 -0
- package/lib/webrtc/stats/transportStatsBuilder.js.map +1 -0
- package/lib/webrtc/stats/valueFormatter.d.ts +4 -0
- package/lib/webrtc/stats/valueFormatter.d.ts.map +1 -0
- package/lib/webrtc/stats/valueFormatter.js +25 -0
- package/lib/webrtc/stats/valueFormatter.js.map +1 -0
- package/package.json +134 -0
- package/src/@types/AESEncryptedSecretStoragePayload.ts +29 -0
- package/src/@types/IIdentityServerProvider.ts +24 -0
- package/src/@types/PushRules.ts +209 -0
- package/src/@types/another-json.d.ts +19 -0
- package/src/@types/auth.ts +252 -0
- package/src/@types/beacon.ts +140 -0
- package/src/@types/common.ts +22 -0
- package/src/@types/crypto.ts +73 -0
- package/src/@types/event.ts +370 -0
- package/src/@types/events.ts +119 -0
- package/src/@types/extensible_events.ts +150 -0
- package/src/@types/global.d.ts +70 -0
- package/src/@types/local_notifications.ts +19 -0
- package/src/@types/location.ts +92 -0
- package/src/@types/matrix-sdk-crypto-wasm.d.ts +44 -0
- package/src/@types/media.ts +245 -0
- package/src/@types/membership.ts +57 -0
- package/src/@types/oidc-client-ts.d.ts +24 -0
- package/src/@types/partials.ts +67 -0
- package/src/@types/polls.ts +119 -0
- package/src/@types/read_receipts.ts +61 -0
- package/src/@types/registration.ts +102 -0
- package/src/@types/requests.ts +314 -0
- package/src/@types/search.ts +119 -0
- package/src/@types/signed.ts +25 -0
- package/src/@types/spaces.ts +37 -0
- package/src/@types/state_events.ts +147 -0
- package/src/@types/synapse.ts +40 -0
- package/src/@types/sync.ts +27 -0
- package/src/@types/threepids.ts +29 -0
- package/src/@types/topic.ts +63 -0
- package/src/@types/uia.ts +29 -0
- package/src/NamespacedValue.ts +123 -0
- package/src/ReEmitter.ts +93 -0
- package/src/ToDeviceMessageQueue.ts +153 -0
- package/src/autodiscovery.ts +505 -0
- package/src/base64.ts +88 -0
- package/src/browser-index.ts +44 -0
- package/src/client.ts +10474 -0
- package/src/common-crypto/CryptoBackend.ts +302 -0
- package/src/common-crypto/README.md +4 -0
- package/src/common-crypto/key-passphrase.ts +43 -0
- package/src/content-helpers.ts +288 -0
- package/src/content-repo.ts +117 -0
- package/src/crypto/CrossSigning.ts +773 -0
- package/src/crypto/DeviceList.ts +989 -0
- package/src/crypto/EncryptionSetup.ts +351 -0
- package/src/crypto/OlmDevice.ts +1500 -0
- package/src/crypto/OutgoingRoomKeyRequestManager.ts +485 -0
- package/src/crypto/RoomList.ts +70 -0
- package/src/crypto/SecretSharing.ts +240 -0
- package/src/crypto/SecretStorage.ts +136 -0
- package/src/crypto/aes.ts +23 -0
- package/src/crypto/algorithms/base.ts +236 -0
- package/src/crypto/algorithms/index.ts +20 -0
- package/src/crypto/algorithms/megolm.ts +2216 -0
- package/src/crypto/algorithms/olm.ts +381 -0
- package/src/crypto/api.ts +70 -0
- package/src/crypto/backup.ts +922 -0
- package/src/crypto/crypto.ts +18 -0
- package/src/crypto/dehydration.ts +272 -0
- package/src/crypto/device-converter.ts +45 -0
- package/src/crypto/deviceinfo.ts +158 -0
- package/src/crypto/index.ts +4414 -0
- package/src/crypto/key_passphrase.ts +42 -0
- package/src/crypto/keybackup.ts +47 -0
- package/src/crypto/olmlib.ts +539 -0
- package/src/crypto/recoverykey.ts +18 -0
- package/src/crypto/store/base.ts +348 -0
- package/src/crypto/store/indexeddb-crypto-store-backend.ts +1250 -0
- package/src/crypto/store/indexeddb-crypto-store.ts +845 -0
- package/src/crypto/store/localStorage-crypto-store.ts +579 -0
- package/src/crypto/store/memory-crypto-store.ts +680 -0
- package/src/crypto/verification/Base.ts +409 -0
- package/src/crypto/verification/Error.ts +76 -0
- package/src/crypto/verification/IllegalMethod.ts +50 -0
- package/src/crypto/verification/QRCode.ts +310 -0
- package/src/crypto/verification/SAS.ts +494 -0
- package/src/crypto/verification/SASDecimal.ts +37 -0
- package/src/crypto/verification/request/Channel.ts +34 -0
- package/src/crypto/verification/request/InRoomChannel.ts +371 -0
- package/src/crypto/verification/request/ToDeviceChannel.ts +354 -0
- package/src/crypto/verification/request/VerificationRequest.ts +976 -0
- package/src/crypto-api/CryptoEvent.ts +93 -0
- package/src/crypto-api/CryptoEventHandlerMap.ts +32 -0
- package/src/crypto-api/index.ts +1175 -0
- package/src/crypto-api/key-passphrase.ts +58 -0
- package/src/crypto-api/keybackup.ts +115 -0
- package/src/crypto-api/recovery-key.ts +69 -0
- package/src/crypto-api/verification.ts +408 -0
- package/src/digest.ts +34 -0
- package/src/embedded.ts +631 -0
- package/src/errors.ts +54 -0
- package/src/event-mapper.ts +97 -0
- package/src/extensible_events_v1/ExtensibleEvent.ts +58 -0
- package/src/extensible_events_v1/InvalidEventError.ts +24 -0
- package/src/extensible_events_v1/MessageEvent.ts +145 -0
- package/src/extensible_events_v1/PollEndEvent.ts +97 -0
- package/src/extensible_events_v1/PollResponseEvent.ts +148 -0
- package/src/extensible_events_v1/PollStartEvent.ts +207 -0
- package/src/extensible_events_v1/utilities.ts +35 -0
- package/src/feature.ts +87 -0
- package/src/filter-component.ts +207 -0
- package/src/filter.ts +245 -0
- package/src/http-api/errors.ts +199 -0
- package/src/http-api/fetch.ts +383 -0
- package/src/http-api/index.ts +191 -0
- package/src/http-api/interface.ts +178 -0
- package/src/http-api/method.ts +25 -0
- package/src/http-api/prefix.ts +48 -0
- package/src/http-api/utils.ts +200 -0
- package/src/index.ts +25 -0
- package/src/indexeddb-helpers.ts +50 -0
- package/src/indexeddb-worker.ts +24 -0
- package/src/interactive-auth.ts +694 -0
- package/src/logger.ts +185 -0
- package/src/matrix.ts +177 -0
- package/src/matrixrtc/CallMembership.ts +247 -0
- package/src/matrixrtc/LivekitFocus.ts +39 -0
- package/src/matrixrtc/MatrixRTCSession.ts +1319 -0
- package/src/matrixrtc/MatrixRTCSessionManager.ts +166 -0
- package/src/matrixrtc/focus.ts +25 -0
- package/src/matrixrtc/index.ts +22 -0
- package/src/matrixrtc/types.ts +36 -0
- package/src/models/MSC3089Branch.ts +272 -0
- package/src/models/MSC3089TreeSpace.ts +565 -0
- package/src/models/ToDeviceMessage.ts +38 -0
- package/src/models/beacon.ts +214 -0
- package/src/models/compare-event-ordering.ts +139 -0
- package/src/models/device.ts +85 -0
- package/src/models/event-context.ts +110 -0
- package/src/models/event-status.ts +39 -0
- package/src/models/event-timeline-set.ts +979 -0
- package/src/models/event-timeline.ts +476 -0
- package/src/models/event.ts +1751 -0
- package/src/models/invites-ignorer.ts +376 -0
- package/src/models/poll.ts +285 -0
- package/src/models/profile-keys.ts +7 -0
- package/src/models/read-receipt.ts +422 -0
- package/src/models/related-relations.ts +39 -0
- package/src/models/relations-container.ts +149 -0
- package/src/models/relations.ts +368 -0
- package/src/models/room-member.ts +457 -0
- package/src/models/room-receipts.ts +439 -0
- package/src/models/room-state.ts +1130 -0
- package/src/models/room-summary.ts +47 -0
- package/src/models/room.ts +3822 -0
- package/src/models/search-result.ts +57 -0
- package/src/models/thread.ts +923 -0
- package/src/models/typed-event-emitter.ts +246 -0
- package/src/models/user.ts +302 -0
- package/src/oidc/authorize.ts +274 -0
- package/src/oidc/discovery.ts +60 -0
- package/src/oidc/error.ts +33 -0
- package/src/oidc/index.ts +34 -0
- package/src/oidc/register.ts +123 -0
- package/src/oidc/tokenRefresher.ts +149 -0
- package/src/oidc/validate.ts +282 -0
- package/src/pushprocessor.ts +837 -0
- package/src/randomstring.ts +51 -0
- package/src/realtime-callbacks.ts +191 -0
- package/src/receipt-accumulator.ts +189 -0
- package/src/rendezvous/MSC4108SignInWithQR.ts +444 -0
- package/src/rendezvous/RendezvousChannel.ts +48 -0
- package/src/rendezvous/RendezvousCode.ts +25 -0
- package/src/rendezvous/RendezvousError.ts +26 -0
- package/src/rendezvous/RendezvousFailureReason.ts +49 -0
- package/src/rendezvous/RendezvousIntent.ts +20 -0
- package/src/rendezvous/RendezvousTransport.ts +58 -0
- package/src/rendezvous/channels/MSC4108SecureChannel.ts +270 -0
- package/src/rendezvous/channels/index.ts +17 -0
- package/src/rendezvous/index.ts +25 -0
- package/src/rendezvous/transports/MSC4108RendezvousSession.ts +270 -0
- package/src/rendezvous/transports/index.ts +17 -0
- package/src/room-hierarchy.ts +152 -0
- package/src/rust-crypto/CrossSigningIdentity.ts +183 -0
- package/src/rust-crypto/DehydratedDeviceManager.ts +306 -0
- package/src/rust-crypto/KeyClaimManager.ts +86 -0
- package/src/rust-crypto/OutgoingRequestProcessor.ts +236 -0
- package/src/rust-crypto/OutgoingRequestsManager.ts +143 -0
- package/src/rust-crypto/PerSessionKeyBackupDownloader.ts +501 -0
- package/src/rust-crypto/RoomEncryptor.ts +352 -0
- package/src/rust-crypto/backup.ts +881 -0
- package/src/rust-crypto/constants.ts +18 -0
- package/src/rust-crypto/device-converter.ts +128 -0
- package/src/rust-crypto/index.ts +237 -0
- package/src/rust-crypto/libolm_migration.ts +530 -0
- package/src/rust-crypto/rust-crypto.ts +2205 -0
- package/src/rust-crypto/secret-storage.ts +60 -0
- package/src/rust-crypto/verification.ts +830 -0
- package/src/scheduler.ts +309 -0
- package/src/secret-storage.ts +693 -0
- package/src/serverCapabilities.ts +139 -0
- package/src/service-types.ts +20 -0
- package/src/sliding-sync-sdk.ts +1026 -0
- package/src/sliding-sync.ts +965 -0
- package/src/store/index.ts +261 -0
- package/src/store/indexeddb-backend.ts +41 -0
- package/src/store/indexeddb-local-backend.ts +610 -0
- package/src/store/indexeddb-remote-backend.ts +213 -0
- package/src/store/indexeddb-store-worker.ts +157 -0
- package/src/store/indexeddb.ts +397 -0
- package/src/store/local-storage-events-emitter.ts +46 -0
- package/src/store/memory.ts +448 -0
- package/src/store/stub.ts +280 -0
- package/src/sync-accumulator.ts +689 -0
- package/src/sync.ts +1920 -0
- package/src/testing.ts +191 -0
- package/src/thread-utils.ts +31 -0
- package/src/timeline-window.ts +536 -0
- package/src/types.ts +59 -0
- package/src/utils/decryptAESSecretStorageItem.ts +54 -0
- package/src/utils/encryptAESSecretStorageItem.ts +73 -0
- package/src/utils/internal/deriveKeys.ts +63 -0
- package/src/utils.ts +763 -0
- package/src/version-support.ts +36 -0
- package/src/webrtc/audioContext.ts +44 -0
- package/src/webrtc/call.ts +3074 -0
- package/src/webrtc/callEventHandler.ts +425 -0
- package/src/webrtc/callEventTypes.ts +93 -0
- package/src/webrtc/callFeed.ts +364 -0
- package/src/webrtc/groupCall.ts +1735 -0
- package/src/webrtc/groupCallEventHandler.ts +234 -0
- package/src/webrtc/mediaHandler.ts +484 -0
- package/src/webrtc/stats/callFeedStatsReporter.ts +94 -0
- package/src/webrtc/stats/callStatsReportGatherer.ts +219 -0
- package/src/webrtc/stats/callStatsReportSummary.ts +30 -0
- package/src/webrtc/stats/connectionStats.ts +47 -0
- package/src/webrtc/stats/connectionStatsBuilder.ts +28 -0
- package/src/webrtc/stats/connectionStatsReportBuilder.ts +140 -0
- package/src/webrtc/stats/groupCallStats.ts +93 -0
- package/src/webrtc/stats/media/mediaSsrcHandler.ts +57 -0
- package/src/webrtc/stats/media/mediaTrackHandler.ts +76 -0
- package/src/webrtc/stats/media/mediaTrackStats.ts +176 -0
- package/src/webrtc/stats/media/mediaTrackStatsHandler.ts +90 -0
- package/src/webrtc/stats/statsReport.ts +133 -0
- package/src/webrtc/stats/statsReportEmitter.ts +49 -0
- package/src/webrtc/stats/summaryStatsReportGatherer.ts +148 -0
- package/src/webrtc/stats/trackStatsBuilder.ts +207 -0
- package/src/webrtc/stats/transportStats.ts +26 -0
- package/src/webrtc/stats/transportStatsBuilder.ts +48 -0
- package/src/webrtc/stats/valueFormatter.ts +27 -0
@@ -0,0 +1,3336 @@
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
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
|
+
/*
|
6
|
+
Copyright 2015 - 2023 The Matrix.org Foundation C.I.C.
|
7
|
+
|
8
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
+
you may not use this file except in compliance with the License.
|
10
|
+
You may obtain a copy of the License at
|
11
|
+
|
12
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
|
14
|
+
Unless required by applicable law or agreed to in writing, software
|
15
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
17
|
+
See the License for the specific language governing permissions and
|
18
|
+
limitations under the License.
|
19
|
+
*/
|
20
|
+
|
21
|
+
import { M_POLL_START } from "matrix-events-sdk";
|
22
|
+
import { EventTimelineSet, DuplicateStrategy } from "./event-timeline-set.js";
|
23
|
+
import { Direction, EventTimeline } from "./event-timeline.js";
|
24
|
+
import { getHttpUriForMxc } from "../content-repo.js";
|
25
|
+
import { removeElement } from "../utils.js";
|
26
|
+
import { normalize, noUnsafeEventProps } from "../utils.js";
|
27
|
+
import { MatrixEvent, MatrixEventEvent } from "./event.js";
|
28
|
+
import { EventStatus } from "./event-status.js";
|
29
|
+
import { RoomMember } from "./room-member.js";
|
30
|
+
import { RoomSummary } from "./room-summary.js";
|
31
|
+
import { logger } from "../logger.js";
|
32
|
+
import { TypedReEmitter } from "../ReEmitter.js";
|
33
|
+
import { EventType, RoomCreateTypeField, RoomType, UNSTABLE_ELEMENT_FUNCTIONAL_USERS, EVENT_VISIBILITY_CHANGE_TYPE, RelationType, UNSIGNED_THREAD_ID_FIELD } from "../@types/event.js";
|
34
|
+
import { PendingEventOrdering } from "../client.js";
|
35
|
+
import { Filter } from "../filter.js";
|
36
|
+
import { RoomStateEvent } from "./room-state.js";
|
37
|
+
import { BeaconEvent } from "./beacon.js";
|
38
|
+
import { Thread, ThreadEvent, FILTER_RELATED_BY_REL_TYPES, THREAD_RELATION_TYPE, FILTER_RELATED_BY_SENDERS, ThreadFilterType } from "./thread.js";
|
39
|
+
import { MAIN_ROOM_TIMELINE, ReceiptType } from "../@types/read_receipts.js";
|
40
|
+
import { RelationsContainer } from "./relations-container.js";
|
41
|
+
import { ReadReceipt, synthesizeReceipt } from "./read-receipt.js";
|
42
|
+
import { isPollEvent, Poll, PollEvent } from "./poll.js";
|
43
|
+
import { RoomReceipts } from "./room-receipts.js";
|
44
|
+
import { compareEventOrdering } from "./compare-event-ordering.js";
|
45
|
+
import * as utils from "../utils.js";
|
46
|
+
import { KnownMembership } from "../@types/membership.js";
|
47
|
+
import { RoomVersionStability } from "../serverCapabilities.js";
|
48
|
+
|
49
|
+
// These constants are used as sane defaults when the homeserver doesn't support
|
50
|
+
// the m.room_versions capability. In practice, KNOWN_SAFE_ROOM_VERSION should be
|
51
|
+
// the same as the common default room version whereas SAFE_ROOM_VERSIONS are the
|
52
|
+
// room versions which are considered okay for people to run without being asked
|
53
|
+
// to upgrade (ie: "stable"). Eventually, we should remove these when all homeservers
|
54
|
+
// return an m.room_versions capability.
|
55
|
+
export var KNOWN_SAFE_ROOM_VERSION = "10";
|
56
|
+
var SAFE_ROOM_VERSIONS = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"];
|
57
|
+
// When inserting a visibility event affecting event `eventId`, we
|
58
|
+
// need to scan through existing visibility events for `eventId`.
|
59
|
+
// In theory, this could take an unlimited amount of time if:
|
60
|
+
//
|
61
|
+
// - the visibility event was sent by a moderator; and
|
62
|
+
// - `eventId` already has many visibility changes (usually, it should
|
63
|
+
// be 2 or less); and
|
64
|
+
// - for some reason, the visibility changes are received out of order
|
65
|
+
// (usually, this shouldn't happen at all).
|
66
|
+
//
|
67
|
+
// For this reason, we limit the number of events to scan through,
|
68
|
+
// expecting that a broken visibility change for a single event in
|
69
|
+
// an extremely uncommon case (possibly a DoS) is a small
|
70
|
+
// price to pay to keep matrix-js-sdk responsive.
|
71
|
+
var MAX_NUMBER_OF_VISIBILITY_EVENTS_TO_SCAN_THROUGH = 30;
|
72
|
+
export var NotificationCountType = /*#__PURE__*/function (NotificationCountType) {
|
73
|
+
NotificationCountType["Highlight"] = "highlight";
|
74
|
+
NotificationCountType["Total"] = "total";
|
75
|
+
return NotificationCountType;
|
76
|
+
}({});
|
77
|
+
export var RoomEvent = /*#__PURE__*/function (RoomEvent) {
|
78
|
+
RoomEvent["MyMembership"] = "Room.myMembership";
|
79
|
+
RoomEvent["Tags"] = "Room.tags";
|
80
|
+
RoomEvent["AccountData"] = "Room.accountData";
|
81
|
+
RoomEvent["Receipt"] = "Room.receipt";
|
82
|
+
RoomEvent["Name"] = "Room.name";
|
83
|
+
RoomEvent["Redaction"] = "Room.redaction";
|
84
|
+
RoomEvent["RedactionCancelled"] = "Room.redactionCancelled";
|
85
|
+
RoomEvent["LocalEchoUpdated"] = "Room.localEchoUpdated";
|
86
|
+
RoomEvent["Timeline"] = "Room.timeline";
|
87
|
+
RoomEvent["TimelineReset"] = "Room.timelineReset";
|
88
|
+
RoomEvent["TimelineRefresh"] = "Room.TimelineRefresh";
|
89
|
+
RoomEvent["OldStateUpdated"] = "Room.OldStateUpdated";
|
90
|
+
RoomEvent["CurrentStateUpdated"] = "Room.CurrentStateUpdated";
|
91
|
+
RoomEvent["HistoryImportedWithinTimeline"] = "Room.historyImportedWithinTimeline";
|
92
|
+
RoomEvent["UnreadNotifications"] = "Room.UnreadNotifications";
|
93
|
+
RoomEvent["Summary"] = "Room.Summary";
|
94
|
+
return RoomEvent;
|
95
|
+
}({});
|
96
|
+
export class Room extends ReadReceipt {
|
97
|
+
/**
|
98
|
+
* Construct a new Room.
|
99
|
+
*
|
100
|
+
* <p>For a room, we store an ordered sequence of timelines, which may or may not
|
101
|
+
* be continuous. Each timeline lists a series of events, as well as tracking
|
102
|
+
* the room state at the start and the end of the timeline. It also tracks
|
103
|
+
* forward and backward pagination tokens, as well as containing links to the
|
104
|
+
* next timeline in the sequence.
|
105
|
+
*
|
106
|
+
* <p>There is one special timeline - the 'live' timeline, which represents the
|
107
|
+
* timeline to which events are being added in real-time as they are received
|
108
|
+
* from the /sync API. Note that you should not retain references to this
|
109
|
+
* timeline - even if it is the current timeline right now, it may not remain
|
110
|
+
* so if the server gives us a timeline gap in /sync.
|
111
|
+
*
|
112
|
+
* <p>In order that we can find events from their ids later, we also maintain a
|
113
|
+
* map from event_id to timeline and index.
|
114
|
+
*
|
115
|
+
* @param roomId - Required. The ID of this room.
|
116
|
+
* @param client - Required. The client, used to lazy load members.
|
117
|
+
* @param myUserId - Required. The ID of the syncing user.
|
118
|
+
* @param opts - Configuration options
|
119
|
+
*/
|
120
|
+
constructor(roomId, client, myUserId) {
|
121
|
+
var _this;
|
122
|
+
var opts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
123
|
+
// In some cases, we add listeners for every displayed Matrix event, so it's
|
124
|
+
// common to have quite a few more than the default limit.
|
125
|
+
super();
|
126
|
+
_this = this;
|
127
|
+
this.roomId = roomId;
|
128
|
+
this.client = client;
|
129
|
+
this.myUserId = myUserId;
|
130
|
+
this.opts = opts;
|
131
|
+
_defineProperty(this, "reEmitter", void 0);
|
132
|
+
_defineProperty(this, "txnToEvent", new Map());
|
133
|
+
// Pending in-flight requests { string: MatrixEvent }
|
134
|
+
_defineProperty(this, "notificationCounts", {});
|
135
|
+
_defineProperty(this, "threadNotifications", new Map());
|
136
|
+
_defineProperty(this, "cachedThreadReadReceipts", new Map());
|
137
|
+
// Useful to know at what point the current user has started using threads in this room
|
138
|
+
_defineProperty(this, "oldestThreadedReceiptTs", Infinity);
|
139
|
+
/**
|
140
|
+
* A record of the latest unthread receipts per user
|
141
|
+
* This is useful in determining whether a user has read a thread or not
|
142
|
+
*/
|
143
|
+
_defineProperty(this, "unthreadedReceipts", new Map());
|
144
|
+
_defineProperty(this, "timelineSets", void 0);
|
145
|
+
_defineProperty(this, "polls", new Map());
|
146
|
+
/**
|
147
|
+
* Empty array if the timeline sets have not been initialised. After initialisation:
|
148
|
+
* 0: All threads
|
149
|
+
* 1: Threads the current user has participated in
|
150
|
+
*/
|
151
|
+
_defineProperty(this, "threadsTimelineSets", []);
|
152
|
+
// any filtered timeline sets we're maintaining for this room
|
153
|
+
_defineProperty(this, "filteredTimelineSets", {});
|
154
|
+
// filter_id: timelineSet
|
155
|
+
_defineProperty(this, "timelineNeedsRefresh", false);
|
156
|
+
_defineProperty(this, "pendingEventList", void 0);
|
157
|
+
// read by megolm via getter; boolean value - null indicates "use global value"
|
158
|
+
_defineProperty(this, "blacklistUnverifiedDevices", void 0);
|
159
|
+
_defineProperty(this, "selfMembership", void 0);
|
160
|
+
_defineProperty(this, "summaryHeroes", null);
|
161
|
+
// flags to stop logspam about missing m.room.create events
|
162
|
+
_defineProperty(this, "getTypeWarning", false);
|
163
|
+
_defineProperty(this, "getVersionWarning", false);
|
164
|
+
_defineProperty(this, "membersPromise", void 0);
|
165
|
+
// XXX: These should be read-only
|
166
|
+
/**
|
167
|
+
* The human-readable display name for this room.
|
168
|
+
*/
|
169
|
+
_defineProperty(this, "name", void 0);
|
170
|
+
/**
|
171
|
+
* The un-homoglyphed name for this room.
|
172
|
+
*/
|
173
|
+
_defineProperty(this, "normalizedName", void 0);
|
174
|
+
/**
|
175
|
+
* Dict of room tags; the keys are the tag name and the values
|
176
|
+
* are any metadata associated with the tag - e.g. `{ "fav" : { order: 1 } }`
|
177
|
+
*/
|
178
|
+
_defineProperty(this, "tags", {});
|
179
|
+
// $tagName: { $metadata: $value }
|
180
|
+
/**
|
181
|
+
* accountData Dict of per-room account_data events; the keys are the
|
182
|
+
* event type and the values are the events.
|
183
|
+
*/
|
184
|
+
_defineProperty(this, "accountData", new Map());
|
185
|
+
// $eventType: $event
|
186
|
+
/**
|
187
|
+
* The room summary.
|
188
|
+
*/
|
189
|
+
_defineProperty(this, "summary", null);
|
190
|
+
/**
|
191
|
+
* oldState The state of the room at the time of the oldest event in the live timeline.
|
192
|
+
*
|
193
|
+
* @deprecated Present for backwards compatibility.
|
194
|
+
* Use getLiveTimeline().getState(EventTimeline.BACKWARDS) instead
|
195
|
+
*/
|
196
|
+
_defineProperty(this, "oldState", void 0);
|
197
|
+
/**
|
198
|
+
* currentState The state of the room at the time of the newest event in the timeline.
|
199
|
+
*
|
200
|
+
* @deprecated Present for backwards compatibility.
|
201
|
+
* Use getLiveTimeline().getState(EventTimeline.FORWARDS) instead.
|
202
|
+
*/
|
203
|
+
_defineProperty(this, "currentState", void 0);
|
204
|
+
_defineProperty(this, "relations", void 0);
|
205
|
+
/**
|
206
|
+
* A collection of events known by the client
|
207
|
+
* This is not a comprehensive list of the threads that exist in this room
|
208
|
+
*/
|
209
|
+
_defineProperty(this, "threads", new Map());
|
210
|
+
/**
|
211
|
+
* A mapping of eventId to all visibility changes to apply
|
212
|
+
* to the event, by chronological order, as per
|
213
|
+
* https://github.com/matrix-org/matrix-doc/pull/3531
|
214
|
+
*
|
215
|
+
* # Invariants
|
216
|
+
*
|
217
|
+
* - within each list, all events are classed by
|
218
|
+
* chronological order;
|
219
|
+
* - all events are events such that
|
220
|
+
* `asVisibilityEvent()` returns a non-null `IVisibilityChange`;
|
221
|
+
* - within each list with key `eventId`, all events
|
222
|
+
* are in relation to `eventId`.
|
223
|
+
*
|
224
|
+
* @experimental
|
225
|
+
*/
|
226
|
+
_defineProperty(this, "visibilityEvents", new Map());
|
227
|
+
/**
|
228
|
+
* The latest receipts (synthetic and real) for each user in each thread
|
229
|
+
* (and unthreaded).
|
230
|
+
*/
|
231
|
+
_defineProperty(this, "roomReceipts", new RoomReceipts(this));
|
232
|
+
_defineProperty(this, "threadTimelineSetsPromise", null);
|
233
|
+
_defineProperty(this, "threadsReady", false);
|
234
|
+
_defineProperty(this, "updateThreadRootEvents", (thread, toStartOfTimeline, recreateEvent) => {
|
235
|
+
if (thread.length) {
|
236
|
+
var _this$threadsTimeline;
|
237
|
+
this.updateThreadRootEvent((_this$threadsTimeline = this.threadsTimelineSets) === null || _this$threadsTimeline === void 0 ? void 0 : _this$threadsTimeline[0], thread, toStartOfTimeline, recreateEvent);
|
238
|
+
if (thread.hasCurrentUserParticipated) {
|
239
|
+
var _this$threadsTimeline2;
|
240
|
+
this.updateThreadRootEvent((_this$threadsTimeline2 = this.threadsTimelineSets) === null || _this$threadsTimeline2 === void 0 ? void 0 : _this$threadsTimeline2[1], thread, toStartOfTimeline, recreateEvent);
|
241
|
+
}
|
242
|
+
}
|
243
|
+
});
|
244
|
+
_defineProperty(this, "updateThreadRootEvent", (timelineSet, thread, toStartOfTimeline, recreateEvent) => {
|
245
|
+
if (timelineSet && thread.rootEvent) {
|
246
|
+
if (recreateEvent) {
|
247
|
+
timelineSet.removeEvent(thread.id);
|
248
|
+
}
|
249
|
+
if (Thread.hasServerSideSupport) {
|
250
|
+
timelineSet.addLiveEvent(thread.rootEvent, {
|
251
|
+
duplicateStrategy: DuplicateStrategy.Replace,
|
252
|
+
fromCache: false,
|
253
|
+
roomState: this.currentState
|
254
|
+
});
|
255
|
+
} else {
|
256
|
+
timelineSet.addEventToTimeline(thread.rootEvent, timelineSet.getLiveTimeline(), {
|
257
|
+
toStartOfTimeline
|
258
|
+
});
|
259
|
+
}
|
260
|
+
}
|
261
|
+
});
|
262
|
+
_defineProperty(this, "applyRedaction", event => {
|
263
|
+
if (event.isRedaction()) {
|
264
|
+
var redactId = event.event.redacts;
|
265
|
+
|
266
|
+
// if we know about this event, redact its contents now.
|
267
|
+
var redactedEvent = redactId ? this.findEventById(redactId) : undefined;
|
268
|
+
if (redactedEvent) {
|
269
|
+
var threadRootId = redactedEvent.threadRootId;
|
270
|
+
redactedEvent.makeRedacted(event, this);
|
271
|
+
|
272
|
+
// If this is in the current state, replace it with the redacted version
|
273
|
+
if (redactedEvent.isState()) {
|
274
|
+
var currentStateEvent = this.currentState.getStateEvents(redactedEvent.getType(), redactedEvent.getStateKey());
|
275
|
+
if ((currentStateEvent === null || currentStateEvent === void 0 ? void 0 : currentStateEvent.getId()) === redactedEvent.getId()) {
|
276
|
+
this.currentState.setStateEvents([redactedEvent]);
|
277
|
+
}
|
278
|
+
}
|
279
|
+
this.emit(RoomEvent.Redaction, event, this, threadRootId);
|
280
|
+
|
281
|
+
// TODO: we stash user displaynames (among other things) in
|
282
|
+
// RoomMember objects which are then attached to other events
|
283
|
+
// (in the sender and target fields). We should get those
|
284
|
+
// RoomMember objects to update themselves when the events that
|
285
|
+
// they are based on are changed.
|
286
|
+
|
287
|
+
// Remove any visibility change on this event.
|
288
|
+
this.visibilityEvents.delete(redactId);
|
289
|
+
|
290
|
+
// If this event is a visibility change event, remove it from the
|
291
|
+
// list of visibility changes and update any event affected by it.
|
292
|
+
if (redactedEvent.isVisibilityEvent()) {
|
293
|
+
this.redactVisibilityChangeEvent(event);
|
294
|
+
}
|
295
|
+
}
|
296
|
+
|
297
|
+
// FIXME: apply redactions to notification list
|
298
|
+
|
299
|
+
// NB: We continue to add the redaction event to the timeline so
|
300
|
+
// clients can say "so and so redacted an event" if they wish to. Also
|
301
|
+
// this may be needed to trigger an update.
|
302
|
+
}
|
303
|
+
});
|
304
|
+
this.setMaxListeners(100);
|
305
|
+
this.reEmitter = new TypedReEmitter(this);
|
306
|
+
opts.pendingEventOrdering = opts.pendingEventOrdering || PendingEventOrdering.Chronological;
|
307
|
+
this.name = roomId;
|
308
|
+
this.normalizedName = roomId;
|
309
|
+
this.relations = new RelationsContainer(this.client, this);
|
310
|
+
|
311
|
+
// Listen to our own receipt event as a more modular way of processing our own
|
312
|
+
// receipts. No need to remove the listener: it's on ourself anyway.
|
313
|
+
this.on(RoomEvent.Receipt, this.onReceipt);
|
314
|
+
|
315
|
+
// all our per-room timeline sets. the first one is the unfiltered ones;
|
316
|
+
// the subsequent ones are the filtered ones in no particular order.
|
317
|
+
this.timelineSets = [new EventTimelineSet(this, opts)];
|
318
|
+
this.reEmitter.reEmit(this.getUnfilteredTimelineSet(), [RoomEvent.Timeline, RoomEvent.TimelineReset]);
|
319
|
+
this.fixUpLegacyTimelineFields();
|
320
|
+
if (this.opts.pendingEventOrdering === PendingEventOrdering.Detached) {
|
321
|
+
this.pendingEventList = [];
|
322
|
+
this.client.store.getPendingEvents(this.roomId).then(events => {
|
323
|
+
var mapper = this.client.getEventMapper({
|
324
|
+
toDevice: false,
|
325
|
+
decrypt: false
|
326
|
+
});
|
327
|
+
events.forEach(/*#__PURE__*/function () {
|
328
|
+
var _ref = _asyncToGenerator(function* (serializedEvent) {
|
329
|
+
var event = mapper(serializedEvent);
|
330
|
+
yield client.decryptEventIfNeeded(event);
|
331
|
+
event.setStatus(EventStatus.NOT_SENT);
|
332
|
+
_this.addPendingEvent(event, event.getTxnId());
|
333
|
+
});
|
334
|
+
return function (_x) {
|
335
|
+
return _ref.apply(this, arguments);
|
336
|
+
};
|
337
|
+
}());
|
338
|
+
});
|
339
|
+
}
|
340
|
+
|
341
|
+
// awaited by getEncryptionTargetMembers while room members are loading
|
342
|
+
if (!this.opts.lazyLoadMembers) {
|
343
|
+
this.membersPromise = Promise.resolve(false);
|
344
|
+
} else {
|
345
|
+
this.membersPromise = undefined;
|
346
|
+
}
|
347
|
+
}
|
348
|
+
createThreadsTimelineSets() {
|
349
|
+
var _this2 = this;
|
350
|
+
return _asyncToGenerator(function* () {
|
351
|
+
var _this2$client;
|
352
|
+
if (_this2.threadTimelineSetsPromise) {
|
353
|
+
return _this2.threadTimelineSetsPromise;
|
354
|
+
}
|
355
|
+
if ((_this2$client = _this2.client) !== null && _this2$client !== void 0 && _this2$client.supportsThreads()) {
|
356
|
+
try {
|
357
|
+
_this2.threadTimelineSetsPromise = Promise.all([_this2.createThreadTimelineSet(), _this2.createThreadTimelineSet(ThreadFilterType.My)]);
|
358
|
+
var timelineSets = yield _this2.threadTimelineSetsPromise;
|
359
|
+
_this2.threadsTimelineSets[0] = timelineSets[0];
|
360
|
+
_this2.threadsTimelineSets[1] = timelineSets[1];
|
361
|
+
return timelineSets;
|
362
|
+
} catch (_unused) {
|
363
|
+
_this2.threadTimelineSetsPromise = null;
|
364
|
+
return null;
|
365
|
+
}
|
366
|
+
}
|
367
|
+
return null;
|
368
|
+
})();
|
369
|
+
}
|
370
|
+
|
371
|
+
/**
|
372
|
+
* Bulk decrypt critical events in a room
|
373
|
+
*
|
374
|
+
* Critical events represents the minimal set of events to decrypt
|
375
|
+
* for a typical UI to function properly
|
376
|
+
*
|
377
|
+
* - Last event of every room (to generate likely message preview)
|
378
|
+
* - All events up to the read receipt (to calculate an accurate notification count)
|
379
|
+
*
|
380
|
+
* @returns Signals when all events have been decrypted
|
381
|
+
*/
|
382
|
+
decryptCriticalEvents() {
|
383
|
+
var _this3 = this;
|
384
|
+
return _asyncToGenerator(function* () {
|
385
|
+
if (!_this3.client.isCryptoEnabled()) return;
|
386
|
+
var readReceiptEventId = _this3.getEventReadUpTo(_this3.client.getUserId(), true);
|
387
|
+
var events = _this3.getLiveTimeline().getEvents();
|
388
|
+
var readReceiptTimelineIndex = events.findIndex(matrixEvent => {
|
389
|
+
return matrixEvent.event.event_id === readReceiptEventId;
|
390
|
+
});
|
391
|
+
var decryptionPromises = events.slice(readReceiptTimelineIndex).reverse().map(event => _this3.client.decryptEventIfNeeded(event));
|
392
|
+
yield Promise.allSettled(decryptionPromises);
|
393
|
+
})();
|
394
|
+
}
|
395
|
+
|
396
|
+
/**
|
397
|
+
* Bulk decrypt events in a room
|
398
|
+
*
|
399
|
+
* @returns Signals when all events have been decrypted
|
400
|
+
*/
|
401
|
+
decryptAllEvents() {
|
402
|
+
var _this4 = this;
|
403
|
+
return _asyncToGenerator(function* () {
|
404
|
+
if (!_this4.client.isCryptoEnabled()) return;
|
405
|
+
var decryptionPromises = _this4.getUnfilteredTimelineSet().getLiveTimeline().getEvents().slice(0) // copy before reversing
|
406
|
+
.reverse().map(event => _this4.client.decryptEventIfNeeded(event));
|
407
|
+
yield Promise.allSettled(decryptionPromises);
|
408
|
+
})();
|
409
|
+
}
|
410
|
+
|
411
|
+
/**
|
412
|
+
* Gets the creator of the room
|
413
|
+
* @returns The creator of the room, or null if it could not be determined
|
414
|
+
*/
|
415
|
+
getCreator() {
|
416
|
+
var _createEvent$getSende;
|
417
|
+
var createEvent = this.currentState.getStateEvents(EventType.RoomCreate, "");
|
418
|
+
return (_createEvent$getSende = createEvent === null || createEvent === void 0 ? void 0 : createEvent.getSender()) !== null && _createEvent$getSende !== void 0 ? _createEvent$getSende : null;
|
419
|
+
}
|
420
|
+
|
421
|
+
/**
|
422
|
+
* Gets the version of the room
|
423
|
+
* @returns The version of the room, or null if it could not be determined
|
424
|
+
*/
|
425
|
+
getVersion() {
|
426
|
+
var _createEvent$getConte;
|
427
|
+
var createEvent = this.currentState.getStateEvents(EventType.RoomCreate, "");
|
428
|
+
if (!createEvent) {
|
429
|
+
if (!this.getVersionWarning) {
|
430
|
+
logger.warn("[getVersion] Room " + this.roomId + " does not have an m.room.create event");
|
431
|
+
this.getVersionWarning = true;
|
432
|
+
}
|
433
|
+
return "1";
|
434
|
+
}
|
435
|
+
return (_createEvent$getConte = createEvent.getContent()["room_version"]) !== null && _createEvent$getConte !== void 0 ? _createEvent$getConte : "1";
|
436
|
+
}
|
437
|
+
|
438
|
+
/**
|
439
|
+
* Determines the recommended room version for the room. This returns an
|
440
|
+
* object with 3 properties: `version` as the new version the
|
441
|
+
* room should be upgraded to (may be the same as the current version);
|
442
|
+
* `needsUpgrade` to indicate if the room actually can be
|
443
|
+
* upgraded (ie: does the current version not match?); and `urgent`
|
444
|
+
* to indicate if the new version patches a vulnerability in a previous
|
445
|
+
* version.
|
446
|
+
* @returns
|
447
|
+
* Resolves to the version the room should be upgraded to.
|
448
|
+
*/
|
449
|
+
getRecommendedVersion() {
|
450
|
+
var _this5 = this;
|
451
|
+
return _asyncToGenerator(function* () {
|
452
|
+
var capabilities = {};
|
453
|
+
try {
|
454
|
+
capabilities = yield _this5.client.getCapabilities();
|
455
|
+
} catch (_unused2) {}
|
456
|
+
var versionCap = capabilities["m.room_versions"];
|
457
|
+
if (!versionCap) {
|
458
|
+
versionCap = {
|
459
|
+
default: KNOWN_SAFE_ROOM_VERSION,
|
460
|
+
available: {}
|
461
|
+
};
|
462
|
+
for (var safeVer of SAFE_ROOM_VERSIONS) {
|
463
|
+
versionCap.available[safeVer] = RoomVersionStability.Stable;
|
464
|
+
}
|
465
|
+
}
|
466
|
+
var result = _this5.checkVersionAgainstCapability(versionCap);
|
467
|
+
if (result.urgent && result.needsUpgrade) {
|
468
|
+
// Something doesn't feel right: we shouldn't need to update
|
469
|
+
// because the version we're on should be in the protocol's
|
470
|
+
// namespace. This usually means that the server was updated
|
471
|
+
// before the client was, making us think the newest possible
|
472
|
+
// room version is not stable. As a solution, we'll refresh
|
473
|
+
// the capability we're using to determine this.
|
474
|
+
logger.warn("Refreshing room version capability because the server looks " + "to be supporting a newer room version we don't know about.");
|
475
|
+
try {
|
476
|
+
capabilities = yield _this5.client.fetchCapabilities();
|
477
|
+
} catch (e) {
|
478
|
+
logger.warn("Failed to refresh room version capabilities", e);
|
479
|
+
}
|
480
|
+
versionCap = capabilities["m.room_versions"];
|
481
|
+
if (!versionCap) {
|
482
|
+
logger.warn("No room version capability - assuming upgrade required.");
|
483
|
+
return result;
|
484
|
+
} else {
|
485
|
+
result = _this5.checkVersionAgainstCapability(versionCap);
|
486
|
+
}
|
487
|
+
}
|
488
|
+
return result;
|
489
|
+
})();
|
490
|
+
}
|
491
|
+
checkVersionAgainstCapability(versionCap) {
|
492
|
+
var currentVersion = this.getVersion();
|
493
|
+
logger.log("[".concat(this.roomId, "] Current version: ").concat(currentVersion));
|
494
|
+
logger.log("[".concat(this.roomId, "] Version capability: "), versionCap);
|
495
|
+
var result = {
|
496
|
+
version: currentVersion,
|
497
|
+
needsUpgrade: false,
|
498
|
+
urgent: false
|
499
|
+
};
|
500
|
+
|
501
|
+
// If the room is on the default version then nothing needs to change
|
502
|
+
if (currentVersion === versionCap.default) return result;
|
503
|
+
var stableVersions = Object.keys(versionCap.available).filter(v => versionCap.available[v] === "stable");
|
504
|
+
|
505
|
+
// Check if the room is on an unstable version. We determine urgency based
|
506
|
+
// off the version being in the Matrix spec namespace or not (if the version
|
507
|
+
// is in the current namespace and unstable, the room is probably vulnerable).
|
508
|
+
if (!stableVersions.includes(currentVersion)) {
|
509
|
+
result.version = versionCap.default;
|
510
|
+
result.needsUpgrade = true;
|
511
|
+
result.urgent = !!this.getVersion().match(/^[0-9]+[0-9.]*$/g);
|
512
|
+
if (result.urgent) {
|
513
|
+
logger.warn("URGENT upgrade required on ".concat(this.roomId));
|
514
|
+
} else {
|
515
|
+
logger.warn("Non-urgent upgrade required on ".concat(this.roomId));
|
516
|
+
}
|
517
|
+
return result;
|
518
|
+
}
|
519
|
+
|
520
|
+
// The room is on a stable, but non-default, version by this point.
|
521
|
+
// No upgrade needed.
|
522
|
+
return result;
|
523
|
+
}
|
524
|
+
|
525
|
+
/**
|
526
|
+
* Determines whether the given user is permitted to perform a room upgrade
|
527
|
+
* @param userId - The ID of the user to test against
|
528
|
+
* @returns True if the given user is permitted to upgrade the room
|
529
|
+
*/
|
530
|
+
userMayUpgradeRoom(userId) {
|
531
|
+
return this.currentState.maySendStateEvent(EventType.RoomTombstone, userId);
|
532
|
+
}
|
533
|
+
|
534
|
+
/**
|
535
|
+
* Get the list of pending sent events for this room
|
536
|
+
*
|
537
|
+
* @returns A list of the sent events
|
538
|
+
* waiting for remote echo.
|
539
|
+
*
|
540
|
+
* @throws If `opts.pendingEventOrdering` was not 'detached'
|
541
|
+
*/
|
542
|
+
getPendingEvents() {
|
543
|
+
if (!this.pendingEventList) {
|
544
|
+
throw new Error("Cannot call getPendingEvents with pendingEventOrdering == " + this.opts.pendingEventOrdering);
|
545
|
+
}
|
546
|
+
return this.pendingEventList;
|
547
|
+
}
|
548
|
+
|
549
|
+
/**
|
550
|
+
* Removes a pending event for this room
|
551
|
+
*
|
552
|
+
* @returns True if an element was removed.
|
553
|
+
*/
|
554
|
+
removePendingEvent(eventId) {
|
555
|
+
if (!this.pendingEventList) {
|
556
|
+
throw new Error("Cannot call removePendingEvent with pendingEventOrdering == " + this.opts.pendingEventOrdering);
|
557
|
+
}
|
558
|
+
var removed = removeElement(this.pendingEventList, function (ev) {
|
559
|
+
return ev.getId() == eventId;
|
560
|
+
}, false);
|
561
|
+
this.savePendingEvents();
|
562
|
+
return removed;
|
563
|
+
}
|
564
|
+
|
565
|
+
/**
|
566
|
+
* Check whether the pending event list contains a given event by ID.
|
567
|
+
* If pending event ordering is not "detached" then this returns false.
|
568
|
+
*
|
569
|
+
* @param eventId - The event ID to check for.
|
570
|
+
*/
|
571
|
+
hasPendingEvent(eventId) {
|
572
|
+
var _this$pendingEventLis, _this$pendingEventLis2;
|
573
|
+
return (_this$pendingEventLis = (_this$pendingEventLis2 = this.pendingEventList) === null || _this$pendingEventLis2 === void 0 ? void 0 : _this$pendingEventLis2.some(event => event.getId() === eventId)) !== null && _this$pendingEventLis !== void 0 ? _this$pendingEventLis : false;
|
574
|
+
}
|
575
|
+
|
576
|
+
/**
|
577
|
+
* Get a specific event from the pending event list, if configured, null otherwise.
|
578
|
+
*
|
579
|
+
* @param eventId - The event ID to check for.
|
580
|
+
*/
|
581
|
+
getPendingEvent(eventId) {
|
582
|
+
var _this$pendingEventLis3, _this$pendingEventLis4;
|
583
|
+
return (_this$pendingEventLis3 = (_this$pendingEventLis4 = this.pendingEventList) === null || _this$pendingEventLis4 === void 0 ? void 0 : _this$pendingEventLis4.find(event => event.getId() === eventId)) !== null && _this$pendingEventLis3 !== void 0 ? _this$pendingEventLis3 : null;
|
584
|
+
}
|
585
|
+
|
586
|
+
/**
|
587
|
+
* Get the live unfiltered timeline for this room.
|
588
|
+
*
|
589
|
+
* @returns live timeline
|
590
|
+
*/
|
591
|
+
getLiveTimeline() {
|
592
|
+
return this.getUnfilteredTimelineSet().getLiveTimeline();
|
593
|
+
}
|
594
|
+
|
595
|
+
/**
|
596
|
+
* The live event timeline for this room, with the oldest event at index 0.
|
597
|
+
*
|
598
|
+
* @deprecated Present for backwards compatibility.
|
599
|
+
* Use getLiveTimeline().getEvents() instead
|
600
|
+
*/
|
601
|
+
get timeline() {
|
602
|
+
return this.getLiveTimeline().getEvents();
|
603
|
+
}
|
604
|
+
|
605
|
+
/**
|
606
|
+
* Get the timestamp of the last message in the room
|
607
|
+
*
|
608
|
+
* @returns the timestamp of the last message in the room
|
609
|
+
*/
|
610
|
+
getLastActiveTimestamp() {
|
611
|
+
var timeline = this.getLiveTimeline();
|
612
|
+
var events = timeline.getEvents();
|
613
|
+
if (events.length) {
|
614
|
+
var lastEvent = events[events.length - 1];
|
615
|
+
return lastEvent.getTs();
|
616
|
+
} else {
|
617
|
+
return Number.MIN_SAFE_INTEGER;
|
618
|
+
}
|
619
|
+
}
|
620
|
+
|
621
|
+
/**
|
622
|
+
* Returns the last live event of this room.
|
623
|
+
* "last" means latest timestamp.
|
624
|
+
* Instead of using timestamps, it would be better to do the comparison based on the order of the homeserver DAG.
|
625
|
+
* Unfortunately, this information is currently not available in the client.
|
626
|
+
* See {@link https://github.com/matrix-org/matrix-js-sdk/issues/3325}.
|
627
|
+
* "live of this room" means from all live timelines: the room and the threads.
|
628
|
+
*
|
629
|
+
* @returns MatrixEvent if there is a last event; else undefined.
|
630
|
+
*/
|
631
|
+
getLastLiveEvent() {
|
632
|
+
var _lastRoomEvent$getTs, _lastThreadEvent$getT;
|
633
|
+
var roomEvents = this.getLiveTimeline().getEvents();
|
634
|
+
var lastRoomEvent = roomEvents[roomEvents.length - 1];
|
635
|
+
var lastThread = this.getLastThread();
|
636
|
+
if (!lastThread) return lastRoomEvent;
|
637
|
+
var lastThreadEvent = lastThread.events[lastThread.events.length - 1];
|
638
|
+
return ((_lastRoomEvent$getTs = lastRoomEvent === null || lastRoomEvent === void 0 ? void 0 : lastRoomEvent.getTs()) !== null && _lastRoomEvent$getTs !== void 0 ? _lastRoomEvent$getTs : 0) > ((_lastThreadEvent$getT = lastThreadEvent === null || lastThreadEvent === void 0 ? void 0 : lastThreadEvent.getTs()) !== null && _lastThreadEvent$getT !== void 0 ? _lastThreadEvent$getT : 0) ? lastRoomEvent : lastThreadEvent;
|
639
|
+
}
|
640
|
+
|
641
|
+
/**
|
642
|
+
* Returns the last thread of this room.
|
643
|
+
* "last" means latest timestamp of the last thread event.
|
644
|
+
* Instead of using timestamps, it would be better to do the comparison based on the order of the homeserver DAG.
|
645
|
+
* Unfortunately, this information is currently not available in the client.
|
646
|
+
* See {@link https://github.com/matrix-org/matrix-js-sdk/issues/3325}.
|
647
|
+
*
|
648
|
+
* @returns the thread with the most recent event in its live time line. undefined if there is no thread.
|
649
|
+
*/
|
650
|
+
getLastThread() {
|
651
|
+
return this.getThreads().reduce((lastThread, thread) => {
|
652
|
+
var _threadEvent$getTs, _lastThreadEvent$getT2;
|
653
|
+
if (!lastThread) return thread;
|
654
|
+
var threadEvent = thread.events[thread.events.length - 1];
|
655
|
+
var lastThreadEvent = lastThread.events[lastThread.events.length - 1];
|
656
|
+
if (((_threadEvent$getTs = threadEvent === null || threadEvent === void 0 ? void 0 : threadEvent.getTs()) !== null && _threadEvent$getTs !== void 0 ? _threadEvent$getTs : 0) >= ((_lastThreadEvent$getT2 = lastThreadEvent === null || lastThreadEvent === void 0 ? void 0 : lastThreadEvent.getTs()) !== null && _lastThreadEvent$getT2 !== void 0 ? _lastThreadEvent$getT2 : 0)) {
|
657
|
+
// Last message of current thread is newer → new last thread.
|
658
|
+
// Equal also means newer, because it was added to the thread map later.
|
659
|
+
return thread;
|
660
|
+
}
|
661
|
+
return lastThread;
|
662
|
+
}, undefined);
|
663
|
+
}
|
664
|
+
|
665
|
+
/**
|
666
|
+
* @returns the membership type (join | leave | invite | knock) for the logged in user
|
667
|
+
*/
|
668
|
+
getMyMembership() {
|
669
|
+
var _this$selfMembership;
|
670
|
+
return (_this$selfMembership = this.selfMembership) !== null && _this$selfMembership !== void 0 ? _this$selfMembership : KnownMembership.Leave;
|
671
|
+
}
|
672
|
+
|
673
|
+
/**
|
674
|
+
* If this room is a DM we're invited to,
|
675
|
+
* try to find out who invited us
|
676
|
+
* @returns user id of the inviter
|
677
|
+
*/
|
678
|
+
getDMInviter() {
|
679
|
+
var me = this.getMember(this.myUserId);
|
680
|
+
if (me) {
|
681
|
+
return me.getDMInviter();
|
682
|
+
}
|
683
|
+
if (this.selfMembership === KnownMembership.Invite) {
|
684
|
+
// fall back to summary information
|
685
|
+
var memberCount = this.getInvitedAndJoinedMemberCount();
|
686
|
+
if (memberCount === 2) {
|
687
|
+
var _this$summaryHeroes;
|
688
|
+
return (_this$summaryHeroes = this.summaryHeroes) === null || _this$summaryHeroes === void 0 ? void 0 : _this$summaryHeroes[0];
|
689
|
+
}
|
690
|
+
}
|
691
|
+
}
|
692
|
+
|
693
|
+
/**
|
694
|
+
* Assuming this room is a DM room, tries to guess with which user.
|
695
|
+
* @returns user id of the other member (could be syncing user)
|
696
|
+
*/
|
697
|
+
guessDMUserId() {
|
698
|
+
var me = this.getMember(this.myUserId);
|
699
|
+
if (me) {
|
700
|
+
var inviterId = me.getDMInviter();
|
701
|
+
if (inviterId) {
|
702
|
+
return inviterId;
|
703
|
+
}
|
704
|
+
}
|
705
|
+
// Remember, we're assuming this room is a DM, so returning the first member we find should be fine
|
706
|
+
if (Array.isArray(this.summaryHeroes) && this.summaryHeroes.length) {
|
707
|
+
return this.summaryHeroes[0];
|
708
|
+
}
|
709
|
+
var members = this.currentState.getMembers();
|
710
|
+
var anyMember = members.find(m => m.userId !== this.myUserId);
|
711
|
+
if (anyMember) {
|
712
|
+
return anyMember.userId;
|
713
|
+
}
|
714
|
+
// it really seems like I'm the only user in the room
|
715
|
+
// so I probably created a room with just me in it
|
716
|
+
// and marked it as a DM. Ok then
|
717
|
+
return this.myUserId;
|
718
|
+
}
|
719
|
+
|
720
|
+
/**
|
721
|
+
* Gets the "functional members" in this room.
|
722
|
+
*
|
723
|
+
* Returns the list of userIDs from the `io.element.functional_members` event. Does not consider the
|
724
|
+
* current membership states of those users.
|
725
|
+
*
|
726
|
+
* @see https://github.com/element-hq/element-meta/blob/develop/spec/functional_members.md.
|
727
|
+
*/
|
728
|
+
getFunctionalMembers() {
|
729
|
+
var mFunctionalMembers = this.currentState.getStateEvents(UNSTABLE_ELEMENT_FUNCTIONAL_USERS.name, "");
|
730
|
+
if (Array.isArray(mFunctionalMembers === null || mFunctionalMembers === void 0 ? void 0 : mFunctionalMembers.getContent().service_members)) {
|
731
|
+
return mFunctionalMembers.getContent().service_members;
|
732
|
+
}
|
733
|
+
return [];
|
734
|
+
}
|
735
|
+
getAvatarFallbackMember() {
|
736
|
+
var _this$summaryHeroes2;
|
737
|
+
var functionalMembers = this.getFunctionalMembers();
|
738
|
+
|
739
|
+
// Only generate a fallback avatar if the conversation is with a single specific other user (a "DM").
|
740
|
+
var nonFunctionalMemberCount = 0;
|
741
|
+
this.getMembers().forEach(m => {
|
742
|
+
if (m.membership !== "join" && m.membership !== "invite") return;
|
743
|
+
if (functionalMembers.includes(m.userId)) return;
|
744
|
+
nonFunctionalMemberCount++;
|
745
|
+
});
|
746
|
+
if (nonFunctionalMemberCount > 2) return;
|
747
|
+
|
748
|
+
// Prefer the list of heroes, if present. It should only include the single other user in the DM.
|
749
|
+
var nonFunctionalHeroes = (_this$summaryHeroes2 = this.summaryHeroes) === null || _this$summaryHeroes2 === void 0 ? void 0 : _this$summaryHeroes2.filter(h => !functionalMembers.includes(h));
|
750
|
+
var hasHeroes = Array.isArray(nonFunctionalHeroes) && nonFunctionalHeroes.length;
|
751
|
+
if (hasHeroes) {
|
752
|
+
var availableMember = nonFunctionalHeroes.map(userId => {
|
753
|
+
return this.getMember(userId);
|
754
|
+
}).find(member => !!member);
|
755
|
+
if (availableMember) {
|
756
|
+
return availableMember;
|
757
|
+
}
|
758
|
+
}
|
759
|
+
|
760
|
+
// Consider *all*, including previous, members, to generate the avatar for DMs where the other user left.
|
761
|
+
// Needed to generate a matching avatar for rooms named "Empty Room (was Alice)".
|
762
|
+
var members = this.getMembers();
|
763
|
+
var nonFunctionalMembers = members === null || members === void 0 ? void 0 : members.filter(m => !functionalMembers.includes(m.userId));
|
764
|
+
if (nonFunctionalMembers.length <= 2) {
|
765
|
+
var _availableMember = nonFunctionalMembers.find(m => {
|
766
|
+
return m.userId !== this.myUserId;
|
767
|
+
});
|
768
|
+
if (_availableMember) {
|
769
|
+
return _availableMember;
|
770
|
+
}
|
771
|
+
}
|
772
|
+
|
773
|
+
// If all else failed, but the homeserver gave us heroes that previously could not be found in the room members,
|
774
|
+
// trust and try falling back to a hero, creating a one-off member for it
|
775
|
+
if (hasHeroes) {
|
776
|
+
var availableUser = nonFunctionalHeroes.map(userId => {
|
777
|
+
return this.client.getUser(userId);
|
778
|
+
}).find(user => !!user);
|
779
|
+
if (availableUser) {
|
780
|
+
var member = new RoomMember(this.roomId, availableUser.userId);
|
781
|
+
member.user = availableUser;
|
782
|
+
return member;
|
783
|
+
}
|
784
|
+
}
|
785
|
+
}
|
786
|
+
|
787
|
+
/**
|
788
|
+
* Sets the membership this room was received as during sync
|
789
|
+
* @param membership - join | leave | invite
|
790
|
+
*/
|
791
|
+
updateMyMembership(membership) {
|
792
|
+
var prevMembership = this.selfMembership;
|
793
|
+
this.selfMembership = membership;
|
794
|
+
if (prevMembership !== membership) {
|
795
|
+
if (membership === KnownMembership.Leave) {
|
796
|
+
this.cleanupAfterLeaving();
|
797
|
+
}
|
798
|
+
this.emit(RoomEvent.MyMembership, this, membership, prevMembership);
|
799
|
+
}
|
800
|
+
}
|
801
|
+
loadMembersFromServer() {
|
802
|
+
var _this6 = this;
|
803
|
+
return _asyncToGenerator(function* () {
|
804
|
+
var lastSyncToken = _this6.client.store.getSyncToken();
|
805
|
+
var response = yield _this6.client.members(_this6.roomId, undefined, KnownMembership.Leave, lastSyncToken !== null && lastSyncToken !== void 0 ? lastSyncToken : undefined);
|
806
|
+
return response.chunk;
|
807
|
+
})();
|
808
|
+
}
|
809
|
+
loadMembers() {
|
810
|
+
var _this7 = this;
|
811
|
+
return _asyncToGenerator(function* () {
|
812
|
+
// were the members loaded from the server?
|
813
|
+
var fromServer = false;
|
814
|
+
var rawMembersEvents = yield _this7.client.store.getOutOfBandMembers(_this7.roomId);
|
815
|
+
// If the room is encrypted, we always fetch members from the server at
|
816
|
+
// least once, in case the latest state wasn't persisted properly. Note
|
817
|
+
// that this function is only called once (unless loading the members
|
818
|
+
// fails), since loadMembersIfNeeded always returns this.membersPromise
|
819
|
+
// if set, which will be the result of the first (successful) call.
|
820
|
+
if (rawMembersEvents === null || _this7.hasEncryptionStateEvent()) {
|
821
|
+
fromServer = true;
|
822
|
+
rawMembersEvents = yield _this7.loadMembersFromServer();
|
823
|
+
logger.log("LL: got ".concat(rawMembersEvents.length, " ") + "members from server for room ".concat(_this7.roomId));
|
824
|
+
}
|
825
|
+
var memberEvents = rawMembersEvents.filter(noUnsafeEventProps).map(_this7.client.getEventMapper());
|
826
|
+
return {
|
827
|
+
memberEvents,
|
828
|
+
fromServer
|
829
|
+
};
|
830
|
+
})();
|
831
|
+
}
|
832
|
+
|
833
|
+
/**
|
834
|
+
* Check if loading of out-of-band-members has completed
|
835
|
+
*
|
836
|
+
* @returns true if the full membership list of this room has been loaded (including if lazy-loading is disabled).
|
837
|
+
* False if the load is not started or is in progress.
|
838
|
+
*/
|
839
|
+
membersLoaded() {
|
840
|
+
if (!this.opts.lazyLoadMembers) {
|
841
|
+
return true;
|
842
|
+
}
|
843
|
+
return this.currentState.outOfBandMembersReady();
|
844
|
+
}
|
845
|
+
|
846
|
+
/**
|
847
|
+
* Preloads the member list in case lazy loading
|
848
|
+
* of memberships is in use. Can be called multiple times,
|
849
|
+
* it will only preload once.
|
850
|
+
* @returns when preloading is done and
|
851
|
+
* accessing the members on the room will take
|
852
|
+
* all members in the room into account
|
853
|
+
*/
|
854
|
+
loadMembersIfNeeded() {
|
855
|
+
if (this.membersPromise) {
|
856
|
+
return this.membersPromise;
|
857
|
+
}
|
858
|
+
|
859
|
+
// mark the state so that incoming messages while
|
860
|
+
// the request is in flight get marked as superseding
|
861
|
+
// the OOB members
|
862
|
+
this.currentState.markOutOfBandMembersStarted();
|
863
|
+
var inMemoryUpdate = this.loadMembers().then(result => {
|
864
|
+
this.currentState.setOutOfBandMembers(result.memberEvents);
|
865
|
+
return result.fromServer;
|
866
|
+
}).catch(err => {
|
867
|
+
// allow retries on fail
|
868
|
+
this.membersPromise = undefined;
|
869
|
+
this.currentState.markOutOfBandMembersFailed();
|
870
|
+
throw err;
|
871
|
+
});
|
872
|
+
// update members in storage, but don't wait for it
|
873
|
+
inMemoryUpdate.then(fromServer => {
|
874
|
+
if (fromServer) {
|
875
|
+
var oobMembers = this.currentState.getMembers().filter(m => m.isOutOfBand()).map(m => {
|
876
|
+
var _m$events$member;
|
877
|
+
return (_m$events$member = m.events.member) === null || _m$events$member === void 0 ? void 0 : _m$events$member.event;
|
878
|
+
});
|
879
|
+
logger.log("LL: telling store to write ".concat(oobMembers.length) + " members for room ".concat(this.roomId));
|
880
|
+
var store = this.client.store;
|
881
|
+
return store.setOutOfBandMembers(this.roomId, oobMembers)
|
882
|
+
// swallow any IDB error as we don't want to fail
|
883
|
+
// because of this
|
884
|
+
.catch(err => {
|
885
|
+
logger.log("LL: storing OOB room members failed, oh well", err);
|
886
|
+
});
|
887
|
+
}
|
888
|
+
}).catch(err => {
|
889
|
+
// as this is not awaited anywhere,
|
890
|
+
// at least show the error in the console
|
891
|
+
logger.error(err);
|
892
|
+
});
|
893
|
+
this.membersPromise = inMemoryUpdate;
|
894
|
+
return this.membersPromise;
|
895
|
+
}
|
896
|
+
|
897
|
+
/**
|
898
|
+
* Removes the lazily loaded members from storage if needed
|
899
|
+
*/
|
900
|
+
clearLoadedMembersIfNeeded() {
|
901
|
+
var _this8 = this;
|
902
|
+
return _asyncToGenerator(function* () {
|
903
|
+
if (_this8.opts.lazyLoadMembers && _this8.membersPromise) {
|
904
|
+
yield _this8.loadMembersIfNeeded();
|
905
|
+
yield _this8.client.store.clearOutOfBandMembers(_this8.roomId);
|
906
|
+
_this8.currentState.clearOutOfBandMembers();
|
907
|
+
_this8.membersPromise = undefined;
|
908
|
+
}
|
909
|
+
})();
|
910
|
+
}
|
911
|
+
|
912
|
+
/**
|
913
|
+
* called when sync receives this room in the leave section
|
914
|
+
* to do cleanup after leaving a room. Possibly called multiple times.
|
915
|
+
*/
|
916
|
+
cleanupAfterLeaving() {
|
917
|
+
this.clearLoadedMembersIfNeeded().catch(err => {
|
918
|
+
logger.error("error after clearing loaded members from " + "room ".concat(this.roomId, " after leaving"));
|
919
|
+
logger.log(err);
|
920
|
+
});
|
921
|
+
}
|
922
|
+
|
923
|
+
/**
|
924
|
+
* Empty out the current live timeline and re-request it. This is used when
|
925
|
+
* historical messages are imported into the room via MSC2716 `/batch_send`
|
926
|
+
* because the client may already have that section of the timeline loaded.
|
927
|
+
* We need to force the client to throw away their current timeline so that
|
928
|
+
* when they back paginate over the area again with the historical messages
|
929
|
+
* in between, it grabs the newly imported messages. We can listen for
|
930
|
+
* `UNSTABLE_MSC2716_MARKER`, in order to tell when historical messages are ready
|
931
|
+
* to be discovered in the room and the timeline needs a refresh. The SDK
|
932
|
+
* emits a `RoomEvent.HistoryImportedWithinTimeline` event when we detect a
|
933
|
+
* valid marker and can check the needs refresh status via
|
934
|
+
* `room.getTimelineNeedsRefresh()`.
|
935
|
+
*/
|
936
|
+
refreshLiveTimeline() {
|
937
|
+
var _this9 = this;
|
938
|
+
return _asyncToGenerator(function* () {
|
939
|
+
var liveTimelineBefore = _this9.getLiveTimeline();
|
940
|
+
var forwardPaginationToken = liveTimelineBefore.getPaginationToken(EventTimeline.FORWARDS);
|
941
|
+
var backwardPaginationToken = liveTimelineBefore.getPaginationToken(EventTimeline.BACKWARDS);
|
942
|
+
var eventsBefore = liveTimelineBefore.getEvents();
|
943
|
+
var mostRecentEventInTimeline = eventsBefore[eventsBefore.length - 1];
|
944
|
+
logger.log("[refreshLiveTimeline for ".concat(_this9.roomId, "] at ") + "mostRecentEventInTimeline=".concat(mostRecentEventInTimeline && mostRecentEventInTimeline.getId(), " ") + "liveTimelineBefore=".concat(liveTimelineBefore.toString(), " ") + "forwardPaginationToken=".concat(forwardPaginationToken, " ") + "backwardPaginationToken=".concat(backwardPaginationToken));
|
945
|
+
|
946
|
+
// Get the main TimelineSet
|
947
|
+
var timelineSet = _this9.getUnfilteredTimelineSet();
|
948
|
+
var newTimeline;
|
949
|
+
// If there isn't any event in the timeline, let's go fetch the latest
|
950
|
+
// event and construct a timeline from it.
|
951
|
+
//
|
952
|
+
// This should only really happen if the user ran into an error
|
953
|
+
// with refreshing the timeline before which left them in a blank
|
954
|
+
// timeline from `resetLiveTimeline`.
|
955
|
+
if (!mostRecentEventInTimeline) {
|
956
|
+
newTimeline = yield _this9.client.getLatestTimeline(timelineSet);
|
957
|
+
} else {
|
958
|
+
// Empty out all of `this.timelineSets`. But we also need to keep the
|
959
|
+
// same `timelineSet` references around so the React code updates
|
960
|
+
// properly and doesn't ignore the room events we emit because it checks
|
961
|
+
// that the `timelineSet` references are the same. We need the
|
962
|
+
// `timelineSet` empty so that the `client.getEventTimeline(...)` call
|
963
|
+
// later, will call `/context` and create a new timeline instead of
|
964
|
+
// returning the same one.
|
965
|
+
_this9.resetLiveTimeline(null, null);
|
966
|
+
|
967
|
+
// Make the UI timeline show the new blank live timeline we just
|
968
|
+
// reset so that if the network fails below it's showing the
|
969
|
+
// accurate state of what we're working with instead of the
|
970
|
+
// disconnected one in the TimelineWindow which is just hanging
|
971
|
+
// around by reference.
|
972
|
+
_this9.emit(RoomEvent.TimelineRefresh, _this9, timelineSet);
|
973
|
+
|
974
|
+
// Use `client.getEventTimeline(...)` to construct a new timeline from a
|
975
|
+
// `/context` response state and events for the most recent event before
|
976
|
+
// we reset everything. The `timelineSet` we pass in needs to be empty
|
977
|
+
// in order for this function to call `/context` and generate a new
|
978
|
+
// timeline.
|
979
|
+
newTimeline = yield _this9.client.getEventTimeline(timelineSet, mostRecentEventInTimeline.getId());
|
980
|
+
}
|
981
|
+
|
982
|
+
// If a racing `/sync` beat us to creating a new timeline, use that
|
983
|
+
// instead because it's the latest in the room and any new messages in
|
984
|
+
// the scrollback will include the history.
|
985
|
+
var liveTimeline = timelineSet.getLiveTimeline();
|
986
|
+
if (!liveTimeline || liveTimeline.getPaginationToken(Direction.Forward) === null && liveTimeline.getPaginationToken(Direction.Backward) === null && liveTimeline.getEvents().length === 0) {
|
987
|
+
logger.log("[refreshLiveTimeline for ".concat(_this9.roomId, "] using our new live timeline"));
|
988
|
+
// Set the pagination token back to the live sync token (`null`) instead
|
989
|
+
// of using the `/context` historical token (ex. `t12-13_0_0_0_0_0_0_0_0`)
|
990
|
+
// so that it matches the next response from `/sync` and we can properly
|
991
|
+
// continue the timeline.
|
992
|
+
newTimeline.setPaginationToken(forwardPaginationToken, EventTimeline.FORWARDS);
|
993
|
+
|
994
|
+
// Set our new fresh timeline as the live timeline to continue syncing
|
995
|
+
// forwards and back paginating from.
|
996
|
+
timelineSet.setLiveTimeline(newTimeline);
|
997
|
+
// Fixup `this.oldstate` so that `scrollback` has the pagination tokens
|
998
|
+
// available
|
999
|
+
_this9.fixUpLegacyTimelineFields();
|
1000
|
+
} else {
|
1001
|
+
logger.log("[refreshLiveTimeline for ".concat(_this9.roomId, "] `/sync` or some other request beat us to creating a new ") + "live timeline after we reset it. We'll use that instead since any events in the scrollback from " + "this timeline will include the history.");
|
1002
|
+
}
|
1003
|
+
|
1004
|
+
// The timeline has now been refreshed ✅
|
1005
|
+
_this9.setTimelineNeedsRefresh(false);
|
1006
|
+
|
1007
|
+
// Emit an event which clients can react to and re-load the timeline
|
1008
|
+
// from the SDK
|
1009
|
+
_this9.emit(RoomEvent.TimelineRefresh, _this9, timelineSet);
|
1010
|
+
})();
|
1011
|
+
}
|
1012
|
+
|
1013
|
+
/**
|
1014
|
+
* Reset the live timeline of all timelineSets, and start new ones.
|
1015
|
+
*
|
1016
|
+
* <p>This is used when /sync returns a 'limited' timeline.
|
1017
|
+
*
|
1018
|
+
* @param backPaginationToken - token for back-paginating the new timeline
|
1019
|
+
* @param forwardPaginationToken - token for forward-paginating the old live timeline,
|
1020
|
+
* if absent or null, all timelines are reset, removing old ones (including the previous live
|
1021
|
+
* timeline which would otherwise be unable to paginate forwards without this token).
|
1022
|
+
* Removing just the old live timeline whilst preserving previous ones is not supported.
|
1023
|
+
*/
|
1024
|
+
resetLiveTimeline(backPaginationToken, forwardPaginationToken) {
|
1025
|
+
for (var timelineSet of this.timelineSets) {
|
1026
|
+
timelineSet.resetLiveTimeline(backPaginationToken !== null && backPaginationToken !== void 0 ? backPaginationToken : undefined, forwardPaginationToken !== null && forwardPaginationToken !== void 0 ? forwardPaginationToken : undefined);
|
1027
|
+
}
|
1028
|
+
for (var thread of this.threads.values()) {
|
1029
|
+
thread.resetLiveTimeline(backPaginationToken, forwardPaginationToken);
|
1030
|
+
}
|
1031
|
+
this.fixUpLegacyTimelineFields();
|
1032
|
+
}
|
1033
|
+
|
1034
|
+
/**
|
1035
|
+
* Fix up this.timeline, this.oldState and this.currentState
|
1036
|
+
*
|
1037
|
+
* @internal
|
1038
|
+
*/
|
1039
|
+
fixUpLegacyTimelineFields() {
|
1040
|
+
var previousOldState = this.oldState;
|
1041
|
+
var previousCurrentState = this.currentState;
|
1042
|
+
|
1043
|
+
// maintain this.oldState and this.currentState as references to the
|
1044
|
+
// state at the start and end of that timeline. These are more
|
1045
|
+
// for backwards-compatibility than anything else.
|
1046
|
+
this.oldState = this.getLiveTimeline().getState(EventTimeline.BACKWARDS);
|
1047
|
+
this.currentState = this.getLiveTimeline().getState(EventTimeline.FORWARDS);
|
1048
|
+
|
1049
|
+
// Let people know to register new listeners for the new state
|
1050
|
+
// references. The reference won't necessarily change every time so only
|
1051
|
+
// emit when we see a change.
|
1052
|
+
if (previousOldState !== this.oldState) {
|
1053
|
+
this.emit(RoomEvent.OldStateUpdated, this, previousOldState, this.oldState);
|
1054
|
+
}
|
1055
|
+
if (previousCurrentState !== this.currentState) {
|
1056
|
+
this.emit(RoomEvent.CurrentStateUpdated, this, previousCurrentState, this.currentState);
|
1057
|
+
|
1058
|
+
// Re-emit various events on the current room state
|
1059
|
+
// TODO: If currentState really only exists for backwards
|
1060
|
+
// compatibility, shouldn't we be doing this some other way?
|
1061
|
+
this.reEmitter.stopReEmitting(previousCurrentState, [RoomStateEvent.Events, RoomStateEvent.Members, RoomStateEvent.NewMember, RoomStateEvent.Update, RoomStateEvent.Marker, BeaconEvent.New, BeaconEvent.Update, BeaconEvent.Destroy, BeaconEvent.LivenessChange]);
|
1062
|
+
this.reEmitter.reEmit(this.currentState, [RoomStateEvent.Events, RoomStateEvent.Members, RoomStateEvent.NewMember, RoomStateEvent.Update, RoomStateEvent.Marker, BeaconEvent.New, BeaconEvent.Update, BeaconEvent.Destroy, BeaconEvent.LivenessChange]);
|
1063
|
+
}
|
1064
|
+
}
|
1065
|
+
onReceipt(event) {
|
1066
|
+
if (this.hasEncryptionStateEvent()) {
|
1067
|
+
this.clearNotificationsOnReceipt(event);
|
1068
|
+
}
|
1069
|
+
}
|
1070
|
+
clearNotificationsOnReceipt(event) {
|
1071
|
+
// Like above, we have to listen for read receipts from ourselves in order to
|
1072
|
+
// correctly handle notification counts on encrypted rooms.
|
1073
|
+
// This fixes https://github.com/vector-im/element-web/issues/9421
|
1074
|
+
|
1075
|
+
// Figure out if we've read something or if it's just informational
|
1076
|
+
// We need to work out what threads we've just recieved receipts for, so we
|
1077
|
+
// know which ones to update. If we've received an unthreaded receipt, we'll
|
1078
|
+
// need to update all threads.
|
1079
|
+
var threadIds = [];
|
1080
|
+
var hasUnthreadedReceipt = false;
|
1081
|
+
var content = event.getContent();
|
1082
|
+
for (var receiptGroup of Object.values(content)) {
|
1083
|
+
for (var [receiptType, userReceipt] of Object.entries(receiptGroup)) {
|
1084
|
+
if (!utils.isSupportedReceiptType(receiptType)) continue;
|
1085
|
+
if (!userReceipt) continue;
|
1086
|
+
for (var [userId, singleReceipt] of Object.entries(userReceipt)) {
|
1087
|
+
if (!singleReceipt || typeof singleReceipt !== "object") continue;
|
1088
|
+
var typedSingleReceipt = singleReceipt;
|
1089
|
+
if (userId !== this.client.getUserId()) continue;
|
1090
|
+
if (typedSingleReceipt.thread_id === undefined) {
|
1091
|
+
hasUnthreadedReceipt = true;
|
1092
|
+
} else if (typeof typedSingleReceipt.thread_id === "string") {
|
1093
|
+
threadIds.push(typedSingleReceipt.thread_id);
|
1094
|
+
}
|
1095
|
+
}
|
1096
|
+
}
|
1097
|
+
}
|
1098
|
+
if (hasUnthreadedReceipt) {
|
1099
|
+
// If we have an unthreaded receipt, we need to update any threads that have a notification
|
1100
|
+
// in them (because we know the receipt can't go backwards so we don't need to check any with
|
1101
|
+
// no notifications: the number can only decrease from a receipt).
|
1102
|
+
threadIds = this.getThreads().filter(thread => this.getThreadUnreadNotificationCount(thread.id, NotificationCountType.Total) > 0 || this.getThreadUnreadNotificationCount(thread.id, NotificationCountType.Highlight) > 0).map(thread => thread.id);
|
1103
|
+
threadIds.push("main");
|
1104
|
+
}
|
1105
|
+
for (var threadId of threadIds) {
|
1106
|
+
var _this$getThread;
|
1107
|
+
// Work backwards to determine how many events are unread. We also set
|
1108
|
+
// a limit for how back we'll look to avoid spinning CPU for too long.
|
1109
|
+
// If we hit the limit, we assume the count is unchanged.
|
1110
|
+
var maxHistory = 20;
|
1111
|
+
var timeline = threadId === "main" ? this.getLiveTimeline() : (_this$getThread = this.getThread(threadId)) === null || _this$getThread === void 0 ? void 0 : _this$getThread.liveTimeline;
|
1112
|
+
if (!timeline) {
|
1113
|
+
logger.warn("Couldn't find timeline for thread ID ".concat(threadId, " in room ").concat(this.roomId));
|
1114
|
+
continue;
|
1115
|
+
}
|
1116
|
+
var events = timeline.getEvents();
|
1117
|
+
var highlightCount = 0;
|
1118
|
+
for (var i = events.length - 1; i >= 0; i--) {
|
1119
|
+
var _pushActions$tweaks;
|
1120
|
+
if (i === events.length - maxHistory) return; // limit reached
|
1121
|
+
|
1122
|
+
var _event = events[i];
|
1123
|
+
if (this.hasUserReadEvent(this.client.getUserId(), _event.getId())) {
|
1124
|
+
// If the user has read the event, then the counting is done.
|
1125
|
+
break;
|
1126
|
+
}
|
1127
|
+
var pushActions = this.client.getPushActionsForEvent(_event);
|
1128
|
+
highlightCount += pushActions !== null && pushActions !== void 0 && (_pushActions$tweaks = pushActions.tweaks) !== null && _pushActions$tweaks !== void 0 && _pushActions$tweaks.highlight ? 1 : 0;
|
1129
|
+
}
|
1130
|
+
|
1131
|
+
// Note: we don't need to handle 'total' notifications because the counts
|
1132
|
+
// will come from the server.
|
1133
|
+
if (threadId === "main") {
|
1134
|
+
this.setUnreadNotificationCount(NotificationCountType.Highlight, highlightCount);
|
1135
|
+
} else {
|
1136
|
+
this.setThreadUnreadNotificationCount(threadId, NotificationCountType.Highlight, highlightCount);
|
1137
|
+
}
|
1138
|
+
}
|
1139
|
+
}
|
1140
|
+
|
1141
|
+
/**
|
1142
|
+
* Return the timeline sets for this room.
|
1143
|
+
* @returns array of timeline sets for this room
|
1144
|
+
*/
|
1145
|
+
getTimelineSets() {
|
1146
|
+
return this.timelineSets;
|
1147
|
+
}
|
1148
|
+
|
1149
|
+
/**
|
1150
|
+
* Helper to return the main unfiltered timeline set for this room
|
1151
|
+
* @returns room's unfiltered timeline set
|
1152
|
+
*/
|
1153
|
+
getUnfilteredTimelineSet() {
|
1154
|
+
return this.timelineSets[0];
|
1155
|
+
}
|
1156
|
+
|
1157
|
+
/**
|
1158
|
+
* Get the timeline which contains the given event from the unfiltered set, if any
|
1159
|
+
*
|
1160
|
+
* @param eventId - event ID to look for
|
1161
|
+
* @returns timeline containing
|
1162
|
+
* the given event, or null if unknown
|
1163
|
+
*/
|
1164
|
+
getTimelineForEvent(eventId) {
|
1165
|
+
var event = this.findEventById(eventId);
|
1166
|
+
var thread = this.findThreadForEvent(event);
|
1167
|
+
if (thread) {
|
1168
|
+
return thread.timelineSet.getTimelineForEvent(eventId);
|
1169
|
+
} else {
|
1170
|
+
return this.getUnfilteredTimelineSet().getTimelineForEvent(eventId);
|
1171
|
+
}
|
1172
|
+
}
|
1173
|
+
|
1174
|
+
/**
|
1175
|
+
* Add a new timeline to this room's unfiltered timeline set
|
1176
|
+
*
|
1177
|
+
* @returns newly-created timeline
|
1178
|
+
*/
|
1179
|
+
addTimeline() {
|
1180
|
+
return this.getUnfilteredTimelineSet().addTimeline();
|
1181
|
+
}
|
1182
|
+
|
1183
|
+
/**
|
1184
|
+
* Whether the timeline needs to be refreshed in order to pull in new
|
1185
|
+
* historical messages that were imported.
|
1186
|
+
* @param value - The value to set
|
1187
|
+
*/
|
1188
|
+
setTimelineNeedsRefresh(value) {
|
1189
|
+
this.timelineNeedsRefresh = value;
|
1190
|
+
}
|
1191
|
+
|
1192
|
+
/**
|
1193
|
+
* Whether the timeline needs to be refreshed in order to pull in new
|
1194
|
+
* historical messages that were imported.
|
1195
|
+
* @returns .
|
1196
|
+
*/
|
1197
|
+
getTimelineNeedsRefresh() {
|
1198
|
+
return this.timelineNeedsRefresh;
|
1199
|
+
}
|
1200
|
+
|
1201
|
+
/**
|
1202
|
+
* Get an event which is stored in our unfiltered timeline set, or in a thread
|
1203
|
+
*
|
1204
|
+
* @param eventId - event ID to look for
|
1205
|
+
* @returns the given event, or undefined if unknown
|
1206
|
+
*/
|
1207
|
+
findEventById(eventId) {
|
1208
|
+
var event = this.getUnfilteredTimelineSet().findEventById(eventId);
|
1209
|
+
if (!event) {
|
1210
|
+
var threads = this.getThreads();
|
1211
|
+
for (var i = 0; i < threads.length; i++) {
|
1212
|
+
var thread = threads[i];
|
1213
|
+
event = thread.findEventById(eventId);
|
1214
|
+
if (event) {
|
1215
|
+
return event;
|
1216
|
+
}
|
1217
|
+
}
|
1218
|
+
}
|
1219
|
+
return event;
|
1220
|
+
}
|
1221
|
+
|
1222
|
+
/**
|
1223
|
+
* Get one of the notification counts for this room
|
1224
|
+
* @param type - The type of notification count to get. default: 'total'
|
1225
|
+
* @returns The notification count, or undefined if there is no count
|
1226
|
+
* for this type.
|
1227
|
+
*/
|
1228
|
+
getUnreadNotificationCount() {
|
1229
|
+
var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : NotificationCountType.Total;
|
1230
|
+
var count = this.getRoomUnreadNotificationCount(type);
|
1231
|
+
for (var threadNotification of this.threadNotifications.values()) {
|
1232
|
+
var _threadNotification$t;
|
1233
|
+
count += (_threadNotification$t = threadNotification[type]) !== null && _threadNotification$t !== void 0 ? _threadNotification$t : 0;
|
1234
|
+
}
|
1235
|
+
return count;
|
1236
|
+
}
|
1237
|
+
|
1238
|
+
/**
|
1239
|
+
* Get the notification for the event context (room or thread timeline)
|
1240
|
+
*/
|
1241
|
+
getUnreadCountForEventContext() {
|
1242
|
+
var _ref2;
|
1243
|
+
var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : NotificationCountType.Total;
|
1244
|
+
var event = arguments.length > 1 ? arguments[1] : undefined;
|
1245
|
+
var isThreadEvent = !!event.threadRootId && !event.isThreadRoot;
|
1246
|
+
return (_ref2 = isThreadEvent ? this.getThreadUnreadNotificationCount(event.threadRootId, type) : this.getRoomUnreadNotificationCount(type)) !== null && _ref2 !== void 0 ? _ref2 : 0;
|
1247
|
+
}
|
1248
|
+
|
1249
|
+
/**
|
1250
|
+
* Get one of the notification counts for this room
|
1251
|
+
* @param type - The type of notification count to get. default: 'total'
|
1252
|
+
* @returns The notification count, or undefined if there is no count
|
1253
|
+
* for this type.
|
1254
|
+
*/
|
1255
|
+
getRoomUnreadNotificationCount() {
|
1256
|
+
var _this$notificationCou;
|
1257
|
+
var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : NotificationCountType.Total;
|
1258
|
+
return (_this$notificationCou = this.notificationCounts[type]) !== null && _this$notificationCou !== void 0 ? _this$notificationCou : 0;
|
1259
|
+
}
|
1260
|
+
|
1261
|
+
/**
|
1262
|
+
* Get one of the notification counts for a thread
|
1263
|
+
* @param threadId - the root event ID
|
1264
|
+
* @param type - The type of notification count to get. default: 'total'
|
1265
|
+
* @returns The notification count, or undefined if there is no count
|
1266
|
+
* for this type.
|
1267
|
+
*/
|
1268
|
+
getThreadUnreadNotificationCount(threadId) {
|
1269
|
+
var _this$threadNotificat, _this$threadNotificat2;
|
1270
|
+
var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : NotificationCountType.Total;
|
1271
|
+
return (_this$threadNotificat = (_this$threadNotificat2 = this.threadNotifications.get(threadId)) === null || _this$threadNotificat2 === void 0 ? void 0 : _this$threadNotificat2[type]) !== null && _this$threadNotificat !== void 0 ? _this$threadNotificat : 0;
|
1272
|
+
}
|
1273
|
+
|
1274
|
+
/**
|
1275
|
+
* Checks if the current room has unread thread notifications
|
1276
|
+
* @returns
|
1277
|
+
*/
|
1278
|
+
hasThreadUnreadNotification() {
|
1279
|
+
for (var notification of this.threadNotifications.values()) {
|
1280
|
+
var _notification$highlig, _notification$total;
|
1281
|
+
if (((_notification$highlig = notification.highlight) !== null && _notification$highlig !== void 0 ? _notification$highlig : 0) > 0 || ((_notification$total = notification.total) !== null && _notification$total !== void 0 ? _notification$total : 0) > 0) {
|
1282
|
+
return true;
|
1283
|
+
}
|
1284
|
+
}
|
1285
|
+
return false;
|
1286
|
+
}
|
1287
|
+
|
1288
|
+
/**
|
1289
|
+
* Swet one of the notification count for a thread
|
1290
|
+
* @param threadId - the root event ID
|
1291
|
+
* @param type - The type of notification count to get. default: 'total'
|
1292
|
+
* @returns
|
1293
|
+
*/
|
1294
|
+
setThreadUnreadNotificationCount(threadId, type, count) {
|
1295
|
+
var _this$threadNotificat3, _this$threadNotificat4;
|
1296
|
+
var notification = _objectSpread({
|
1297
|
+
highlight: (_this$threadNotificat3 = this.threadNotifications.get(threadId)) === null || _this$threadNotificat3 === void 0 ? void 0 : _this$threadNotificat3.highlight,
|
1298
|
+
total: (_this$threadNotificat4 = this.threadNotifications.get(threadId)) === null || _this$threadNotificat4 === void 0 ? void 0 : _this$threadNotificat4.total
|
1299
|
+
}, {
|
1300
|
+
[type]: count
|
1301
|
+
});
|
1302
|
+
this.threadNotifications.set(threadId, notification);
|
1303
|
+
this.emit(RoomEvent.UnreadNotifications, notification, threadId);
|
1304
|
+
}
|
1305
|
+
|
1306
|
+
/**
|
1307
|
+
* @returns the notification count type for all the threads in the room
|
1308
|
+
*/
|
1309
|
+
get threadsAggregateNotificationType() {
|
1310
|
+
var type = null;
|
1311
|
+
for (var threadNotification of this.threadNotifications.values()) {
|
1312
|
+
var _threadNotification$h, _threadNotification$t2;
|
1313
|
+
if (((_threadNotification$h = threadNotification.highlight) !== null && _threadNotification$h !== void 0 ? _threadNotification$h : 0) > 0) {
|
1314
|
+
return NotificationCountType.Highlight;
|
1315
|
+
} else if (((_threadNotification$t2 = threadNotification.total) !== null && _threadNotification$t2 !== void 0 ? _threadNotification$t2 : 0) > 0 && !type) {
|
1316
|
+
type = NotificationCountType.Total;
|
1317
|
+
}
|
1318
|
+
}
|
1319
|
+
return type;
|
1320
|
+
}
|
1321
|
+
|
1322
|
+
/**
|
1323
|
+
* Resets the total thread notifications for all threads in this room to zero,
|
1324
|
+
* excluding any threads whose IDs are given in `exceptThreadIds`.
|
1325
|
+
*
|
1326
|
+
* If the room is not encrypted, also resets the highlight notification count to zero
|
1327
|
+
* for the same set of threads.
|
1328
|
+
*
|
1329
|
+
* This is intended for use from the sync code since we calculate highlight notification
|
1330
|
+
* counts locally from decrypted messages. We want to partially trust the total from the
|
1331
|
+
* server such that we clear notifications when read receipts arrive. The weird name is
|
1332
|
+
* intended to reflect this. You probably do not want to use this.
|
1333
|
+
*
|
1334
|
+
* @param exceptThreadIds - The thread IDs to exclude from the reset.
|
1335
|
+
*/
|
1336
|
+
resetThreadUnreadNotificationCountFromSync() {
|
1337
|
+
var exceptThreadIds = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
1338
|
+
var isEncrypted = this.hasEncryptionStateEvent();
|
1339
|
+
for (var [threadId, notifs] of this.threadNotifications) {
|
1340
|
+
if (!exceptThreadIds.includes(threadId)) {
|
1341
|
+
notifs.total = 0;
|
1342
|
+
if (!isEncrypted) {
|
1343
|
+
notifs.highlight = 0;
|
1344
|
+
}
|
1345
|
+
}
|
1346
|
+
}
|
1347
|
+
this.emit(RoomEvent.UnreadNotifications);
|
1348
|
+
}
|
1349
|
+
|
1350
|
+
/**
|
1351
|
+
* Set one of the notification counts for this room
|
1352
|
+
* @param type - The type of notification count to set.
|
1353
|
+
* @param count - The new count
|
1354
|
+
*/
|
1355
|
+
setUnreadNotificationCount(type, count) {
|
1356
|
+
this.notificationCounts[type] = count;
|
1357
|
+
this.emit(RoomEvent.UnreadNotifications, this.notificationCounts);
|
1358
|
+
}
|
1359
|
+
setUnread(type, count) {
|
1360
|
+
return this.setUnreadNotificationCount(type, count);
|
1361
|
+
}
|
1362
|
+
setSummary(summary) {
|
1363
|
+
var heroes = summary["m.heroes"];
|
1364
|
+
var joinedCount = summary["m.joined_member_count"];
|
1365
|
+
var invitedCount = summary["m.invited_member_count"];
|
1366
|
+
if (Number.isInteger(joinedCount)) {
|
1367
|
+
this.currentState.setJoinedMemberCount(joinedCount);
|
1368
|
+
}
|
1369
|
+
if (Number.isInteger(invitedCount)) {
|
1370
|
+
this.currentState.setInvitedMemberCount(invitedCount);
|
1371
|
+
}
|
1372
|
+
if (Array.isArray(heroes)) {
|
1373
|
+
// be cautious about trusting server values,
|
1374
|
+
// and make sure heroes doesn't contain our own id
|
1375
|
+
// just to be sure
|
1376
|
+
this.summaryHeroes = heroes.filter(userId => {
|
1377
|
+
return userId !== this.myUserId;
|
1378
|
+
});
|
1379
|
+
}
|
1380
|
+
this.emit(RoomEvent.Summary, summary);
|
1381
|
+
}
|
1382
|
+
|
1383
|
+
/**
|
1384
|
+
* Whether to send encrypted messages to devices within this room.
|
1385
|
+
* @param value - true to blacklist unverified devices, null
|
1386
|
+
* to use the global value for this room.
|
1387
|
+
*/
|
1388
|
+
setBlacklistUnverifiedDevices(value) {
|
1389
|
+
this.blacklistUnverifiedDevices = value;
|
1390
|
+
}
|
1391
|
+
|
1392
|
+
/**
|
1393
|
+
* Whether to send encrypted messages to devices within this room.
|
1394
|
+
* @returns true if blacklisting unverified devices, null
|
1395
|
+
* if the global value should be used for this room.
|
1396
|
+
*/
|
1397
|
+
getBlacklistUnverifiedDevices() {
|
1398
|
+
if (this.blacklistUnverifiedDevices === undefined) return null;
|
1399
|
+
return this.blacklistUnverifiedDevices;
|
1400
|
+
}
|
1401
|
+
|
1402
|
+
/**
|
1403
|
+
* Get the avatar URL for a room if one was set.
|
1404
|
+
* @param baseUrl - The homeserver base URL. See
|
1405
|
+
* {@link MatrixClient#getHomeserverUrl}.
|
1406
|
+
* @param width - The desired width of the thumbnail.
|
1407
|
+
* @param height - The desired height of the thumbnail.
|
1408
|
+
* @param resizeMethod - The thumbnail resize method to use, either
|
1409
|
+
* "crop" or "scale".
|
1410
|
+
* @param allowDefault - True to allow an identicon for this room if an
|
1411
|
+
* avatar URL wasn't explicitly set. Default: true. (Deprecated)
|
1412
|
+
* @returns the avatar URL or null.
|
1413
|
+
*/
|
1414
|
+
getAvatarUrl(baseUrl, width, height, resizeMethod) {
|
1415
|
+
var allowDefault = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
|
1416
|
+
var roomAvatarEvent = this.currentState.getStateEvents(EventType.RoomAvatar, "");
|
1417
|
+
if (!roomAvatarEvent && !allowDefault) {
|
1418
|
+
return null;
|
1419
|
+
}
|
1420
|
+
var mainUrl = roomAvatarEvent ? roomAvatarEvent.getContent().url : null;
|
1421
|
+
if (mainUrl) {
|
1422
|
+
return getHttpUriForMxc(baseUrl, mainUrl, width, height, resizeMethod);
|
1423
|
+
}
|
1424
|
+
return null;
|
1425
|
+
}
|
1426
|
+
|
1427
|
+
/**
|
1428
|
+
* Get the mxc avatar url for the room, if one was set.
|
1429
|
+
* @returns the mxc avatar url or falsy
|
1430
|
+
*/
|
1431
|
+
getMxcAvatarUrl() {
|
1432
|
+
var _this$currentState$ge;
|
1433
|
+
return ((_this$currentState$ge = this.currentState.getStateEvents(EventType.RoomAvatar, "")) === null || _this$currentState$ge === void 0 || (_this$currentState$ge = _this$currentState$ge.getContent()) === null || _this$currentState$ge === void 0 ? void 0 : _this$currentState$ge.url) || null;
|
1434
|
+
}
|
1435
|
+
|
1436
|
+
/**
|
1437
|
+
* Get this room's canonical alias
|
1438
|
+
* The alias returned by this function may not necessarily
|
1439
|
+
* still point to this room.
|
1440
|
+
* @returns The room's canonical alias, or null if there is none
|
1441
|
+
*/
|
1442
|
+
getCanonicalAlias() {
|
1443
|
+
var canonicalAlias = this.currentState.getStateEvents(EventType.RoomCanonicalAlias, "");
|
1444
|
+
if (canonicalAlias) {
|
1445
|
+
return canonicalAlias.getContent().alias || null;
|
1446
|
+
}
|
1447
|
+
return null;
|
1448
|
+
}
|
1449
|
+
|
1450
|
+
/**
|
1451
|
+
* Get this room's alternative aliases
|
1452
|
+
* @returns The room's alternative aliases, or an empty array
|
1453
|
+
*/
|
1454
|
+
getAltAliases() {
|
1455
|
+
var canonicalAlias = this.currentState.getStateEvents(EventType.RoomCanonicalAlias, "");
|
1456
|
+
if (canonicalAlias) {
|
1457
|
+
return canonicalAlias.getContent().alt_aliases || [];
|
1458
|
+
}
|
1459
|
+
return [];
|
1460
|
+
}
|
1461
|
+
|
1462
|
+
/**
|
1463
|
+
* Add events to a timeline
|
1464
|
+
*
|
1465
|
+
* <p>Will fire "Room.timeline" for each event added.
|
1466
|
+
*
|
1467
|
+
* @param events - A list of events to add.
|
1468
|
+
*
|
1469
|
+
* @param toStartOfTimeline - True to add these events to the start
|
1470
|
+
* (oldest) instead of the end (newest) of the timeline. If true, the oldest
|
1471
|
+
* event will be the <b>last</b> element of 'events'.
|
1472
|
+
*
|
1473
|
+
* @param timeline - timeline to
|
1474
|
+
* add events to.
|
1475
|
+
*
|
1476
|
+
* @param paginationToken - token for the next batch of events
|
1477
|
+
*
|
1478
|
+
* @remarks
|
1479
|
+
* Fires {@link RoomEvent.Timeline}
|
1480
|
+
*/
|
1481
|
+
addEventsToTimeline(events, toStartOfTimeline, timeline, paginationToken) {
|
1482
|
+
timeline.getTimelineSet().addEventsToTimeline(events, toStartOfTimeline, timeline, paginationToken);
|
1483
|
+
}
|
1484
|
+
|
1485
|
+
/**
|
1486
|
+
* Get the instance of the thread associated with the current event
|
1487
|
+
* @param eventId - the ID of the current event
|
1488
|
+
* @returns a thread instance if known
|
1489
|
+
*/
|
1490
|
+
getThread(eventId) {
|
1491
|
+
var _this$threads$get;
|
1492
|
+
return (_this$threads$get = this.threads.get(eventId)) !== null && _this$threads$get !== void 0 ? _this$threads$get : null;
|
1493
|
+
}
|
1494
|
+
|
1495
|
+
/**
|
1496
|
+
* Get all the known threads in the room
|
1497
|
+
*/
|
1498
|
+
getThreads() {
|
1499
|
+
return Array.from(this.threads.values());
|
1500
|
+
}
|
1501
|
+
|
1502
|
+
/**
|
1503
|
+
* Get a member from the current room state.
|
1504
|
+
* @param userId - The user ID of the member.
|
1505
|
+
* @returns The member or `null`.
|
1506
|
+
*/
|
1507
|
+
getMember(userId) {
|
1508
|
+
return this.currentState.getMember(userId);
|
1509
|
+
}
|
1510
|
+
|
1511
|
+
/**
|
1512
|
+
* Get all currently loaded members from the current
|
1513
|
+
* room state.
|
1514
|
+
* @returns Room members
|
1515
|
+
*/
|
1516
|
+
getMembers() {
|
1517
|
+
return this.currentState.getMembers();
|
1518
|
+
}
|
1519
|
+
|
1520
|
+
/**
|
1521
|
+
* Get a list of members whose membership state is "join".
|
1522
|
+
* @returns A list of currently joined members.
|
1523
|
+
*/
|
1524
|
+
getJoinedMembers() {
|
1525
|
+
return this.getMembersWithMembership(KnownMembership.Join);
|
1526
|
+
}
|
1527
|
+
|
1528
|
+
/**
|
1529
|
+
* Returns the number of joined members in this room
|
1530
|
+
* This method caches the result.
|
1531
|
+
* This is a wrapper around the method of the same name in roomState, returning
|
1532
|
+
* its result for the room's current state.
|
1533
|
+
* @returns The number of members in this room whose membership is 'join'
|
1534
|
+
*/
|
1535
|
+
getJoinedMemberCount() {
|
1536
|
+
return this.currentState.getJoinedMemberCount();
|
1537
|
+
}
|
1538
|
+
|
1539
|
+
/**
|
1540
|
+
* Returns the number of invited members in this room
|
1541
|
+
* @returns The number of members in this room whose membership is 'invite'
|
1542
|
+
*/
|
1543
|
+
getInvitedMemberCount() {
|
1544
|
+
return this.currentState.getInvitedMemberCount();
|
1545
|
+
}
|
1546
|
+
|
1547
|
+
/**
|
1548
|
+
* Returns the number of invited + joined members in this room
|
1549
|
+
* @returns The number of members in this room whose membership is 'invite' or 'join'
|
1550
|
+
*/
|
1551
|
+
getInvitedAndJoinedMemberCount() {
|
1552
|
+
return this.getInvitedMemberCount() + this.getJoinedMemberCount();
|
1553
|
+
}
|
1554
|
+
|
1555
|
+
/**
|
1556
|
+
* Get a list of members with given membership state.
|
1557
|
+
* @param membership - The membership state.
|
1558
|
+
* @returns A list of members with the given membership state.
|
1559
|
+
*/
|
1560
|
+
getMembersWithMembership(membership) {
|
1561
|
+
return this.currentState.getMembers().filter(function (m) {
|
1562
|
+
return m.membership === membership;
|
1563
|
+
});
|
1564
|
+
}
|
1565
|
+
|
1566
|
+
/**
|
1567
|
+
* Get a list of members we should be encrypting for in this room
|
1568
|
+
* @returns A list of members who
|
1569
|
+
* we should encrypt messages for in this room.
|
1570
|
+
*/
|
1571
|
+
getEncryptionTargetMembers() {
|
1572
|
+
var _this10 = this;
|
1573
|
+
return _asyncToGenerator(function* () {
|
1574
|
+
yield _this10.loadMembersIfNeeded();
|
1575
|
+
var members = _this10.getMembersWithMembership(KnownMembership.Join);
|
1576
|
+
if (_this10.shouldEncryptForInvitedMembers()) {
|
1577
|
+
members = members.concat(_this10.getMembersWithMembership(KnownMembership.Invite));
|
1578
|
+
}
|
1579
|
+
return members;
|
1580
|
+
})();
|
1581
|
+
}
|
1582
|
+
|
1583
|
+
/**
|
1584
|
+
* Determine whether we should encrypt messages for invited users in this room
|
1585
|
+
* @returns if we should encrypt messages for invited users
|
1586
|
+
*/
|
1587
|
+
shouldEncryptForInvitedMembers() {
|
1588
|
+
var _ev$getContent;
|
1589
|
+
var ev = this.currentState.getStateEvents(EventType.RoomHistoryVisibility, "");
|
1590
|
+
return (ev === null || ev === void 0 || (_ev$getContent = ev.getContent()) === null || _ev$getContent === void 0 ? void 0 : _ev$getContent.history_visibility) !== "joined";
|
1591
|
+
}
|
1592
|
+
|
1593
|
+
/**
|
1594
|
+
* Get the default room name (i.e. what a given user would see if the
|
1595
|
+
* room had no m.room.name)
|
1596
|
+
* @param userId - The userId from whose perspective we want
|
1597
|
+
* to calculate the default name
|
1598
|
+
* @returns The default room name
|
1599
|
+
*/
|
1600
|
+
getDefaultRoomName(userId) {
|
1601
|
+
return this.calculateRoomName(userId, true);
|
1602
|
+
}
|
1603
|
+
|
1604
|
+
/**
|
1605
|
+
* Check if the given user_id has the given membership state.
|
1606
|
+
* @param userId - The user ID to check.
|
1607
|
+
* @param membership - The membership e.g. `'join'`
|
1608
|
+
* @returns True if this user_id has the given membership state.
|
1609
|
+
*/
|
1610
|
+
hasMembershipState(userId, membership) {
|
1611
|
+
var member = this.getMember(userId);
|
1612
|
+
if (!member) {
|
1613
|
+
return false;
|
1614
|
+
}
|
1615
|
+
return member.membership === membership;
|
1616
|
+
}
|
1617
|
+
|
1618
|
+
/**
|
1619
|
+
* Add a timelineSet for this room with the given filter
|
1620
|
+
* @param filter - The filter to be applied to this timelineSet
|
1621
|
+
* @param opts - Configuration options
|
1622
|
+
* @returns The timelineSet
|
1623
|
+
*/
|
1624
|
+
getOrCreateFilteredTimelineSet(filter) {
|
1625
|
+
var {
|
1626
|
+
prepopulateTimeline = true,
|
1627
|
+
useSyncEvents = true,
|
1628
|
+
pendingEvents = true
|
1629
|
+
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
1630
|
+
if (this.filteredTimelineSets[filter.filterId]) {
|
1631
|
+
return this.filteredTimelineSets[filter.filterId];
|
1632
|
+
}
|
1633
|
+
var opts = Object.assign({
|
1634
|
+
filter,
|
1635
|
+
pendingEvents
|
1636
|
+
}, this.opts);
|
1637
|
+
var timelineSet = new EventTimelineSet(this, opts);
|
1638
|
+
this.reEmitter.reEmit(timelineSet, [RoomEvent.Timeline, RoomEvent.TimelineReset]);
|
1639
|
+
if (useSyncEvents) {
|
1640
|
+
this.filteredTimelineSets[filter.filterId] = timelineSet;
|
1641
|
+
this.timelineSets.push(timelineSet);
|
1642
|
+
}
|
1643
|
+
var unfilteredLiveTimeline = this.getLiveTimeline();
|
1644
|
+
// Not all filter are possible to replicate client-side only
|
1645
|
+
// When that's the case we do not want to prepopulate from the live timeline
|
1646
|
+
// as we would get incorrect results compared to what the server would send back
|
1647
|
+
if (prepopulateTimeline) {
|
1648
|
+
// populate up the new timelineSet with filtered events from our live
|
1649
|
+
// unfiltered timeline.
|
1650
|
+
//
|
1651
|
+
// XXX: This is risky as our timeline
|
1652
|
+
// may have grown huge and so take a long time to filter.
|
1653
|
+
// see https://github.com/vector-im/vector-web/issues/2109
|
1654
|
+
|
1655
|
+
unfilteredLiveTimeline.getEvents().forEach(function (event) {
|
1656
|
+
timelineSet.addLiveEvent(event);
|
1657
|
+
});
|
1658
|
+
|
1659
|
+
// find the earliest unfiltered timeline
|
1660
|
+
var timeline = unfilteredLiveTimeline;
|
1661
|
+
while (timeline.getNeighbouringTimeline(EventTimeline.BACKWARDS)) {
|
1662
|
+
timeline = timeline.getNeighbouringTimeline(EventTimeline.BACKWARDS);
|
1663
|
+
}
|
1664
|
+
timelineSet.getLiveTimeline().setPaginationToken(timeline.getPaginationToken(EventTimeline.BACKWARDS), EventTimeline.BACKWARDS);
|
1665
|
+
} else if (useSyncEvents) {
|
1666
|
+
var livePaginationToken = unfilteredLiveTimeline.getPaginationToken(Direction.Forward);
|
1667
|
+
timelineSet.getLiveTimeline().setPaginationToken(livePaginationToken, Direction.Backward);
|
1668
|
+
}
|
1669
|
+
|
1670
|
+
// alternatively, we could try to do something like this to try and re-paginate
|
1671
|
+
// in the filtered events from nothing, but Mark says it's an abuse of the API
|
1672
|
+
// to do so:
|
1673
|
+
//
|
1674
|
+
// timelineSet.resetLiveTimeline(
|
1675
|
+
// unfilteredLiveTimeline.getPaginationToken(EventTimeline.FORWARDS)
|
1676
|
+
// );
|
1677
|
+
|
1678
|
+
return timelineSet;
|
1679
|
+
}
|
1680
|
+
getThreadListFilter() {
|
1681
|
+
var _arguments = arguments,
|
1682
|
+
_this11 = this;
|
1683
|
+
return _asyncToGenerator(function* () {
|
1684
|
+
var filterType = _arguments.length > 0 && _arguments[0] !== undefined ? _arguments[0] : ThreadFilterType.All;
|
1685
|
+
var myUserId = _this11.client.getUserId();
|
1686
|
+
var filter = new Filter(myUserId);
|
1687
|
+
var definition = {
|
1688
|
+
room: {
|
1689
|
+
timeline: {
|
1690
|
+
[FILTER_RELATED_BY_REL_TYPES.name]: [THREAD_RELATION_TYPE.name]
|
1691
|
+
}
|
1692
|
+
}
|
1693
|
+
};
|
1694
|
+
if (filterType === ThreadFilterType.My) {
|
1695
|
+
definition.room.timeline[FILTER_RELATED_BY_SENDERS.name] = [myUserId];
|
1696
|
+
}
|
1697
|
+
filter.setDefinition(definition);
|
1698
|
+
var filterId = yield _this11.client.getOrCreateFilter("THREAD_PANEL_".concat(_this11.roomId, "_").concat(filterType), filter);
|
1699
|
+
filter.filterId = filterId;
|
1700
|
+
return filter;
|
1701
|
+
})();
|
1702
|
+
}
|
1703
|
+
createThreadTimelineSet(filterType) {
|
1704
|
+
var _this12 = this;
|
1705
|
+
return _asyncToGenerator(function* () {
|
1706
|
+
var timelineSet;
|
1707
|
+
if (Thread.hasServerSideListSupport) {
|
1708
|
+
timelineSet = new EventTimelineSet(_this12, _objectSpread(_objectSpread({}, _this12.opts), {}, {
|
1709
|
+
pendingEvents: false
|
1710
|
+
}), undefined, undefined, filterType !== null && filterType !== void 0 ? filterType : ThreadFilterType.All);
|
1711
|
+
_this12.reEmitter.reEmit(timelineSet, [RoomEvent.Timeline, RoomEvent.TimelineReset]);
|
1712
|
+
} else if (Thread.hasServerSideSupport) {
|
1713
|
+
var filter = yield _this12.getThreadListFilter(filterType);
|
1714
|
+
timelineSet = _this12.getOrCreateFilteredTimelineSet(filter, {
|
1715
|
+
prepopulateTimeline: false,
|
1716
|
+
useSyncEvents: false,
|
1717
|
+
pendingEvents: false
|
1718
|
+
});
|
1719
|
+
} else {
|
1720
|
+
timelineSet = new EventTimelineSet(_this12, {
|
1721
|
+
pendingEvents: false
|
1722
|
+
});
|
1723
|
+
Array.from(_this12.threads).forEach(_ref3 => {
|
1724
|
+
var [, thread] = _ref3;
|
1725
|
+
if (thread.length === 0) return;
|
1726
|
+
var currentUserParticipated = thread.timeline.some(event => {
|
1727
|
+
return event.getSender() === _this12.client.getUserId();
|
1728
|
+
});
|
1729
|
+
if (filterType !== ThreadFilterType.My || currentUserParticipated) {
|
1730
|
+
timelineSet.getLiveTimeline().addEvent(thread.rootEvent, {
|
1731
|
+
toStartOfTimeline: false
|
1732
|
+
});
|
1733
|
+
}
|
1734
|
+
});
|
1735
|
+
}
|
1736
|
+
return timelineSet;
|
1737
|
+
})();
|
1738
|
+
}
|
1739
|
+
/**
|
1740
|
+
* Takes the given thread root events and creates threads for them.
|
1741
|
+
*/
|
1742
|
+
processThreadRoots(events, toStartOfTimeline) {
|
1743
|
+
if (!this.client.supportsThreads()) return;
|
1744
|
+
for (var rootEvent of events) {
|
1745
|
+
EventTimeline.setEventMetadata(rootEvent, this.currentState, toStartOfTimeline);
|
1746
|
+
if (!this.getThread(rootEvent.getId())) {
|
1747
|
+
this.createThread(rootEvent.getId(), rootEvent, [], toStartOfTimeline);
|
1748
|
+
}
|
1749
|
+
}
|
1750
|
+
}
|
1751
|
+
|
1752
|
+
/**
|
1753
|
+
* Fetch the bare minimum of room threads required for the thread list to work reliably.
|
1754
|
+
* With server support that means fetching one page.
|
1755
|
+
* Without server support that means fetching as much at once as the server allows us to.
|
1756
|
+
*/
|
1757
|
+
fetchRoomThreads() {
|
1758
|
+
var _this13 = this;
|
1759
|
+
return _asyncToGenerator(function* () {
|
1760
|
+
if (_this13.threadsReady || !_this13.client.supportsThreads()) {
|
1761
|
+
return;
|
1762
|
+
}
|
1763
|
+
if (Thread.hasServerSideListSupport) {
|
1764
|
+
yield Promise.all([_this13.fetchRoomThreadList(ThreadFilterType.All), _this13.fetchRoomThreadList(ThreadFilterType.My)]);
|
1765
|
+
} else {
|
1766
|
+
var allThreadsFilter = yield _this13.getThreadListFilter();
|
1767
|
+
var {
|
1768
|
+
chunk: events
|
1769
|
+
} = yield _this13.client.createMessagesRequest(_this13.roomId, "", Number.MAX_SAFE_INTEGER, Direction.Backward, allThreadsFilter);
|
1770
|
+
if (!events.length) return;
|
1771
|
+
|
1772
|
+
// Sorted by last_reply origin_server_ts
|
1773
|
+
var threadRoots = events.map(_this13.client.getEventMapper()).sort((eventA, eventB) => {
|
1774
|
+
/**
|
1775
|
+
* `origin_server_ts` in a decentralised world is far from ideal
|
1776
|
+
* but for lack of any better, we will have to use this
|
1777
|
+
* Long term the sorting should be handled by homeservers and this
|
1778
|
+
* is only meant as a short term patch
|
1779
|
+
*/
|
1780
|
+
var threadAMetadata = eventA.getServerAggregatedRelation(THREAD_RELATION_TYPE.name);
|
1781
|
+
var threadBMetadata = eventB.getServerAggregatedRelation(THREAD_RELATION_TYPE.name);
|
1782
|
+
return threadAMetadata.latest_event.origin_server_ts - threadBMetadata.latest_event.origin_server_ts;
|
1783
|
+
});
|
1784
|
+
var latestMyThreadsRootEvent;
|
1785
|
+
var roomState = _this13.getLiveTimeline().getState(EventTimeline.FORWARDS);
|
1786
|
+
for (var rootEvent of threadRoots) {
|
1787
|
+
var _this13$threadsTimeli;
|
1788
|
+
var _opts = {
|
1789
|
+
duplicateStrategy: DuplicateStrategy.Ignore,
|
1790
|
+
fromCache: false,
|
1791
|
+
roomState
|
1792
|
+
};
|
1793
|
+
(_this13$threadsTimeli = _this13.threadsTimelineSets[0]) === null || _this13$threadsTimeli === void 0 || _this13$threadsTimeli.addLiveEvent(rootEvent, _opts);
|
1794
|
+
var threadRelationship = rootEvent.getServerAggregatedRelation(THREAD_RELATION_TYPE.name);
|
1795
|
+
if (threadRelationship !== null && threadRelationship !== void 0 && threadRelationship.current_user_participated) {
|
1796
|
+
var _this13$threadsTimeli2;
|
1797
|
+
(_this13$threadsTimeli2 = _this13.threadsTimelineSets[1]) === null || _this13$threadsTimeli2 === void 0 || _this13$threadsTimeli2.addLiveEvent(rootEvent, _opts);
|
1798
|
+
latestMyThreadsRootEvent = rootEvent;
|
1799
|
+
}
|
1800
|
+
}
|
1801
|
+
_this13.processThreadRoots(threadRoots, true);
|
1802
|
+
_this13.client.decryptEventIfNeeded(threadRoots[threadRoots.length - 1]);
|
1803
|
+
if (latestMyThreadsRootEvent) {
|
1804
|
+
_this13.client.decryptEventIfNeeded(latestMyThreadsRootEvent);
|
1805
|
+
}
|
1806
|
+
}
|
1807
|
+
_this13.on(ThreadEvent.NewReply, _this13.onThreadReply);
|
1808
|
+
_this13.on(ThreadEvent.Update, _this13.onThreadUpdate);
|
1809
|
+
_this13.on(ThreadEvent.Delete, _this13.onThreadDelete);
|
1810
|
+
_this13.threadsReady = true;
|
1811
|
+
})();
|
1812
|
+
}
|
1813
|
+
|
1814
|
+
/**
|
1815
|
+
* Process a list of poll events.
|
1816
|
+
*
|
1817
|
+
* @param events - List of events
|
1818
|
+
*/
|
1819
|
+
processPollEvents(events) {
|
1820
|
+
var _this14 = this;
|
1821
|
+
return _asyncToGenerator(function* () {
|
1822
|
+
for (var event of events) {
|
1823
|
+
try {
|
1824
|
+
// Continue if the event is a clear text, non-poll event.
|
1825
|
+
if (!event.isEncrypted() && !isPollEvent(event)) continue;
|
1826
|
+
|
1827
|
+
/**
|
1828
|
+
* Try to decrypt the event. Promise resolution does not guarantee a successful decryption.
|
1829
|
+
* Retry is handled in {@link processPollEvent}.
|
1830
|
+
*/
|
1831
|
+
yield _this14.client.decryptEventIfNeeded(event);
|
1832
|
+
_this14.processPollEvent(event);
|
1833
|
+
} catch (err) {
|
1834
|
+
logger.warn("Error processing poll event", event.getId(), err);
|
1835
|
+
}
|
1836
|
+
}
|
1837
|
+
})();
|
1838
|
+
}
|
1839
|
+
|
1840
|
+
/**
|
1841
|
+
* Processes poll events:
|
1842
|
+
* If the event has a decryption failure, it will listen for decryption and tries again.
|
1843
|
+
* If it is a poll start event (`m.poll.start`),
|
1844
|
+
* it creates and stores a Poll model and emits a PollEvent.New event.
|
1845
|
+
* If the event is related to a poll, it will add it to the poll.
|
1846
|
+
* Noop for other cases.
|
1847
|
+
*
|
1848
|
+
* @param event - Event that could be a poll event
|
1849
|
+
*/
|
1850
|
+
processPollEvent(event) {
|
1851
|
+
var _this15 = this;
|
1852
|
+
return _asyncToGenerator(function* () {
|
1853
|
+
if (event.isDecryptionFailure()) {
|
1854
|
+
event.once(MatrixEventEvent.Decrypted, maybeDecryptedEvent => {
|
1855
|
+
_this15.processPollEvent(maybeDecryptedEvent);
|
1856
|
+
});
|
1857
|
+
return;
|
1858
|
+
}
|
1859
|
+
if (M_POLL_START.matches(event.getType())) {
|
1860
|
+
try {
|
1861
|
+
var poll = new Poll(event, _this15.client, _this15);
|
1862
|
+
_this15.polls.set(event.getId(), poll);
|
1863
|
+
_this15.emit(PollEvent.New, poll);
|
1864
|
+
|
1865
|
+
// remove the poll when redacted
|
1866
|
+
event.once(MatrixEventEvent.BeforeRedaction, redactedEvent => {
|
1867
|
+
_this15.polls.delete(redactedEvent.getId());
|
1868
|
+
});
|
1869
|
+
} catch (_unused3) {}
|
1870
|
+
// poll creation can fail for malformed poll start events
|
1871
|
+
return;
|
1872
|
+
}
|
1873
|
+
var relationEventId = event.relationEventId;
|
1874
|
+
if (relationEventId && _this15.polls.has(relationEventId)) {
|
1875
|
+
var _poll = _this15.polls.get(relationEventId);
|
1876
|
+
_poll === null || _poll === void 0 || _poll.onNewRelation(event);
|
1877
|
+
}
|
1878
|
+
})();
|
1879
|
+
}
|
1880
|
+
|
1881
|
+
/**
|
1882
|
+
* Fetch a single page of threadlist messages for the specific thread filter
|
1883
|
+
* @internal
|
1884
|
+
*/
|
1885
|
+
fetchRoomThreadList(filter) {
|
1886
|
+
var _this16 = this;
|
1887
|
+
return _asyncToGenerator(function* () {
|
1888
|
+
if (!_this16.client.supportsThreads()) return;
|
1889
|
+
if (_this16.threadsTimelineSets.length === 0) return;
|
1890
|
+
var timelineSet = filter === ThreadFilterType.My ? _this16.threadsTimelineSets[1] : _this16.threadsTimelineSets[0];
|
1891
|
+
var {
|
1892
|
+
chunk: events,
|
1893
|
+
end
|
1894
|
+
} = yield _this16.client.createThreadListMessagesRequest(_this16.roomId, null, undefined, Direction.Backward, timelineSet.threadListType, timelineSet.getFilter());
|
1895
|
+
timelineSet.getLiveTimeline().setPaginationToken(end !== null && end !== void 0 ? end : null, Direction.Backward);
|
1896
|
+
if (!events.length) return;
|
1897
|
+
var matrixEvents = events.map(_this16.client.getEventMapper());
|
1898
|
+
_this16.processThreadRoots(matrixEvents, true);
|
1899
|
+
var roomState = _this16.getLiveTimeline().getState(EventTimeline.FORWARDS);
|
1900
|
+
for (var rootEvent of matrixEvents) {
|
1901
|
+
timelineSet.addLiveEvent(rootEvent, {
|
1902
|
+
duplicateStrategy: DuplicateStrategy.Replace,
|
1903
|
+
fromCache: false,
|
1904
|
+
roomState
|
1905
|
+
});
|
1906
|
+
}
|
1907
|
+
})();
|
1908
|
+
}
|
1909
|
+
onThreadUpdate(thread) {
|
1910
|
+
this.updateThreadRootEvents(thread, false, false);
|
1911
|
+
}
|
1912
|
+
onThreadReply(thread) {
|
1913
|
+
this.updateThreadRootEvents(thread, false, true);
|
1914
|
+
}
|
1915
|
+
onThreadDelete(thread) {
|
1916
|
+
var _timeline$getEvents;
|
1917
|
+
this.threads.delete(thread.id);
|
1918
|
+
var timeline = this.getTimelineForEvent(thread.id);
|
1919
|
+
var roomEvent = timeline === null || timeline === void 0 || (_timeline$getEvents = timeline.getEvents()) === null || _timeline$getEvents === void 0 ? void 0 : _timeline$getEvents.find(it => it.getId() === thread.id);
|
1920
|
+
if (roomEvent) {
|
1921
|
+
thread.clearEventMetadata(roomEvent);
|
1922
|
+
} else {
|
1923
|
+
logger.debug("onThreadDelete: Could not find root event in room timeline");
|
1924
|
+
}
|
1925
|
+
for (var timelineSet of this.threadsTimelineSets) {
|
1926
|
+
timelineSet.removeEvent(thread.id);
|
1927
|
+
}
|
1928
|
+
}
|
1929
|
+
|
1930
|
+
/**
|
1931
|
+
* Forget the timelineSet for this room with the given filter
|
1932
|
+
*
|
1933
|
+
* @param filter - the filter whose timelineSet is to be forgotten
|
1934
|
+
*/
|
1935
|
+
removeFilteredTimelineSet(filter) {
|
1936
|
+
var timelineSet = this.filteredTimelineSets[filter.filterId];
|
1937
|
+
delete this.filteredTimelineSets[filter.filterId];
|
1938
|
+
var i = this.timelineSets.indexOf(timelineSet);
|
1939
|
+
if (i > -1) {
|
1940
|
+
this.timelineSets.splice(i, 1);
|
1941
|
+
}
|
1942
|
+
}
|
1943
|
+
|
1944
|
+
/**
|
1945
|
+
* Determine which timeline(s) a given event should live in
|
1946
|
+
* Thread roots live in both the main timeline and their corresponding thread timeline
|
1947
|
+
* Relations, redactions, replies to thread relation events live only in the thread timeline
|
1948
|
+
* Relations (other than m.thread), redactions, replies to a thread root live only in the main timeline
|
1949
|
+
* Relations, redactions, replies where the parent cannot be found live in no timelines but should be aggregated regardless.
|
1950
|
+
* Otherwise, the event lives in the main timeline only.
|
1951
|
+
*
|
1952
|
+
* Note: when a redaction is applied, the redacted event, events relating
|
1953
|
+
* to it, and the redaction event itself, will all move to the main thread.
|
1954
|
+
* This method classifies them as inside the thread of the redacted event.
|
1955
|
+
* They are moved later as part of makeRedacted.
|
1956
|
+
* This will change if MSC3389 is merged.
|
1957
|
+
*/
|
1958
|
+
eventShouldLiveIn(event, events, roots) {
|
1959
|
+
var _this$client;
|
1960
|
+
if (!((_this$client = this.client) !== null && _this$client !== void 0 && _this$client.supportsThreads())) {
|
1961
|
+
return {
|
1962
|
+
shouldLiveInRoom: true,
|
1963
|
+
shouldLiveInThread: false
|
1964
|
+
};
|
1965
|
+
}
|
1966
|
+
|
1967
|
+
// A thread root is the only event shown in both timelines
|
1968
|
+
if (event.isThreadRoot || roots !== null && roots !== void 0 && roots.has(event.getId())) {
|
1969
|
+
return {
|
1970
|
+
shouldLiveInRoom: true,
|
1971
|
+
shouldLiveInThread: true,
|
1972
|
+
threadId: event.getId()
|
1973
|
+
};
|
1974
|
+
}
|
1975
|
+
var isThreadRelation = event.isRelation(THREAD_RELATION_TYPE.name);
|
1976
|
+
var parentEventId = event.getAssociatedId();
|
1977
|
+
var threadRootId = event.threadRootId;
|
1978
|
+
|
1979
|
+
// Where the parent is the thread root and this is a non-thread relation this should live only in the main timeline
|
1980
|
+
if (!!parentEventId && !isThreadRelation && (threadRootId === parentEventId || roots !== null && roots !== void 0 && roots.has(parentEventId))) {
|
1981
|
+
return {
|
1982
|
+
shouldLiveInRoom: true,
|
1983
|
+
shouldLiveInThread: false
|
1984
|
+
};
|
1985
|
+
}
|
1986
|
+
var parentEvent;
|
1987
|
+
if (parentEventId) {
|
1988
|
+
var _this$findEventById;
|
1989
|
+
parentEvent = (_this$findEventById = this.findEventById(parentEventId)) !== null && _this$findEventById !== void 0 ? _this$findEventById : events === null || events === void 0 ? void 0 : events.find(e => e.getId() === parentEventId);
|
1990
|
+
}
|
1991
|
+
|
1992
|
+
// Treat non-thread-relations, redactions, and replies as extensions of their parents so evaluate parentEvent instead
|
1993
|
+
if (parentEvent && !isThreadRelation) {
|
1994
|
+
return this.eventShouldLiveIn(parentEvent, events, roots);
|
1995
|
+
}
|
1996
|
+
|
1997
|
+
// A thread relation (1st and 2nd order) is always only shown in a thread
|
1998
|
+
if (threadRootId != undefined) {
|
1999
|
+
return {
|
2000
|
+
shouldLiveInRoom: false,
|
2001
|
+
shouldLiveInThread: true,
|
2002
|
+
threadId: threadRootId
|
2003
|
+
};
|
2004
|
+
}
|
2005
|
+
|
2006
|
+
// Due to replies not being typical relations and being used as fallbacks for threads relations
|
2007
|
+
// If we bypass the if case above then we know we are not a thread, so if we are still a reply
|
2008
|
+
// then we know that we must be in the main timeline. Same goes if we have no associated parent event.
|
2009
|
+
if (!parentEventId || !!event.replyEventId) {
|
2010
|
+
return {
|
2011
|
+
shouldLiveInRoom: true,
|
2012
|
+
shouldLiveInThread: false
|
2013
|
+
};
|
2014
|
+
}
|
2015
|
+
|
2016
|
+
// We've exhausted all scenarios,
|
2017
|
+
// we cannot assume that it lives in the main timeline as this may be a relation for an unknown thread
|
2018
|
+
// adding the event in the wrong timeline causes stuck notifications and can break ability to send read receipts
|
2019
|
+
return {
|
2020
|
+
shouldLiveInRoom: false,
|
2021
|
+
shouldLiveInThread: false
|
2022
|
+
};
|
2023
|
+
}
|
2024
|
+
findThreadForEvent(event) {
|
2025
|
+
if (!event) return null;
|
2026
|
+
var {
|
2027
|
+
threadId
|
2028
|
+
} = this.eventShouldLiveIn(event);
|
2029
|
+
return threadId ? this.getThread(threadId) : null;
|
2030
|
+
}
|
2031
|
+
addThreadedEvents(threadId, events) {
|
2032
|
+
var toStartOfTimeline = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
2033
|
+
var thread = this.getThread(threadId);
|
2034
|
+
if (thread) {
|
2035
|
+
thread.addEvents(events, toStartOfTimeline);
|
2036
|
+
} else {
|
2037
|
+
var _this$findEventById2;
|
2038
|
+
var rootEvent = (_this$findEventById2 = this.findEventById(threadId)) !== null && _this$findEventById2 !== void 0 ? _this$findEventById2 : events.find(e => e.getId() === threadId);
|
2039
|
+
this.createThread(threadId, rootEvent, events, toStartOfTimeline);
|
2040
|
+
}
|
2041
|
+
}
|
2042
|
+
|
2043
|
+
/**
|
2044
|
+
* Adds events to a thread's timeline. Will fire "Thread.update"
|
2045
|
+
*/
|
2046
|
+
processThreadedEvents(events, toStartOfTimeline) {
|
2047
|
+
events.forEach(this.applyRedaction);
|
2048
|
+
var eventsByThread = {};
|
2049
|
+
for (var event of events) {
|
2050
|
+
var _eventsByThread;
|
2051
|
+
var {
|
2052
|
+
threadId,
|
2053
|
+
shouldLiveInThread
|
2054
|
+
} = this.eventShouldLiveIn(event);
|
2055
|
+
if (shouldLiveInThread && !eventsByThread[threadId]) {
|
2056
|
+
eventsByThread[threadId] = [];
|
2057
|
+
}
|
2058
|
+
(_eventsByThread = eventsByThread[threadId]) === null || _eventsByThread === void 0 || _eventsByThread.push(event);
|
2059
|
+
}
|
2060
|
+
Object.entries(eventsByThread).map(_ref4 => {
|
2061
|
+
var [threadId, threadEvents] = _ref4;
|
2062
|
+
return this.addThreadedEvents(threadId, threadEvents, toStartOfTimeline);
|
2063
|
+
});
|
2064
|
+
}
|
2065
|
+
createThread(threadId, rootEvent) {
|
2066
|
+
var _this$cachedThreadRea;
|
2067
|
+
var events = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
2068
|
+
var toStartOfTimeline = arguments.length > 3 ? arguments[3] : undefined;
|
2069
|
+
if (this.threads.has(threadId)) {
|
2070
|
+
return this.threads.get(threadId);
|
2071
|
+
}
|
2072
|
+
if (rootEvent) {
|
2073
|
+
var relatedEvents = this.relations.getAllChildEventsForEvent(rootEvent.getId());
|
2074
|
+
if (relatedEvents !== null && relatedEvents !== void 0 && relatedEvents.length) {
|
2075
|
+
// Include all relations of the root event, given it'll be visible in both timelines,
|
2076
|
+
// except `m.replace` as that will already be applied atop the event using `MatrixEvent::makeReplaced`
|
2077
|
+
events = events.concat(relatedEvents.filter(e => !e.isRelation(RelationType.Replace)));
|
2078
|
+
}
|
2079
|
+
}
|
2080
|
+
var thread = new Thread(threadId, rootEvent, {
|
2081
|
+
room: this,
|
2082
|
+
client: this.client,
|
2083
|
+
pendingEventOrdering: this.opts.pendingEventOrdering,
|
2084
|
+
receipts: (_this$cachedThreadRea = this.cachedThreadReadReceipts.get(threadId)) !== null && _this$cachedThreadRea !== void 0 ? _this$cachedThreadRea : []
|
2085
|
+
});
|
2086
|
+
|
2087
|
+
// Add the re-emitter before we start adding events to the thread so we don't miss events
|
2088
|
+
this.reEmitter.reEmit(thread, [ThreadEvent.Delete, ThreadEvent.Update, ThreadEvent.NewReply, RoomEvent.Timeline, RoomEvent.TimelineReset]);
|
2089
|
+
|
2090
|
+
// All read receipts should now come down from sync, we do not need to keep
|
2091
|
+
// a reference to the cached receipts anymore.
|
2092
|
+
this.cachedThreadReadReceipts.delete(threadId);
|
2093
|
+
|
2094
|
+
// If we managed to create a thread and figure out its `id` then we can use it
|
2095
|
+
// This has to happen before thread.addEvents, because that adds events to the eventtimeline, and the
|
2096
|
+
// eventtimeline sometimes looks up thread information via the room.
|
2097
|
+
this.threads.set(thread.id, thread);
|
2098
|
+
|
2099
|
+
// This is necessary to be able to jump to events in threads:
|
2100
|
+
// If we jump to an event in a thread where neither the event, nor the root,
|
2101
|
+
// nor any thread event are loaded yet, we'll load the event as well as the thread root, create the thread,
|
2102
|
+
// and pass the event through this.
|
2103
|
+
thread.addEvents(events, false);
|
2104
|
+
|
2105
|
+
// We need to update the thread root events, but the thread may not be ready yet.
|
2106
|
+
// If it isn't, it will fire ThreadEvent.Update when it is and we'll call updateThreadRootEvents then.
|
2107
|
+
if (this.threadsReady && thread.initialEventsFetched) {
|
2108
|
+
this.updateThreadRootEvents(thread, toStartOfTimeline, false);
|
2109
|
+
}
|
2110
|
+
this.emit(ThreadEvent.New, thread, toStartOfTimeline);
|
2111
|
+
return thread;
|
2112
|
+
}
|
2113
|
+
processLiveEvent(event) {
|
2114
|
+
this.applyRedaction(event);
|
2115
|
+
|
2116
|
+
// Implement MSC3531: hiding messages.
|
2117
|
+
if (event.isVisibilityEvent()) {
|
2118
|
+
// This event changes the visibility of another event, record
|
2119
|
+
// the visibility change, inform clients if necessary.
|
2120
|
+
this.applyNewVisibilityEvent(event);
|
2121
|
+
}
|
2122
|
+
// If any pending visibility change is waiting for this (older) event,
|
2123
|
+
this.applyPendingVisibilityEvents(event);
|
2124
|
+
|
2125
|
+
// Sliding Sync modifications:
|
2126
|
+
// The proxy cannot guarantee every sent event will have a transaction_id field, so we need
|
2127
|
+
// to check the event ID against the list of pending events if there is no transaction ID
|
2128
|
+
// field. Only do this for events sent by us though as it's potentially expensive to loop
|
2129
|
+
// the pending events map.
|
2130
|
+
var txnId = event.getUnsigned().transaction_id;
|
2131
|
+
if (!txnId && event.getSender() === this.myUserId) {
|
2132
|
+
// check the txn map for a matching event ID
|
2133
|
+
for (var [tid, localEvent] of this.txnToEvent) {
|
2134
|
+
if (localEvent.getId() === event.getId()) {
|
2135
|
+
logger.debug("processLiveEvent: found sent event without txn ID: ", tid, event.getId());
|
2136
|
+
// update the unsigned field so we can re-use the same codepaths
|
2137
|
+
var unsigned = event.getUnsigned();
|
2138
|
+
unsigned.transaction_id = tid;
|
2139
|
+
event.setUnsigned(unsigned);
|
2140
|
+
break;
|
2141
|
+
}
|
2142
|
+
}
|
2143
|
+
}
|
2144
|
+
}
|
2145
|
+
|
2146
|
+
/**
|
2147
|
+
* Add an event to the end of this room's live timelines. Will fire
|
2148
|
+
* "Room.timeline".
|
2149
|
+
*
|
2150
|
+
* @param event - Event to be added
|
2151
|
+
* @param addLiveEventOptions - addLiveEvent options
|
2152
|
+
* @internal
|
2153
|
+
*
|
2154
|
+
* @remarks
|
2155
|
+
* Fires {@link RoomEvent.Timeline}
|
2156
|
+
*/
|
2157
|
+
addLiveEvent(event, addLiveEventOptions) {
|
2158
|
+
var {
|
2159
|
+
duplicateStrategy,
|
2160
|
+
timelineWasEmpty,
|
2161
|
+
fromCache
|
2162
|
+
} = addLiveEventOptions;
|
2163
|
+
|
2164
|
+
// add to our timeline sets
|
2165
|
+
for (var timelineSet of this.timelineSets) {
|
2166
|
+
timelineSet.addLiveEvent(event, {
|
2167
|
+
duplicateStrategy,
|
2168
|
+
fromCache,
|
2169
|
+
timelineWasEmpty
|
2170
|
+
});
|
2171
|
+
}
|
2172
|
+
|
2173
|
+
// synthesize and inject implicit read receipts
|
2174
|
+
// Done after adding the event because otherwise the app would get a read receipt
|
2175
|
+
// pointing to an event that wasn't yet in the timeline
|
2176
|
+
// Don't synthesize RR for m.room.redaction as this causes the RR to go missing.
|
2177
|
+
if (event.sender && event.getType() !== EventType.RoomRedaction) {
|
2178
|
+
this.addReceipt(synthesizeReceipt(event.sender.userId, event, ReceiptType.Read), true);
|
2179
|
+
|
2180
|
+
// Any live events from a user could be taken as implicit
|
2181
|
+
// presence information: evidence that they are currently active.
|
2182
|
+
// ...except in a world where we use 'user.currentlyActive' to reduce
|
2183
|
+
// presence spam, this isn't very useful - we'll get a transition when
|
2184
|
+
// they are no longer currently active anyway. So don't bother to
|
2185
|
+
// reset the lastActiveAgo and lastPresenceTs from the RoomState's user.
|
2186
|
+
}
|
2187
|
+
}
|
2188
|
+
|
2189
|
+
/**
|
2190
|
+
* Add a pending outgoing event to this room.
|
2191
|
+
*
|
2192
|
+
* <p>The event is added to either the pendingEventList, or the live timeline,
|
2193
|
+
* depending on the setting of opts.pendingEventOrdering.
|
2194
|
+
*
|
2195
|
+
* <p>This is an internal method, intended for use by MatrixClient.
|
2196
|
+
*
|
2197
|
+
* @param event - The event to add.
|
2198
|
+
*
|
2199
|
+
* @param txnId - Transaction id for this outgoing event
|
2200
|
+
*
|
2201
|
+
* @throws if the event doesn't have status SENDING, or we aren't given a
|
2202
|
+
* unique transaction id.
|
2203
|
+
*
|
2204
|
+
* @remarks
|
2205
|
+
* Fires {@link RoomEvent.LocalEchoUpdated}
|
2206
|
+
*/
|
2207
|
+
addPendingEvent(event, txnId) {
|
2208
|
+
if (event.status !== EventStatus.SENDING && event.status !== EventStatus.NOT_SENT) {
|
2209
|
+
throw new Error("addPendingEvent called on an event with status " + event.status);
|
2210
|
+
}
|
2211
|
+
if (this.txnToEvent.get(txnId)) {
|
2212
|
+
throw new Error("addPendingEvent called on an event with known txnId " + txnId);
|
2213
|
+
}
|
2214
|
+
|
2215
|
+
// call setEventMetadata to set up event.sender etc
|
2216
|
+
// as event is shared over all timelineSets, we set up its metadata based
|
2217
|
+
// on the unfiltered timelineSet.
|
2218
|
+
EventTimeline.setEventMetadata(event, this.getLiveTimeline().getState(EventTimeline.FORWARDS), false);
|
2219
|
+
this.txnToEvent.set(txnId, event);
|
2220
|
+
if (this.pendingEventList) {
|
2221
|
+
if (this.pendingEventList.some(e => e.status === EventStatus.NOT_SENT)) {
|
2222
|
+
logger.warn("Setting event as NOT_SENT due to messages in the same state");
|
2223
|
+
event.setStatus(EventStatus.NOT_SENT);
|
2224
|
+
}
|
2225
|
+
this.pendingEventList.push(event);
|
2226
|
+
this.savePendingEvents();
|
2227
|
+
if (event.isRelation()) {
|
2228
|
+
// For pending events, add them to the relations collection immediately.
|
2229
|
+
// (The alternate case below already covers this as part of adding to
|
2230
|
+
// the timeline set.)
|
2231
|
+
this.aggregateNonLiveRelation(event);
|
2232
|
+
}
|
2233
|
+
if (event.isRedaction()) {
|
2234
|
+
var redactId = event.event.redacts;
|
2235
|
+
var redactedEvent = this.pendingEventList.find(e => e.getId() === redactId);
|
2236
|
+
if (!redactedEvent && redactId) {
|
2237
|
+
redactedEvent = this.findEventById(redactId);
|
2238
|
+
}
|
2239
|
+
if (redactedEvent) {
|
2240
|
+
redactedEvent.markLocallyRedacted(event);
|
2241
|
+
this.emit(RoomEvent.Redaction, event, this, redactedEvent.threadRootId);
|
2242
|
+
}
|
2243
|
+
}
|
2244
|
+
} else {
|
2245
|
+
for (var timelineSet of this.timelineSets) {
|
2246
|
+
if (timelineSet.getFilter()) {
|
2247
|
+
if (timelineSet.getFilter().filterRoomTimeline([event]).length) {
|
2248
|
+
timelineSet.addEventToTimeline(event, timelineSet.getLiveTimeline(), {
|
2249
|
+
toStartOfTimeline: false
|
2250
|
+
});
|
2251
|
+
}
|
2252
|
+
} else {
|
2253
|
+
timelineSet.addEventToTimeline(event, timelineSet.getLiveTimeline(), {
|
2254
|
+
toStartOfTimeline: false
|
2255
|
+
});
|
2256
|
+
}
|
2257
|
+
}
|
2258
|
+
}
|
2259
|
+
this.emit(RoomEvent.LocalEchoUpdated, event, this);
|
2260
|
+
}
|
2261
|
+
|
2262
|
+
/**
|
2263
|
+
* Persists all pending events to local storage
|
2264
|
+
*
|
2265
|
+
* If the current room is encrypted only encrypted events will be persisted
|
2266
|
+
* all messages that are not yet encrypted will be discarded
|
2267
|
+
*
|
2268
|
+
* This is because the flow of EVENT_STATUS transition is
|
2269
|
+
* `queued => sending => encrypting => sending => sent`
|
2270
|
+
*
|
2271
|
+
* Steps 3 and 4 are skipped for unencrypted room.
|
2272
|
+
* It is better to discard an unencrypted message rather than persisting
|
2273
|
+
* it locally for everyone to read
|
2274
|
+
*/
|
2275
|
+
savePendingEvents() {
|
2276
|
+
if (this.pendingEventList) {
|
2277
|
+
var pendingEvents = this.pendingEventList.map(event => {
|
2278
|
+
return _objectSpread(_objectSpread({}, event.event), {}, {
|
2279
|
+
txn_id: event.getTxnId()
|
2280
|
+
});
|
2281
|
+
}).filter(event => {
|
2282
|
+
// Filter out the unencrypted messages if the room is encrypted
|
2283
|
+
var isEventEncrypted = event.type === EventType.RoomMessageEncrypted;
|
2284
|
+
var isRoomEncrypted = this.hasEncryptionStateEvent();
|
2285
|
+
return isEventEncrypted || !isRoomEncrypted;
|
2286
|
+
});
|
2287
|
+
this.client.store.setPendingEvents(this.roomId, pendingEvents);
|
2288
|
+
}
|
2289
|
+
}
|
2290
|
+
|
2291
|
+
/**
|
2292
|
+
* Used to aggregate the local echo for a relation, and also
|
2293
|
+
* for re-applying a relation after it's redaction has been cancelled,
|
2294
|
+
* as the local echo for the redaction of the relation would have
|
2295
|
+
* un-aggregated the relation. Note that this is different from regular messages,
|
2296
|
+
* which are just kept detached for their local echo.
|
2297
|
+
*
|
2298
|
+
* Also note that live events are aggregated in the live EventTimelineSet.
|
2299
|
+
* @param event - the relation event that needs to be aggregated.
|
2300
|
+
*/
|
2301
|
+
aggregateNonLiveRelation(event) {
|
2302
|
+
this.relations.aggregateChildEvent(event);
|
2303
|
+
}
|
2304
|
+
getEventForTxnId(txnId) {
|
2305
|
+
return this.txnToEvent.get(txnId);
|
2306
|
+
}
|
2307
|
+
|
2308
|
+
/**
|
2309
|
+
* Deal with the echo of a message we sent.
|
2310
|
+
*
|
2311
|
+
* <p>We move the event to the live timeline if it isn't there already, and
|
2312
|
+
* update it.
|
2313
|
+
*
|
2314
|
+
* @param remoteEvent - The event received from
|
2315
|
+
* /sync
|
2316
|
+
* @param localEvent - The local echo, which
|
2317
|
+
* should be either in the pendingEventList or the timeline.
|
2318
|
+
*
|
2319
|
+
* @internal
|
2320
|
+
*
|
2321
|
+
* @remarks
|
2322
|
+
* Fires {@link RoomEvent.LocalEchoUpdated}
|
2323
|
+
*/
|
2324
|
+
handleRemoteEcho(remoteEvent, localEvent) {
|
2325
|
+
var oldEventId = localEvent.getId();
|
2326
|
+
var newEventId = remoteEvent.getId();
|
2327
|
+
var oldStatus = localEvent.status;
|
2328
|
+
logger.debug("Got remote echo for event ".concat(oldEventId, " -> ").concat(newEventId, " old status ").concat(oldStatus));
|
2329
|
+
|
2330
|
+
// no longer pending
|
2331
|
+
this.txnToEvent.delete(remoteEvent.getUnsigned().transaction_id);
|
2332
|
+
|
2333
|
+
// if it's in the pending list, remove it
|
2334
|
+
if (this.pendingEventList) {
|
2335
|
+
this.removePendingEvent(oldEventId);
|
2336
|
+
}
|
2337
|
+
|
2338
|
+
// replace the event source (this will preserve the plaintext payload if
|
2339
|
+
// any, which is good, because we don't want to try decoding it again).
|
2340
|
+
localEvent.handleRemoteEcho(remoteEvent.event);
|
2341
|
+
var {
|
2342
|
+
shouldLiveInRoom,
|
2343
|
+
threadId
|
2344
|
+
} = this.eventShouldLiveIn(remoteEvent);
|
2345
|
+
var thread = threadId ? this.getThread(threadId) : null;
|
2346
|
+
thread === null || thread === void 0 || thread.setEventMetadata(localEvent);
|
2347
|
+
thread === null || thread === void 0 || thread.timelineSet.handleRemoteEcho(localEvent, oldEventId, newEventId);
|
2348
|
+
if (shouldLiveInRoom) {
|
2349
|
+
for (var timelineSet of this.timelineSets) {
|
2350
|
+
// if it's already in the timeline, update the timeline map. If it's not, add it.
|
2351
|
+
timelineSet.handleRemoteEcho(localEvent, oldEventId, newEventId);
|
2352
|
+
}
|
2353
|
+
}
|
2354
|
+
this.emit(RoomEvent.LocalEchoUpdated, localEvent, this, oldEventId, oldStatus);
|
2355
|
+
}
|
2356
|
+
|
2357
|
+
/**
|
2358
|
+
* Update the status / event id on a pending event, to reflect its transmission
|
2359
|
+
* progress.
|
2360
|
+
*
|
2361
|
+
* <p>This is an internal method.
|
2362
|
+
*
|
2363
|
+
* @param event - local echo event
|
2364
|
+
* @param newStatus - status to assign
|
2365
|
+
* @param newEventId - new event id to assign. Ignored unless newStatus == EventStatus.SENT.
|
2366
|
+
*
|
2367
|
+
* @remarks
|
2368
|
+
* Fires {@link RoomEvent.LocalEchoUpdated}
|
2369
|
+
*/
|
2370
|
+
updatePendingEvent(event, newStatus, newEventId) {
|
2371
|
+
logger.log("setting pendingEvent status to ".concat(newStatus, " in ").concat(event.getRoomId(), " ") + "event ID ".concat(event.getId(), " -> ").concat(newEventId));
|
2372
|
+
|
2373
|
+
// if the message was sent, we expect an event id
|
2374
|
+
if (newStatus == EventStatus.SENT && !newEventId) {
|
2375
|
+
throw new Error("updatePendingEvent called with status=SENT, but no new event id");
|
2376
|
+
}
|
2377
|
+
|
2378
|
+
// SENT races against /sync, so we have to special-case it.
|
2379
|
+
if (newStatus == EventStatus.SENT) {
|
2380
|
+
var timeline = this.getTimelineForEvent(newEventId);
|
2381
|
+
if (timeline) {
|
2382
|
+
// we've already received the event via the event stream.
|
2383
|
+
// nothing more to do here, assuming the transaction ID was correctly matched.
|
2384
|
+
// Let's check that.
|
2385
|
+
var remoteEvent = this.findEventById(newEventId);
|
2386
|
+
var remoteTxnId = remoteEvent === null || remoteEvent === void 0 ? void 0 : remoteEvent.getUnsigned().transaction_id;
|
2387
|
+
if (!remoteTxnId && remoteEvent) {
|
2388
|
+
// This code path is mostly relevant for the Sliding Sync proxy.
|
2389
|
+
// The remote event did not contain a transaction ID, so we did not handle
|
2390
|
+
// the remote echo yet. Handle it now.
|
2391
|
+
var unsigned = remoteEvent.getUnsigned();
|
2392
|
+
unsigned.transaction_id = event.getTxnId();
|
2393
|
+
remoteEvent.setUnsigned(unsigned);
|
2394
|
+
// the remote event is _already_ in the timeline, so we need to remove it so
|
2395
|
+
// we can convert the local event into the final event.
|
2396
|
+
this.removeEvent(remoteEvent.getId());
|
2397
|
+
this.handleRemoteEcho(remoteEvent, event);
|
2398
|
+
}
|
2399
|
+
return;
|
2400
|
+
}
|
2401
|
+
}
|
2402
|
+
var oldStatus = event.status;
|
2403
|
+
var oldEventId = event.getId();
|
2404
|
+
if (!oldStatus) {
|
2405
|
+
throw new Error("updatePendingEventStatus called on an event which is not a local echo.");
|
2406
|
+
}
|
2407
|
+
var allowed = ALLOWED_TRANSITIONS[oldStatus];
|
2408
|
+
if (!(allowed !== null && allowed !== void 0 && allowed.includes(newStatus))) {
|
2409
|
+
throw new Error("Invalid EventStatus transition ".concat(oldStatus, "->").concat(newStatus));
|
2410
|
+
}
|
2411
|
+
event.setStatus(newStatus);
|
2412
|
+
if (newStatus == EventStatus.SENT) {
|
2413
|
+
// update the event id
|
2414
|
+
event.replaceLocalEventId(newEventId);
|
2415
|
+
var {
|
2416
|
+
shouldLiveInRoom,
|
2417
|
+
threadId
|
2418
|
+
} = this.eventShouldLiveIn(event);
|
2419
|
+
var thread = threadId ? this.getThread(threadId) : undefined;
|
2420
|
+
thread === null || thread === void 0 || thread.setEventMetadata(event);
|
2421
|
+
thread === null || thread === void 0 || thread.timelineSet.replaceEventId(oldEventId, newEventId);
|
2422
|
+
if (shouldLiveInRoom) {
|
2423
|
+
// if the event was already in the timeline (which will be the case if
|
2424
|
+
// opts.pendingEventOrdering==chronological), we need to update the
|
2425
|
+
// timeline map.
|
2426
|
+
for (var timelineSet of this.timelineSets) {
|
2427
|
+
timelineSet.replaceEventId(oldEventId, newEventId);
|
2428
|
+
}
|
2429
|
+
}
|
2430
|
+
} else if (newStatus == EventStatus.CANCELLED) {
|
2431
|
+
// remove it from the pending event list, or the timeline.
|
2432
|
+
if (this.pendingEventList) {
|
2433
|
+
var removedEvent = this.getPendingEvent(oldEventId);
|
2434
|
+
this.removePendingEvent(oldEventId);
|
2435
|
+
if (removedEvent !== null && removedEvent !== void 0 && removedEvent.isRedaction()) {
|
2436
|
+
this.revertRedactionLocalEcho(removedEvent);
|
2437
|
+
}
|
2438
|
+
}
|
2439
|
+
this.removeEvent(oldEventId);
|
2440
|
+
}
|
2441
|
+
this.savePendingEvents();
|
2442
|
+
this.emit(RoomEvent.LocalEchoUpdated, event, this, oldEventId, oldStatus);
|
2443
|
+
}
|
2444
|
+
revertRedactionLocalEcho(redactionEvent) {
|
2445
|
+
var redactId = redactionEvent.event.redacts;
|
2446
|
+
if (!redactId) {
|
2447
|
+
return;
|
2448
|
+
}
|
2449
|
+
var redactedEvent = this.getUnfilteredTimelineSet().findEventById(redactId);
|
2450
|
+
if (redactedEvent) {
|
2451
|
+
redactedEvent.unmarkLocallyRedacted();
|
2452
|
+
// re-render after undoing redaction
|
2453
|
+
this.emit(RoomEvent.RedactionCancelled, redactionEvent, this);
|
2454
|
+
// reapply relation now redaction failed
|
2455
|
+
if (redactedEvent.isRelation()) {
|
2456
|
+
this.aggregateNonLiveRelation(redactedEvent);
|
2457
|
+
}
|
2458
|
+
}
|
2459
|
+
}
|
2460
|
+
assertTimelineSetsAreLive() {
|
2461
|
+
for (var i = 0; i < this.timelineSets.length; i++) {
|
2462
|
+
var liveTimeline = this.timelineSets[i].getLiveTimeline();
|
2463
|
+
if (liveTimeline.getPaginationToken(EventTimeline.FORWARDS)) {
|
2464
|
+
throw new Error("live timeline " + i + " is no longer live - it has a pagination token " + "(" + liveTimeline.getPaginationToken(EventTimeline.FORWARDS) + ")");
|
2465
|
+
}
|
2466
|
+
if (liveTimeline.getNeighbouringTimeline(EventTimeline.FORWARDS)) {
|
2467
|
+
throw new Error("live timeline ".concat(i, " is no longer live - it has a neighbouring timeline"));
|
2468
|
+
}
|
2469
|
+
}
|
2470
|
+
}
|
2471
|
+
|
2472
|
+
/**
|
2473
|
+
* Add some events to this room. This can include state events, message
|
2474
|
+
* events and typing notifications. These events are treated as "live" so
|
2475
|
+
* they will go to the end of the timeline.
|
2476
|
+
*
|
2477
|
+
* @param events - A list of events to add.
|
2478
|
+
* @param addLiveEventOptions - addLiveEvent options
|
2479
|
+
* @throws If `duplicateStrategy` is not falsey, 'replace' or 'ignore'.
|
2480
|
+
*/
|
2481
|
+
addLiveEvents(events, addLiveEventOptions) {
|
2482
|
+
var _this17 = this;
|
2483
|
+
return _asyncToGenerator(function* () {
|
2484
|
+
var {
|
2485
|
+
duplicateStrategy,
|
2486
|
+
fromCache,
|
2487
|
+
timelineWasEmpty = false
|
2488
|
+
} = addLiveEventOptions !== null && addLiveEventOptions !== void 0 ? addLiveEventOptions : {};
|
2489
|
+
if (duplicateStrategy && ["replace", "ignore"].indexOf(duplicateStrategy) === -1) {
|
2490
|
+
throw new Error("duplicateStrategy MUST be either 'replace' or 'ignore'");
|
2491
|
+
}
|
2492
|
+
|
2493
|
+
// sanity check that the live timeline is still live
|
2494
|
+
_this17.assertTimelineSetsAreLive();
|
2495
|
+
var threadRoots = _this17.findThreadRoots(events);
|
2496
|
+
var eventsByThread = {};
|
2497
|
+
var options = {
|
2498
|
+
duplicateStrategy,
|
2499
|
+
fromCache,
|
2500
|
+
timelineWasEmpty
|
2501
|
+
};
|
2502
|
+
|
2503
|
+
// List of extra events to check for being parents of any relations encountered
|
2504
|
+
var neighbouringEvents = [...events];
|
2505
|
+
for (var event of events) {
|
2506
|
+
var _eventsByThread$threa;
|
2507
|
+
// TODO: We should have a filter to say "only add state event types X Y Z to the timeline".
|
2508
|
+
_this17.processLiveEvent(event);
|
2509
|
+
if (event.getUnsigned().transaction_id) {
|
2510
|
+
var existingEvent = _this17.txnToEvent.get(event.getUnsigned().transaction_id);
|
2511
|
+
if (existingEvent) {
|
2512
|
+
// remote echo of an event we sent earlier
|
2513
|
+
_this17.handleRemoteEcho(event, existingEvent);
|
2514
|
+
continue; // we can skip adding the event to the timeline sets, it is already there
|
2515
|
+
}
|
2516
|
+
}
|
2517
|
+
var {
|
2518
|
+
shouldLiveInRoom,
|
2519
|
+
shouldLiveInThread,
|
2520
|
+
threadId = ""
|
2521
|
+
} = _this17.eventShouldLiveIn(event, neighbouringEvents, threadRoots);
|
2522
|
+
if (!shouldLiveInThread && !shouldLiveInRoom && event.isRelation()) {
|
2523
|
+
try {
|
2524
|
+
var parentEvent = new MatrixEvent(yield _this17.client.fetchRoomEvent(_this17.roomId, event.relationEventId));
|
2525
|
+
neighbouringEvents.push(parentEvent);
|
2526
|
+
if (parentEvent.threadRootId) {
|
2527
|
+
threadRoots.add(parentEvent.threadRootId);
|
2528
|
+
var unsigned = event.getUnsigned();
|
2529
|
+
unsigned[UNSIGNED_THREAD_ID_FIELD.name] = parentEvent.threadRootId;
|
2530
|
+
event.setUnsigned(unsigned);
|
2531
|
+
}
|
2532
|
+
({
|
2533
|
+
shouldLiveInRoom,
|
2534
|
+
shouldLiveInThread,
|
2535
|
+
threadId = ""
|
2536
|
+
} = _this17.eventShouldLiveIn(event, neighbouringEvents, threadRoots));
|
2537
|
+
} catch (e) {
|
2538
|
+
logger.error("Failed to load parent event of unhandled relation", e);
|
2539
|
+
}
|
2540
|
+
}
|
2541
|
+
if (shouldLiveInThread && !eventsByThread[threadId]) {
|
2542
|
+
eventsByThread[threadId] = [];
|
2543
|
+
}
|
2544
|
+
(_eventsByThread$threa = eventsByThread[threadId]) === null || _eventsByThread$threa === void 0 || _eventsByThread$threa.push(event);
|
2545
|
+
if (shouldLiveInRoom) {
|
2546
|
+
_this17.addLiveEvent(event, options);
|
2547
|
+
} else if (!shouldLiveInThread && event.isRelation()) {
|
2548
|
+
_this17.relations.aggregateChildEvent(event);
|
2549
|
+
}
|
2550
|
+
}
|
2551
|
+
Object.entries(eventsByThread).forEach(_ref5 => {
|
2552
|
+
var [threadId, threadEvents] = _ref5;
|
2553
|
+
_this17.addThreadedEvents(threadId, threadEvents, false);
|
2554
|
+
});
|
2555
|
+
})();
|
2556
|
+
}
|
2557
|
+
partitionThreadedEvents(events) {
|
2558
|
+
// Indices to the events array, for readability
|
2559
|
+
var ROOM = 0;
|
2560
|
+
var THREAD = 1;
|
2561
|
+
var UNKNOWN_RELATION = 2;
|
2562
|
+
if (this.client.supportsThreads()) {
|
2563
|
+
var threadRoots = this.findThreadRoots(events);
|
2564
|
+
return events.reduce((memo, event) => {
|
2565
|
+
var {
|
2566
|
+
shouldLiveInRoom,
|
2567
|
+
shouldLiveInThread,
|
2568
|
+
threadId
|
2569
|
+
} = this.eventShouldLiveIn(event, events, threadRoots);
|
2570
|
+
if (shouldLiveInRoom) {
|
2571
|
+
memo[ROOM].push(event);
|
2572
|
+
}
|
2573
|
+
if (shouldLiveInThread) {
|
2574
|
+
event.setThreadId(threadId !== null && threadId !== void 0 ? threadId : "");
|
2575
|
+
memo[THREAD].push(event);
|
2576
|
+
}
|
2577
|
+
if (!shouldLiveInThread && !shouldLiveInRoom) {
|
2578
|
+
memo[UNKNOWN_RELATION].push(event);
|
2579
|
+
}
|
2580
|
+
return memo;
|
2581
|
+
}, [[], [], []]);
|
2582
|
+
} else {
|
2583
|
+
// When `threadSupport` is disabled treat all events as timelineEvents
|
2584
|
+
return [events, [], []];
|
2585
|
+
}
|
2586
|
+
}
|
2587
|
+
|
2588
|
+
/**
|
2589
|
+
* Given some events, find the IDs of all the thread roots that are referred to by them.
|
2590
|
+
*/
|
2591
|
+
findThreadRoots(events) {
|
2592
|
+
var threadRoots = new Set();
|
2593
|
+
for (var event of events) {
|
2594
|
+
var threadRootId = event.threadRootId;
|
2595
|
+
if (threadRootId != undefined) {
|
2596
|
+
threadRoots.add(threadRootId);
|
2597
|
+
}
|
2598
|
+
}
|
2599
|
+
return threadRoots;
|
2600
|
+
}
|
2601
|
+
|
2602
|
+
/**
|
2603
|
+
* Add a receipt event to the room.
|
2604
|
+
* @param event - The m.receipt event.
|
2605
|
+
* @param synthetic - True if this event is implicit.
|
2606
|
+
*/
|
2607
|
+
addReceipt(event) {
|
2608
|
+
var synthetic = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
2609
|
+
var content = event.getContent();
|
2610
|
+
this.roomReceipts.add(content, synthetic);
|
2611
|
+
|
2612
|
+
// TODO: delete the following code when it has been replaced by RoomReceipts
|
2613
|
+
Object.keys(content).forEach(eventId => {
|
2614
|
+
Object.keys(content[eventId]).forEach(receiptType => {
|
2615
|
+
Object.keys(content[eventId][receiptType]).forEach(userId => {
|
2616
|
+
var _receipt$thread_id, _this$unthreadedRecei, _this$unthreadedRecei2;
|
2617
|
+
var receipt = content[eventId][receiptType][userId];
|
2618
|
+
var receiptForMainTimeline = !receipt.thread_id || receipt.thread_id === MAIN_ROOM_TIMELINE;
|
2619
|
+
var receiptDestination = receiptForMainTimeline ? this : this.threads.get((_receipt$thread_id = receipt.thread_id) !== null && _receipt$thread_id !== void 0 ? _receipt$thread_id : "");
|
2620
|
+
if (receiptDestination) {
|
2621
|
+
receiptDestination.addReceiptToStructure(eventId, receiptType, userId, receipt, synthetic);
|
2622
|
+
|
2623
|
+
// If the read receipt sent for the logged in user matches
|
2624
|
+
// the last event of the live timeline, then we know for a fact
|
2625
|
+
// that the user has read that message, so we can mark the room
|
2626
|
+
// as read and not wait for the remote echo from synapse.
|
2627
|
+
//
|
2628
|
+
// This needs to be done after the initial sync as we do not want this
|
2629
|
+
// logic to run whilst the room is being initialised
|
2630
|
+
//
|
2631
|
+
// We only do this for non-synthetic receipts, because
|
2632
|
+
// our intention is to do this when the user really did
|
2633
|
+
// just read a message, not when we are e.g. receiving
|
2634
|
+
// an event during the sync. More explanation at:
|
2635
|
+
// https://github.com/matrix-org/matrix-js-sdk/issues/3684
|
2636
|
+
if (!synthetic && this.client.isInitialSyncComplete() && userId === this.client.getUserId()) {
|
2637
|
+
var lastEvent = receiptDestination.timeline[receiptDestination.timeline.length - 1];
|
2638
|
+
if (lastEvent && eventId === lastEvent.getId() && userId === lastEvent.getSender()) {
|
2639
|
+
receiptDestination.setUnread(NotificationCountType.Total, 0);
|
2640
|
+
receiptDestination.setUnread(NotificationCountType.Highlight, 0);
|
2641
|
+
}
|
2642
|
+
}
|
2643
|
+
} else {
|
2644
|
+
var _this$cachedThreadRea2;
|
2645
|
+
// The thread does not exist locally, keep the read receipt
|
2646
|
+
// in a cache locally, and re-apply the `addReceipt` logic
|
2647
|
+
// when the thread is created
|
2648
|
+
this.cachedThreadReadReceipts.set(receipt.thread_id, [...((_this$cachedThreadRea2 = this.cachedThreadReadReceipts.get(receipt.thread_id)) !== null && _this$cachedThreadRea2 !== void 0 ? _this$cachedThreadRea2 : []), {
|
2649
|
+
eventId,
|
2650
|
+
receiptType,
|
2651
|
+
userId,
|
2652
|
+
receipt,
|
2653
|
+
synthetic
|
2654
|
+
}]);
|
2655
|
+
}
|
2656
|
+
var me = this.client.getUserId();
|
2657
|
+
// Track the time of the current user's oldest threaded receipt in the room.
|
2658
|
+
if (userId === me && !receiptForMainTimeline && receipt.ts < this.oldestThreadedReceiptTs) {
|
2659
|
+
this.oldestThreadedReceiptTs = receipt.ts;
|
2660
|
+
}
|
2661
|
+
|
2662
|
+
// Track each user's unthreaded read receipt.
|
2663
|
+
if (!receipt.thread_id && receipt.ts > ((_this$unthreadedRecei = (_this$unthreadedRecei2 = this.unthreadedReceipts.get(userId)) === null || _this$unthreadedRecei2 === void 0 ? void 0 : _this$unthreadedRecei2.ts) !== null && _this$unthreadedRecei !== void 0 ? _this$unthreadedRecei : 0)) {
|
2664
|
+
this.unthreadedReceipts.set(userId, receipt);
|
2665
|
+
}
|
2666
|
+
});
|
2667
|
+
});
|
2668
|
+
});
|
2669
|
+
// End of code to delete when replaced by RoomReceipts
|
2670
|
+
|
2671
|
+
// send events after we've regenerated the structure & cache, otherwise things that
|
2672
|
+
// listened for the event would read stale data.
|
2673
|
+
this.emit(RoomEvent.Receipt, event, this);
|
2674
|
+
}
|
2675
|
+
|
2676
|
+
/**
|
2677
|
+
* Adds/handles ephemeral events such as typing notifications and read receipts.
|
2678
|
+
* @param events - A list of events to process
|
2679
|
+
*/
|
2680
|
+
addEphemeralEvents(events) {
|
2681
|
+
for (var event of events) {
|
2682
|
+
if (event.getType() === EventType.Typing) {
|
2683
|
+
this.currentState.setTypingEvent(event);
|
2684
|
+
} else if (event.getType() === EventType.Receipt) {
|
2685
|
+
this.addReceipt(event);
|
2686
|
+
} // else ignore - life is too short for us to care about these events
|
2687
|
+
}
|
2688
|
+
}
|
2689
|
+
|
2690
|
+
/**
|
2691
|
+
* Removes events from this room.
|
2692
|
+
* @param eventIds - A list of eventIds to remove.
|
2693
|
+
*/
|
2694
|
+
removeEvents(eventIds) {
|
2695
|
+
for (var eventId of eventIds) {
|
2696
|
+
this.removeEvent(eventId);
|
2697
|
+
}
|
2698
|
+
}
|
2699
|
+
|
2700
|
+
/**
|
2701
|
+
* Removes a single event from this room.
|
2702
|
+
*
|
2703
|
+
* @param eventId - The id of the event to remove
|
2704
|
+
*
|
2705
|
+
* @returns true if the event was removed from any of the room's timeline sets
|
2706
|
+
*/
|
2707
|
+
removeEvent(eventId) {
|
2708
|
+
var removedAny = false;
|
2709
|
+
for (var timelineSet of this.timelineSets) {
|
2710
|
+
var removed = timelineSet.removeEvent(eventId);
|
2711
|
+
if (removed) {
|
2712
|
+
if (removed.isRedaction()) {
|
2713
|
+
this.revertRedactionLocalEcho(removed);
|
2714
|
+
}
|
2715
|
+
removedAny = true;
|
2716
|
+
}
|
2717
|
+
}
|
2718
|
+
return removedAny;
|
2719
|
+
}
|
2720
|
+
|
2721
|
+
/**
|
2722
|
+
* Recalculate various aspects of the room, including the room name and
|
2723
|
+
* room summary. Call this any time the room's current state is modified.
|
2724
|
+
* May fire "Room.name" if the room name is updated.
|
2725
|
+
*
|
2726
|
+
* @remarks
|
2727
|
+
* Fires {@link RoomEvent.Name}
|
2728
|
+
*/
|
2729
|
+
recalculate() {
|
2730
|
+
// set fake stripped state events if this is an invite room so logic remains
|
2731
|
+
// consistent elsewhere.
|
2732
|
+
var membershipEvent = this.currentState.getStateEvents(EventType.RoomMember, this.myUserId);
|
2733
|
+
if (membershipEvent) {
|
2734
|
+
var membership = membershipEvent.getContent().membership;
|
2735
|
+
this.updateMyMembership(membership);
|
2736
|
+
if (membership === KnownMembership.Invite) {
|
2737
|
+
var strippedStateEvents = membershipEvent.getUnsigned().invite_room_state || [];
|
2738
|
+
strippedStateEvents.forEach(strippedEvent => {
|
2739
|
+
var existingEvent = this.currentState.getStateEvents(strippedEvent.type, strippedEvent.state_key);
|
2740
|
+
if (!existingEvent) {
|
2741
|
+
// set the fake stripped event instead
|
2742
|
+
this.currentState.setStateEvents([new MatrixEvent({
|
2743
|
+
type: strippedEvent.type,
|
2744
|
+
state_key: strippedEvent.state_key,
|
2745
|
+
content: strippedEvent.content,
|
2746
|
+
event_id: "$fake" + Date.now(),
|
2747
|
+
room_id: this.roomId,
|
2748
|
+
sender: this.myUserId // technically a lie
|
2749
|
+
})]);
|
2750
|
+
}
|
2751
|
+
});
|
2752
|
+
}
|
2753
|
+
}
|
2754
|
+
var oldName = this.name;
|
2755
|
+
this.name = this.calculateRoomName(this.myUserId);
|
2756
|
+
this.normalizedName = normalize(this.name);
|
2757
|
+
this.summary = new RoomSummary(this.roomId, {
|
2758
|
+
title: this.name
|
2759
|
+
});
|
2760
|
+
if (oldName !== this.name) {
|
2761
|
+
this.emit(RoomEvent.Name, this);
|
2762
|
+
}
|
2763
|
+
}
|
2764
|
+
|
2765
|
+
/**
|
2766
|
+
* Update the room-tag event for the room. The previous one is overwritten.
|
2767
|
+
* @param event - the m.tag event
|
2768
|
+
*/
|
2769
|
+
addTags(event) {
|
2770
|
+
// event content looks like:
|
2771
|
+
// content: {
|
2772
|
+
// tags: {
|
2773
|
+
// $tagName: { $metadata: $value },
|
2774
|
+
// $tagName: { $metadata: $value },
|
2775
|
+
// }
|
2776
|
+
// }
|
2777
|
+
|
2778
|
+
// XXX: do we need to deep copy here?
|
2779
|
+
this.tags = event.getContent().tags || {};
|
2780
|
+
|
2781
|
+
// XXX: we could do a deep-comparison to see if the tags have really
|
2782
|
+
// changed - but do we want to bother?
|
2783
|
+
this.emit(RoomEvent.Tags, event, this);
|
2784
|
+
}
|
2785
|
+
|
2786
|
+
/**
|
2787
|
+
* Update the account_data events for this room, overwriting events of the same type.
|
2788
|
+
* @param events - an array of account_data events to add
|
2789
|
+
*/
|
2790
|
+
addAccountData(events) {
|
2791
|
+
for (var event of events) {
|
2792
|
+
if (event.getType() === "m.tag") {
|
2793
|
+
this.addTags(event);
|
2794
|
+
}
|
2795
|
+
var eventType = event.getType();
|
2796
|
+
var lastEvent = this.accountData.get(eventType);
|
2797
|
+
this.accountData.set(eventType, event);
|
2798
|
+
this.emit(RoomEvent.AccountData, event, this, lastEvent);
|
2799
|
+
}
|
2800
|
+
}
|
2801
|
+
|
2802
|
+
/**
|
2803
|
+
* Access account_data event of given event type for this room
|
2804
|
+
* @param type - the type of account_data event to be accessed
|
2805
|
+
* @returns the account_data event in question
|
2806
|
+
*/
|
2807
|
+
getAccountData(type) {
|
2808
|
+
return this.accountData.get(type);
|
2809
|
+
}
|
2810
|
+
|
2811
|
+
/**
|
2812
|
+
* Returns whether the syncing user has permission to send a message in the room
|
2813
|
+
* @returns true if the user should be permitted to send
|
2814
|
+
* message events into the room.
|
2815
|
+
*/
|
2816
|
+
maySendMessage() {
|
2817
|
+
return this.getMyMembership() === KnownMembership.Join && (this.hasEncryptionStateEvent() ? this.currentState.maySendEvent(EventType.RoomMessageEncrypted, this.myUserId) : this.currentState.maySendEvent(EventType.RoomMessage, this.myUserId));
|
2818
|
+
}
|
2819
|
+
|
2820
|
+
/**
|
2821
|
+
* Returns whether the given user has permissions to issue an invite for this room.
|
2822
|
+
* @param userId - the ID of the Matrix user to check permissions for
|
2823
|
+
* @returns true if the user should be permitted to issue invites for this room.
|
2824
|
+
*/
|
2825
|
+
canInvite(userId) {
|
2826
|
+
var canInvite = this.getMyMembership() === KnownMembership.Join;
|
2827
|
+
var powerLevelsEvent = this.currentState.getStateEvents(EventType.RoomPowerLevels, "");
|
2828
|
+
var powerLevels = powerLevelsEvent && powerLevelsEvent.getContent();
|
2829
|
+
var me = this.getMember(userId);
|
2830
|
+
if (powerLevels && me && powerLevels.invite > me.powerLevel) {
|
2831
|
+
canInvite = false;
|
2832
|
+
}
|
2833
|
+
return canInvite;
|
2834
|
+
}
|
2835
|
+
|
2836
|
+
/**
|
2837
|
+
* Returns the join rule based on the m.room.join_rule state event, defaulting to `invite`.
|
2838
|
+
* @returns the join_rule applied to this room
|
2839
|
+
*/
|
2840
|
+
getJoinRule() {
|
2841
|
+
return this.currentState.getJoinRule();
|
2842
|
+
}
|
2843
|
+
|
2844
|
+
/**
|
2845
|
+
* Returns the history visibility based on the m.room.history_visibility state event, defaulting to `shared`.
|
2846
|
+
* @returns the history_visibility applied to this room
|
2847
|
+
*/
|
2848
|
+
getHistoryVisibility() {
|
2849
|
+
return this.currentState.getHistoryVisibility();
|
2850
|
+
}
|
2851
|
+
|
2852
|
+
/**
|
2853
|
+
* Returns the history visibility based on the m.room.history_visibility state event, defaulting to `shared`.
|
2854
|
+
* @returns the history_visibility applied to this room
|
2855
|
+
*/
|
2856
|
+
getGuestAccess() {
|
2857
|
+
return this.currentState.getGuestAccess();
|
2858
|
+
}
|
2859
|
+
|
2860
|
+
/**
|
2861
|
+
* Returns the type of the room from the `m.room.create` event content or undefined if none is set
|
2862
|
+
* @returns the type of the room.
|
2863
|
+
*/
|
2864
|
+
getType() {
|
2865
|
+
var createEvent = this.currentState.getStateEvents(EventType.RoomCreate, "");
|
2866
|
+
if (!createEvent) {
|
2867
|
+
if (!this.getTypeWarning) {
|
2868
|
+
logger.warn("[getType] Room " + this.roomId + " does not have an m.room.create event");
|
2869
|
+
this.getTypeWarning = true;
|
2870
|
+
}
|
2871
|
+
return undefined;
|
2872
|
+
}
|
2873
|
+
return createEvent.getContent()[RoomCreateTypeField];
|
2874
|
+
}
|
2875
|
+
|
2876
|
+
/**
|
2877
|
+
* Returns whether the room is a space-room as defined by MSC1772.
|
2878
|
+
* @returns true if the room's type is RoomType.Space
|
2879
|
+
*/
|
2880
|
+
isSpaceRoom() {
|
2881
|
+
return this.getType() === RoomType.Space;
|
2882
|
+
}
|
2883
|
+
|
2884
|
+
/**
|
2885
|
+
* Returns whether the room is a call-room as defined by MSC3417.
|
2886
|
+
* @returns true if the room's type is RoomType.UnstableCall
|
2887
|
+
*/
|
2888
|
+
isCallRoom() {
|
2889
|
+
return this.getType() === RoomType.UnstableCall;
|
2890
|
+
}
|
2891
|
+
|
2892
|
+
/**
|
2893
|
+
* Returns whether the room is a video room.
|
2894
|
+
* @returns true if the room's type is RoomType.ElementVideo
|
2895
|
+
*/
|
2896
|
+
isElementVideoRoom() {
|
2897
|
+
return this.getType() === RoomType.ElementVideo;
|
2898
|
+
}
|
2899
|
+
|
2900
|
+
/**
|
2901
|
+
* Find the predecessor of this room.
|
2902
|
+
*
|
2903
|
+
* @param msc3946ProcessDynamicPredecessor - if true, look for an
|
2904
|
+
* m.room.predecessor state event and use it if found (MSC3946).
|
2905
|
+
* @returns null if this room has no predecessor. Otherwise, returns
|
2906
|
+
* the roomId, last eventId and viaServers of the predecessor room.
|
2907
|
+
*
|
2908
|
+
* If msc3946ProcessDynamicPredecessor is true, use m.predecessor events
|
2909
|
+
* as well as m.room.create events to find predecessors.
|
2910
|
+
*
|
2911
|
+
* Note: if an m.predecessor event is used, eventId may be undefined
|
2912
|
+
* since last_known_event_id is optional.
|
2913
|
+
*
|
2914
|
+
* Note: viaServers may be undefined, and will definitely be undefined if
|
2915
|
+
* this predecessor comes from a RoomCreate event (rather than a
|
2916
|
+
* RoomPredecessor, which has the optional via_servers property).
|
2917
|
+
*/
|
2918
|
+
findPredecessor() {
|
2919
|
+
var msc3946ProcessDynamicPredecessor = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
2920
|
+
var currentState = this.getLiveTimeline().getState(EventTimeline.FORWARDS);
|
2921
|
+
if (!currentState) {
|
2922
|
+
return null;
|
2923
|
+
}
|
2924
|
+
return currentState.findPredecessor(msc3946ProcessDynamicPredecessor);
|
2925
|
+
}
|
2926
|
+
roomNameGenerator(state) {
|
2927
|
+
if (this.client.roomNameGenerator) {
|
2928
|
+
var name = this.client.roomNameGenerator(this.roomId, state);
|
2929
|
+
if (name !== null) {
|
2930
|
+
return name;
|
2931
|
+
}
|
2932
|
+
}
|
2933
|
+
switch (state.type) {
|
2934
|
+
case RoomNameType.Actual:
|
2935
|
+
return state.name;
|
2936
|
+
case RoomNameType.Generated:
|
2937
|
+
switch (state.subtype) {
|
2938
|
+
case "Inviting":
|
2939
|
+
return "Inviting ".concat(memberNamesToRoomName(state.names, state.count));
|
2940
|
+
default:
|
2941
|
+
return memberNamesToRoomName(state.names, state.count);
|
2942
|
+
}
|
2943
|
+
case RoomNameType.EmptyRoom:
|
2944
|
+
if (state.oldName) {
|
2945
|
+
return "Empty room (was ".concat(state.oldName, ")");
|
2946
|
+
} else {
|
2947
|
+
return "Empty room";
|
2948
|
+
}
|
2949
|
+
}
|
2950
|
+
}
|
2951
|
+
|
2952
|
+
/**
|
2953
|
+
* This is an internal method. Calculates the name of the room from the current
|
2954
|
+
* room state.
|
2955
|
+
* @param userId - The client's user ID. Used to filter room members
|
2956
|
+
* correctly.
|
2957
|
+
* @param ignoreRoomNameEvent - Return the implicit room name that we'd see if there
|
2958
|
+
* was no m.room.name event.
|
2959
|
+
* @returns The calculated room name.
|
2960
|
+
*/
|
2961
|
+
calculateRoomName(userId) {
|
2962
|
+
var ignoreRoomNameEvent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
2963
|
+
if (!ignoreRoomNameEvent) {
|
2964
|
+
// check for an alias, if any. for now, assume first alias is the
|
2965
|
+
// official one.
|
2966
|
+
var mRoomName = this.currentState.getStateEvents(EventType.RoomName, "");
|
2967
|
+
if (mRoomName !== null && mRoomName !== void 0 && mRoomName.getContent().name) {
|
2968
|
+
return this.roomNameGenerator({
|
2969
|
+
type: RoomNameType.Actual,
|
2970
|
+
name: mRoomName.getContent().name
|
2971
|
+
});
|
2972
|
+
}
|
2973
|
+
}
|
2974
|
+
var alias = this.getCanonicalAlias();
|
2975
|
+
if (alias) {
|
2976
|
+
return this.roomNameGenerator({
|
2977
|
+
type: RoomNameType.Actual,
|
2978
|
+
name: alias
|
2979
|
+
});
|
2980
|
+
}
|
2981
|
+
var joinedMemberCount = this.currentState.getJoinedMemberCount();
|
2982
|
+
var invitedMemberCount = this.currentState.getInvitedMemberCount();
|
2983
|
+
// -1 because these numbers include the syncing user
|
2984
|
+
var inviteJoinCount = joinedMemberCount + invitedMemberCount - 1;
|
2985
|
+
|
2986
|
+
// get service members (e.g. helper bots) for exclusion
|
2987
|
+
var excludedUserIds = this.getFunctionalMembers();
|
2988
|
+
|
2989
|
+
// get members that are NOT ourselves and are actually in the room.
|
2990
|
+
var otherNames = [];
|
2991
|
+
if (this.summaryHeroes) {
|
2992
|
+
// if we have a summary, the member state events should be in the room state
|
2993
|
+
this.summaryHeroes.forEach(userId => {
|
2994
|
+
// filter service members
|
2995
|
+
if (excludedUserIds.includes(userId)) {
|
2996
|
+
inviteJoinCount--;
|
2997
|
+
return;
|
2998
|
+
}
|
2999
|
+
var member = this.getMember(userId);
|
3000
|
+
otherNames.push(member ? member.name : userId);
|
3001
|
+
});
|
3002
|
+
} else {
|
3003
|
+
var otherMembers = this.currentState.getMembers().filter(m => {
|
3004
|
+
return m.userId !== userId && (m.membership === KnownMembership.Invite || m.membership === KnownMembership.Join);
|
3005
|
+
});
|
3006
|
+
otherMembers = otherMembers.filter(_ref6 => {
|
3007
|
+
var {
|
3008
|
+
userId
|
3009
|
+
} = _ref6;
|
3010
|
+
// filter service members
|
3011
|
+
if (excludedUserIds.includes(userId)) {
|
3012
|
+
inviteJoinCount--;
|
3013
|
+
return false;
|
3014
|
+
}
|
3015
|
+
return true;
|
3016
|
+
});
|
3017
|
+
// make sure members have stable order
|
3018
|
+
var collator = new Intl.Collator();
|
3019
|
+
otherMembers.sort((a, b) => collator.compare(a.userId, b.userId));
|
3020
|
+
// only 5 first members, immitate summaryHeroes
|
3021
|
+
otherMembers = otherMembers.slice(0, 5);
|
3022
|
+
otherNames = otherMembers.map(m => m.name);
|
3023
|
+
}
|
3024
|
+
if (inviteJoinCount) {
|
3025
|
+
return this.roomNameGenerator({
|
3026
|
+
type: RoomNameType.Generated,
|
3027
|
+
names: otherNames,
|
3028
|
+
count: inviteJoinCount
|
3029
|
+
});
|
3030
|
+
}
|
3031
|
+
var myMembership = this.getMyMembership();
|
3032
|
+
// if I have created a room and invited people through
|
3033
|
+
// 3rd party invites
|
3034
|
+
if (myMembership == KnownMembership.Join) {
|
3035
|
+
var thirdPartyInvites = this.currentState.getStateEvents(EventType.RoomThirdPartyInvite);
|
3036
|
+
if (thirdPartyInvites !== null && thirdPartyInvites !== void 0 && thirdPartyInvites.length) {
|
3037
|
+
var thirdPartyNames = thirdPartyInvites.map(i => {
|
3038
|
+
return i.getContent().display_name;
|
3039
|
+
});
|
3040
|
+
return this.roomNameGenerator({
|
3041
|
+
type: RoomNameType.Generated,
|
3042
|
+
subtype: "Inviting",
|
3043
|
+
names: thirdPartyNames,
|
3044
|
+
count: thirdPartyNames.length + 1
|
3045
|
+
});
|
3046
|
+
}
|
3047
|
+
}
|
3048
|
+
|
3049
|
+
// let's try to figure out who was here before
|
3050
|
+
var leftNames = otherNames;
|
3051
|
+
// if we didn't have heroes, try finding them in the room state
|
3052
|
+
if (!leftNames.length) {
|
3053
|
+
leftNames = this.currentState.getMembers().filter(m => {
|
3054
|
+
return m.userId !== userId && m.membership !== KnownMembership.Invite && m.membership !== KnownMembership.Join;
|
3055
|
+
}).map(m => m.name);
|
3056
|
+
}
|
3057
|
+
var oldName;
|
3058
|
+
if (leftNames.length) {
|
3059
|
+
oldName = this.roomNameGenerator({
|
3060
|
+
type: RoomNameType.Generated,
|
3061
|
+
names: leftNames,
|
3062
|
+
count: leftNames.length + 1
|
3063
|
+
});
|
3064
|
+
}
|
3065
|
+
return this.roomNameGenerator({
|
3066
|
+
type: RoomNameType.EmptyRoom,
|
3067
|
+
oldName
|
3068
|
+
});
|
3069
|
+
}
|
3070
|
+
|
3071
|
+
/**
|
3072
|
+
* When we receive a new visibility change event:
|
3073
|
+
*
|
3074
|
+
* - store this visibility change alongside the timeline, in case we
|
3075
|
+
* later need to apply it to an event that we haven't received yet;
|
3076
|
+
* - if we have already received the event whose visibility has changed,
|
3077
|
+
* patch it to reflect the visibility change and inform listeners.
|
3078
|
+
*/
|
3079
|
+
applyNewVisibilityEvent(event) {
|
3080
|
+
var visibilityChange = event.asVisibilityChange();
|
3081
|
+
if (!visibilityChange) {
|
3082
|
+
// The event is ill-formed.
|
3083
|
+
return;
|
3084
|
+
}
|
3085
|
+
|
3086
|
+
// Ignore visibility change events that are not emitted by moderators.
|
3087
|
+
var userId = event.getSender();
|
3088
|
+
if (!userId) {
|
3089
|
+
return;
|
3090
|
+
}
|
3091
|
+
var isPowerSufficient = EVENT_VISIBILITY_CHANGE_TYPE.name && this.currentState.maySendStateEvent(EVENT_VISIBILITY_CHANGE_TYPE.name, userId) || EVENT_VISIBILITY_CHANGE_TYPE.altName && this.currentState.maySendStateEvent(EVENT_VISIBILITY_CHANGE_TYPE.altName, userId);
|
3092
|
+
if (!isPowerSufficient) {
|
3093
|
+
// Powerlevel is insufficient.
|
3094
|
+
return;
|
3095
|
+
}
|
3096
|
+
|
3097
|
+
// Record this change in visibility.
|
3098
|
+
// If the event is not in our timeline and we only receive it later,
|
3099
|
+
// we may need to apply the visibility change at a later date.
|
3100
|
+
|
3101
|
+
var visibilityEventsOnOriginalEvent = this.visibilityEvents.get(visibilityChange.eventId);
|
3102
|
+
if (visibilityEventsOnOriginalEvent) {
|
3103
|
+
// It would be tempting to simply erase the latest visibility change
|
3104
|
+
// but we need to record all of the changes in case the latest change
|
3105
|
+
// is ever redacted.
|
3106
|
+
//
|
3107
|
+
// In practice, linear scans through `visibilityEvents` should be fast.
|
3108
|
+
// However, to protect against a potential DoS attack, we limit the
|
3109
|
+
// number of iterations in this loop.
|
3110
|
+
var index = visibilityEventsOnOriginalEvent.length - 1;
|
3111
|
+
var min = Math.max(0, visibilityEventsOnOriginalEvent.length - MAX_NUMBER_OF_VISIBILITY_EVENTS_TO_SCAN_THROUGH);
|
3112
|
+
for (; index >= min; --index) {
|
3113
|
+
var target = visibilityEventsOnOriginalEvent[index];
|
3114
|
+
if (target.getTs() < event.getTs()) {
|
3115
|
+
break;
|
3116
|
+
}
|
3117
|
+
}
|
3118
|
+
if (index === -1) {
|
3119
|
+
visibilityEventsOnOriginalEvent.unshift(event);
|
3120
|
+
} else {
|
3121
|
+
visibilityEventsOnOriginalEvent.splice(index + 1, 0, event);
|
3122
|
+
}
|
3123
|
+
} else {
|
3124
|
+
this.visibilityEvents.set(visibilityChange.eventId, [event]);
|
3125
|
+
}
|
3126
|
+
|
3127
|
+
// Finally, let's check if the event is already in our timeline.
|
3128
|
+
// If so, we need to patch it and inform listeners.
|
3129
|
+
|
3130
|
+
var originalEvent = this.findEventById(visibilityChange.eventId);
|
3131
|
+
if (!originalEvent) {
|
3132
|
+
return;
|
3133
|
+
}
|
3134
|
+
originalEvent.applyVisibilityEvent(visibilityChange);
|
3135
|
+
}
|
3136
|
+
redactVisibilityChangeEvent(event) {
|
3137
|
+
// Sanity checks.
|
3138
|
+
if (!event.isVisibilityEvent) {
|
3139
|
+
throw new Error("expected a visibility change event");
|
3140
|
+
}
|
3141
|
+
var relation = event.getRelation();
|
3142
|
+
var originalEventId = relation === null || relation === void 0 ? void 0 : relation.event_id;
|
3143
|
+
var visibilityEventsOnOriginalEvent = this.visibilityEvents.get(originalEventId);
|
3144
|
+
if (!visibilityEventsOnOriginalEvent) {
|
3145
|
+
// No visibility changes on the original event.
|
3146
|
+
// In particular, this change event was not recorded,
|
3147
|
+
// most likely because it was ill-formed.
|
3148
|
+
return;
|
3149
|
+
}
|
3150
|
+
var index = visibilityEventsOnOriginalEvent.findIndex(change => change.getId() === event.getId());
|
3151
|
+
if (index === -1) {
|
3152
|
+
// This change event was not recorded, most likely because
|
3153
|
+
// it was ill-formed.
|
3154
|
+
return;
|
3155
|
+
}
|
3156
|
+
// Remove visibility change.
|
3157
|
+
visibilityEventsOnOriginalEvent.splice(index, 1);
|
3158
|
+
|
3159
|
+
// If we removed the latest visibility change event, propagate changes.
|
3160
|
+
if (index === visibilityEventsOnOriginalEvent.length) {
|
3161
|
+
var originalEvent = this.findEventById(originalEventId);
|
3162
|
+
if (!originalEvent) {
|
3163
|
+
return;
|
3164
|
+
}
|
3165
|
+
if (index === 0) {
|
3166
|
+
// We have just removed the only visibility change event.
|
3167
|
+
this.visibilityEvents.delete(originalEventId);
|
3168
|
+
originalEvent.applyVisibilityEvent();
|
3169
|
+
} else {
|
3170
|
+
var newEvent = visibilityEventsOnOriginalEvent[visibilityEventsOnOriginalEvent.length - 1];
|
3171
|
+
var newVisibility = newEvent.asVisibilityChange();
|
3172
|
+
if (!newVisibility) {
|
3173
|
+
// Event is ill-formed.
|
3174
|
+
// This breaks our invariant.
|
3175
|
+
throw new Error("at this stage, visibility changes should be well-formed");
|
3176
|
+
}
|
3177
|
+
originalEvent.applyVisibilityEvent(newVisibility);
|
3178
|
+
}
|
3179
|
+
}
|
3180
|
+
}
|
3181
|
+
|
3182
|
+
/**
|
3183
|
+
* When we receive an event whose visibility has been altered by
|
3184
|
+
* a (more recent) visibility change event, patch the event in
|
3185
|
+
* place so that clients now not to display it.
|
3186
|
+
*
|
3187
|
+
* @param event - Any matrix event. If this event has at least one a
|
3188
|
+
* pending visibility change event, apply the latest visibility
|
3189
|
+
* change event.
|
3190
|
+
*/
|
3191
|
+
applyPendingVisibilityEvents(event) {
|
3192
|
+
var visibilityEvents = this.visibilityEvents.get(event.getId());
|
3193
|
+
if (!visibilityEvents || visibilityEvents.length == 0) {
|
3194
|
+
// No pending visibility change in store.
|
3195
|
+
return;
|
3196
|
+
}
|
3197
|
+
var visibilityEvent = visibilityEvents[visibilityEvents.length - 1];
|
3198
|
+
var visibilityChange = visibilityEvent.asVisibilityChange();
|
3199
|
+
if (!visibilityChange) {
|
3200
|
+
return;
|
3201
|
+
}
|
3202
|
+
if (visibilityChange.visible) {
|
3203
|
+
// Events are visible by default, no need to apply a visibility change.
|
3204
|
+
// Note that we need to keep the visibility changes in `visibilityEvents`,
|
3205
|
+
// in case we later fetch an older visibility change event that is superseded
|
3206
|
+
// by `visibilityChange`.
|
3207
|
+
}
|
3208
|
+
if (visibilityEvent.getTs() < event.getTs()) {
|
3209
|
+
// Something is wrong, the visibility change cannot happen before the
|
3210
|
+
// event. Presumably an ill-formed event.
|
3211
|
+
return;
|
3212
|
+
}
|
3213
|
+
event.applyVisibilityEvent(visibilityChange);
|
3214
|
+
}
|
3215
|
+
|
3216
|
+
/**
|
3217
|
+
* Find when a client has gained thread capabilities by inspecting the oldest
|
3218
|
+
* threaded receipt
|
3219
|
+
* @returns the timestamp of the oldest threaded receipt
|
3220
|
+
*/
|
3221
|
+
getOldestThreadedReceiptTs() {
|
3222
|
+
return this.oldestThreadedReceiptTs;
|
3223
|
+
}
|
3224
|
+
|
3225
|
+
/**
|
3226
|
+
* Determines if the given user has read a particular event ID with the known
|
3227
|
+
* history of the room. This is not a definitive check as it relies only on
|
3228
|
+
* what is available to the room at the time of execution.
|
3229
|
+
*
|
3230
|
+
* @param userId - The user ID to check the read state of.
|
3231
|
+
* @param eventId - The event ID to check if the user read.
|
3232
|
+
* @returns true if the user has read the event, false otherwise.
|
3233
|
+
*/
|
3234
|
+
hasUserReadEvent(userId, eventId) {
|
3235
|
+
return this.roomReceipts.hasUserReadEvent(userId, eventId);
|
3236
|
+
}
|
3237
|
+
|
3238
|
+
/**
|
3239
|
+
* Returns the most recent unthreaded receipt for a given user
|
3240
|
+
* @param userId - the MxID of the User
|
3241
|
+
* @returns an unthreaded Receipt. Can be undefined if receipts have been disabled
|
3242
|
+
* or a user chooses to use private read receipts (or we have simply not received
|
3243
|
+
* a receipt from this user yet).
|
3244
|
+
*/
|
3245
|
+
getLastUnthreadedReceiptFor(userId) {
|
3246
|
+
return this.unthreadedReceipts.get(userId);
|
3247
|
+
}
|
3248
|
+
|
3249
|
+
/**
|
3250
|
+
* This issue should also be addressed on synapse's side and is tracked as part
|
3251
|
+
* of https://github.com/matrix-org/synapse/issues/14837
|
3252
|
+
*
|
3253
|
+
*
|
3254
|
+
* We consider a room fully read if the current user has sent
|
3255
|
+
* the last event in the live timeline of that context and if the read receipt
|
3256
|
+
* we have on record matches.
|
3257
|
+
* This also detects all unread threads and applies the same logic to those
|
3258
|
+
* contexts
|
3259
|
+
*/
|
3260
|
+
fixupNotifications(userId) {
|
3261
|
+
super.fixupNotifications(userId);
|
3262
|
+
var unreadThreads = this.getThreads().filter(thread => this.getThreadUnreadNotificationCount(thread.id, NotificationCountType.Total) > 0);
|
3263
|
+
for (var thread of unreadThreads) {
|
3264
|
+
thread.fixupNotifications(userId);
|
3265
|
+
}
|
3266
|
+
}
|
3267
|
+
|
3268
|
+
/**
|
3269
|
+
* Determine the order of two events in this room.
|
3270
|
+
*
|
3271
|
+
* In principle this should use the same order as the server, but in practice
|
3272
|
+
* this is difficult for events that were not received over the Sync API. See
|
3273
|
+
* MSC4033 for details.
|
3274
|
+
*
|
3275
|
+
* This implementation leans on the order of events within their timelines, and
|
3276
|
+
* falls back to comparing event timestamps when they are in different
|
3277
|
+
* timelines.
|
3278
|
+
*
|
3279
|
+
* See https://github.com/matrix-org/matrix-js-sdk/issues/3325 for where we are
|
3280
|
+
* tracking the work to fix this.
|
3281
|
+
*
|
3282
|
+
* @param leftEventId - the id of the first event
|
3283
|
+
* @param rightEventId - the id of the second event
|
3284
|
+
* @returns -1 if left \< right, 1 if left \> right, 0 if left == right, null if
|
3285
|
+
* we can't tell (because we can't find the events).
|
3286
|
+
*/
|
3287
|
+
compareEventOrdering(leftEventId, rightEventId) {
|
3288
|
+
return compareEventOrdering(this, leftEventId, rightEventId);
|
3289
|
+
}
|
3290
|
+
|
3291
|
+
/**
|
3292
|
+
* Return true if this room has an `m.room.encryption` state event.
|
3293
|
+
*
|
3294
|
+
* If this returns `true`, events sent to this room should be encrypted (and `MatrixClient.sendEvent` and friends
|
3295
|
+
* will encrypt outgoing events).
|
3296
|
+
*/
|
3297
|
+
hasEncryptionStateEvent() {
|
3298
|
+
var _this$getLiveTimeline;
|
3299
|
+
return Boolean((_this$getLiveTimeline = this.getLiveTimeline().getState(EventTimeline.FORWARDS)) === null || _this$getLiveTimeline === void 0 ? void 0 : _this$getLiveTimeline.getStateEvents(EventType.RoomEncryption, ""));
|
3300
|
+
}
|
3301
|
+
}
|
3302
|
+
|
3303
|
+
// a map from current event status to a list of allowed next statuses
|
3304
|
+
var ALLOWED_TRANSITIONS = {
|
3305
|
+
[EventStatus.ENCRYPTING]: [EventStatus.SENDING, EventStatus.NOT_SENT, EventStatus.CANCELLED],
|
3306
|
+
[EventStatus.SENDING]: [EventStatus.ENCRYPTING, EventStatus.QUEUED, EventStatus.NOT_SENT, EventStatus.SENT],
|
3307
|
+
[EventStatus.QUEUED]: [EventStatus.SENDING, EventStatus.NOT_SENT, EventStatus.CANCELLED],
|
3308
|
+
[EventStatus.SENT]: [],
|
3309
|
+
[EventStatus.NOT_SENT]: [EventStatus.SENDING, EventStatus.QUEUED, EventStatus.CANCELLED],
|
3310
|
+
[EventStatus.CANCELLED]: []
|
3311
|
+
};
|
3312
|
+
export var RoomNameType = /*#__PURE__*/function (RoomNameType) {
|
3313
|
+
RoomNameType[RoomNameType["EmptyRoom"] = 0] = "EmptyRoom";
|
3314
|
+
RoomNameType[RoomNameType["Generated"] = 1] = "Generated";
|
3315
|
+
RoomNameType[RoomNameType["Actual"] = 2] = "Actual";
|
3316
|
+
return RoomNameType;
|
3317
|
+
}({});
|
3318
|
+
// Can be overriden by IMatrixClientCreateOpts::memberNamesToRoomNameFn
|
3319
|
+
function memberNamesToRoomName(names, count) {
|
3320
|
+
var countWithoutMe = count - 1;
|
3321
|
+
if (!names.length) {
|
3322
|
+
return "Empty room";
|
3323
|
+
} else if (names.length === 1 && countWithoutMe <= 1) {
|
3324
|
+
return names[0];
|
3325
|
+
} else if (names.length === 2 && countWithoutMe <= 2) {
|
3326
|
+
return "".concat(names[0], " and ").concat(names[1]);
|
3327
|
+
} else {
|
3328
|
+
var plural = countWithoutMe > 1;
|
3329
|
+
if (plural) {
|
3330
|
+
return "".concat(names[0], " and ").concat(countWithoutMe, " others");
|
3331
|
+
} else {
|
3332
|
+
return "".concat(names[0], " and 1 other");
|
3333
|
+
}
|
3334
|
+
}
|
3335
|
+
}
|
3336
|
+
//# sourceMappingURL=room.js.map
|