1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-08-07 23:02:56 +03:00
Commit Graph

1904 Commits

Author SHA1 Message Date
Janne Mareike Koschinski
193c38523c Fix messages loaded during initial fetch ending up out of order (#2971)
* Fix messages loaded during initial fetch ending up out of order
2022-12-13 15:23:43 +01:00
Andy Uhnak
11ac3d9e58 Add unit tests 2022-12-13 12:26:52 +00:00
Germain
74b30246d0 Avoid creating duplicate threads (#2968) 2022-12-13 09:54:44 +00:00
Richard van der Hoff
9c17eb6c14 Begin factoring out a CryptoBackend interface (#2955)
Part of https://github.com/vector-im/element-web/issues/21972. Eventually I want to replace the whole of the current `Crypto` implementation with an alternative implementation, but in order to get from here to there, I'm factoring out a common interface which will be implemented by both implementations.

I'm also determined to fix the problem where the innards of the crypto implementation are exposed to applications via the `MatrixClient.crypto` property.

It's not (yet) entirely clear what shape this interface should be, so I'm going with a minimal approach and adding things as we know we need them. This means that we need to keep the old `client.crypto` property around as well as a new `client.cryptoBackend` property. Eventually `client.crypto` will go away, but that will be a breaking change in the js-sdk.
2022-12-12 17:49:39 +00:00
Janne Mareike Koschinski
8293011ee2 Fix #23916: Prevent edits of the last message in a thread getting lost (#2951)
* Fix issue where the root event of a thread had to be loaded in a complicated way
* Fix issue where edits to the last event of a thread would get lost
* Fix issue where thread reply count would desync
* Refactor relations pagination mocking for tests
2022-12-12 18:22:16 +01:00
Richard van der Hoff
4c5f416b32 Factor out some utility functions in the megolm integration tests (#2958)
There's a lot of repetition here, which can be reduced with some utility functions.
2022-12-12 16:31:56 +00:00
Damir Jelić
ada401f4c0 Make sure that MegolmEncryption.setupPromise always resolves (#2960)
ensureOutboundSession uses and modifies the setupPromise of the
MegolmEncryption class. Some comments suggest that setupPromise will
always resolve, in other words it should never contain a promise that
will get rejected.

Other comments also seem to suggest that the return value of
ensureOutboundSession, a promise as well, may fail.

The critical error here is that the promise that gets set as
the next setupPromise, as well as the promise that ensureOutboundSession
returns, is the same promise.

It seems that the intention was for setupPromise to contain a promise
that will always resolve to either `null` or `OutboundSessionInfo`.

We can see that a couple of lines before we set setupPromise to its new
value we construct a promise that logs and discards errors using the
`Promise.catch()` method.

The `Promise.catch()` method does not mutate the promise, instead it
returns a new promise. The intention of the original author might have
been to set the next setupPromise to the promise which `Promise.catch()`
produces.

This patch modifies the updating of setupPromise in the
ensureOutboundSession so that setupPromise discards errors correctly.

Using `>>=` to represent the promise chaining operation, setupPromise is
now updated using the following logic:

    setupPromise = previousSetupPromise >>= setup >>= discardErrors
2022-12-09 14:46:33 +00:00
Germain
5b6bebc1d7 Do not calculate highlight notifs for threads unknown to the room (#2957) 2022-12-09 12:41:51 +00:00
Michael Weimann
72dac9a107 Apply manual code style fixes after prettier 2022-12-09 09:43:22 +01:00
Michael Weimann
349c2c2587 Apply prettier formatting 2022-12-09 09:38:20 +01:00
Eric Eastwood
ed91bd9c11 Merge branch 'develop' into madlittlemods/stablize-msc3030-timestamp-to-event
Conflicts:
	spec/unit/matrix-client.spec.ts
	src/client.ts
2022-12-08 18:29:14 -06:00
Eric Eastwood
c953fc9fb7 Update casing
See https://github.com/matrix-org/matrix-js-sdk/pull/2915#discussion_r1041542066
2022-12-08 17:56:53 -06:00
Eric Eastwood
bf78a64d82 Remove console coloring in favor of future PR
See https://github.com/matrix-org/matrix-js-sdk/pull/2915#discussion_r1041539703
2022-12-08 17:47:56 -06:00
Šimon Brandner
ae849fdd46 Minor VoIP stack improvements (#2946)
* Add `IGroupCallRoomState`

Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>

* Export values into `const`s

Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>

* Add `should correctly emit LengthChanged`

Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>

* Add `ICE disconnected timeout`

Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>

* Improve typing

Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>

* Don't cast `getContent()`

Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>

* Use `Date.now()` for call length

Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>

* Type fix

Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>

Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
2022-12-08 19:51:05 +01:00
Richard van der Hoff
39cf212628 Expose a new 'userHasCrossSigningKeys' method (#2950) 2022-12-08 11:53:38 +00:00
Germain
16d791b038 Cache read receipts for unknown threads (#2953) 2022-12-08 09:54:10 +00:00
Michael Telatynski
c4006d752a Improve tsdoc types (#2940)
* Install eslint-plugin-jsdoc

* Enable lint rule jsdoc/no-types

* Make tsdoc more valid, add required hyphens and s/return/returns/g

* Stash tsdoc work

* Fix mistypes

* Stash

* Stash

* More tsdoc work

* Remove useless doc params

* Fixup docs

* Apply suggestions from code review

Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>

* Update src/crypto/verification/request/ToDeviceChannel.ts

Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>

* Update src/client.ts

Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>

* Update src/client.ts

Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>

* Update src/client.ts

Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>

* Iterate

Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
2022-12-07 18:01:54 +00:00
Richard van der Hoff
a9e7a46c56 Upload device keys during initCrypto (#2872)
Rather than waiting for the application to call `.startClient`, upload the
device keys during `initCrypto()`. Element-R is going to approach this slightly
differently (it wants to manage the decision on key uploads itself), so this
lays some groundwork by collecting the libolm-specific bits together.
2022-12-07 13:48:41 +00:00
Michael Telatynski
8d018f9c2d Enable noImplicitAny (#2895)
* Stash noImplicitAny work

* Enable noImplicitAny

* Update olm

* Fun

* Fix msgid stuff

* Fix tests

* Attempt to fix Browserify
2022-12-06 18:21:44 +00:00
Richard van der Hoff
683e7fba4a Add a message ID on each to-device message (#2938)
To make it easier to track down where to-device messages are getting lost,
add a custom property to each one, and log its value. Synapse will also log
this property.
2022-12-06 10:31:48 +00:00
Šimon Brandner
2c8eece5ca Don't expose calls on GroupCall (#2941) 2022-12-05 18:44:13 +01:00
kegsay
4a4d493856 bugfix: sliding sync initial room timelines shouldn't notify (#2933)
* bugfix: sliding sync initial room timelines shouldn't notify

Flag timeline events as `fromCache` when `initial: true` rooms
are received. This stops notifications appearing inappropriately
when you scroll the room list or spider the room list, as it
causes `liveEvent=false`.

* Use num_live to detect liveness; with jest test

* Linting

* jsdoc

Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
2022-12-05 17:00:06 +00:00
Michael Weimann
11d8f562c5 Redo key sharing after own device verification (#2921) 2022-12-05 14:31:58 +01:00
Janne Mareike Koschinski
8a7fd270e4 Move updated threads to the end of the thread list (#2923)
* Move updated threads to the end of the thread list
* Write new tests
2022-12-02 17:11:18 +01:00
Germain
53a45a34df Fix highlight notifications increasing when total notification is zero (#2937) 2022-12-02 15:41:15 +00:00
Janne Mareike Koschinski
720248466f Include pending events in thread summary and count again (#2922)
* Include pending events in thread summary and count again
* Pass through pending event status
2022-12-02 15:01:43 +01:00
Janne Mareike Koschinski
43bfa0c020 Switch to stable /relations endpoint, stop using unspecced original_event field (#2911)
* Switch to stable /relations endpoint, stop using unspecced original_event field
* Adapt the tests to the changed endpoint
2022-12-02 15:01:15 +01:00
Robin Townsend
9de9ff76b5 Test cleanMemberState 2022-12-01 23:27:31 -05:00
Robin Townsend
c0090852ad Make GroupCall work better with widgets
If the client uses a widget to join group calls, like Element Web does, then the local device could be joined to the call without GroupCall knowing. This adds a field to GroupCall that allows the client to tell GroupCall when it's using another session to join the call.
2022-12-01 10:45:34 -05:00
Faye Duxovni
3870e3395d Add method to get outgoing room key requests for a given event (#2930)
* Add method to get outgoing room key requests for a given event

* Write test, fix typo

* Add test case for non-encrypted event
2022-12-01 09:49:36 +00:00
Eric Eastwood
9a98e8008f Fix relevant strict ts error 2022-11-30 19:13:29 -06:00
Eric Eastwood
ad8bb5d2cd Fix lints 2022-11-30 19:01:20 -06:00
Eric Eastwood
9a731cdf4f Add some comments 2022-11-30 18:53:23 -06:00
Eric Eastwood
d1ede036e2 Add return type 2022-11-30 18:51:49 -06:00
Eric Eastwood
d3f08fec03 Add tests 2022-11-30 18:45:05 -06:00
Richard van der Hoff
1606274c36 Process m.room.encryption events before emitting RoomMember events (#2914)
vector-im/element-web#23819 is an intermittent failure to correctly initiate a user verification process. The
root cause is as follows:

* In matrix-react-sdk, ensureDMExists tries to create an encrypted DM room, and assumes it is ready for use
  (including sending encrypted events) as soon as it receives a RoomStateEvent.NewMember notification
  indicating that the other user has been invited or joined. 

* However, in sync.ts, we process the membership events in a /sync response (including emitting
  RoomStateEvent.NewMember notifications), which is long before we process any m.room.encryption event.
    
* The upshot is that we can end up trying to send an encrypted event in the new room before processing
  the m.room.encryption event, which causes the crypto layer to blow up with an error of "Room was 
  previously configured to use encryption, but is no longer".

Strictly speaking, ensureDMExists probably ought to be listening for ClientEvent.Room as well as RoomStateEvent.NewMember; but that doesn't help us, because ClientEvent.Room is also emitted
before we process the crypto event.

So, we need to process the crypto event before we start emitting these other events; but a corollary of that 
is that we need to do so before we store the new room in the client's store. That makes things tricky, because
currently the crypto layer expects the room to have been stored in the client first.

So... we have to rearrange everything to pass the newly-created Room object into the crypto layer, rather than
just the room id, so that it doesn't need to rely on getting the Room from the client's store.
2022-11-30 10:53:38 +00:00
Germain
3577aa98b5 Fix synthesizeReceipt (#2916) 2022-11-30 07:58:29 +00:00
Marco Bartelt
6611cfa253 add-privileged-users-in-room (#2892) 2022-11-29 19:23:57 +00:00
Robin Townsend
a4ad4ed2cf Merge branch 'develop' into group-call-participants 2022-11-28 16:11:24 -05:00
Kegan Dougal
6592b2c205 sonarcloud 2022-11-28 10:58:38 +00:00
Robin Townsend
5511a6ef8c Fix tests 2022-11-26 00:28:11 -05:00
Robin Townsend
995f5bf7d7 Merge branch 'develop' into group-call-participants 2022-11-25 11:56:45 -05:00
Richard van der Hoff
aaf3702c66 Process m.room.encryption events before emitting RoomMember events (#2910)
* Update tests

* Call `Store.storeRoom` earlier

We're going to call `onCryptoEvent` earlier in `processSyncResponse`, but we
need to have stored the room before doing so. We therefore need to move the
call to `storeRoom` earlier.

We can actually reduce a bit of duplication by moving the call into
`SyncApi.createRoom`.

`storeRoom` has relatively few side-effects, so as far as I can tell this
should be pretty safe.

* Call onCryptoEvent before processing state events

This fixes the problematic race condition.
2022-11-25 13:47:28 +00:00
Kegan Dougal
74147b9943 Linting 2022-11-25 13:24:12 +00:00
Kegan Dougal
815370c5f9 sliding sync: add receipts extension 2022-11-25 13:21:16 +00:00
Michael Telatynski
007b7dd242 Fix 3pid invite acceptance not working due to mxid being sent in body (#2907) 2022-11-25 09:22:10 +00:00
Florian Duros
77d6def1cc Add jest metrics (#2897)
* Add slow jest reporter
2022-11-24 13:06:19 +00:00
Robin Townsend
f46ecf970c Refactor GroupCall participant management
This refactoring brings a number of improvements to GroupCall, which I've unfortunately had to combine into a single commit due to coupling:

- Moves the expiration timestamp field on call membership state to be per-device
- Makes the participants of a group call visible without having to enter the call yourself
- Enables users to join group calls from multiple devices
- Identifies active speakers by their call feed, rather than just their user ID
- Plays nicely with clients that can be in multiple calls in a room at once
- Fixes a memory leak caused by the call retry loop never stopping
- Changes GroupCall to update its state synchronously, and write back to room state asynchronously
  - This was already sort of halfway being done, but now we'd be committing to it
  - Generally improves the robustness of the state machine
  - It means that group call joins will appear instant, in a sense

For many reasons, this is a breaking change.
2022-11-21 12:16:44 -05:00
Michael Telatynski
305b83f8ea Merge branch 'develop' into kegan/ss-typing 2022-11-21 11:36:07 +00:00
Kegan Dougal
acc488da64 typing events don't need to be in an array 2022-11-21 11:31:33 +00:00