Original issue and former solution by
The one with the braid <info@braid.business>
Special thanks for pointing out the problem.
This fixes that dart:io is imported into the
SDK database by moving it into it's own mixin which
makes it reusable and platform independent by
using conditional imports.
- removes `Directory` field in high-level `MatrixSdkDatabase`
- migrates `Directory fileStoragePath` to `Uri fileStorageLocation`
- makes file operations in `MatrixSdkDatabase` conditional on
`dart.libraries.js_util`
- implements a tiny stub of the file operations used in `MatrixSdkDatabase`
It seems like the Flutter tool can compile despite these imports. Sadly
the Dart standalone dart2js compiler doesn't reach there. While
refactorying the code, I decided it's likely cleaner to have a `Uri` as
storage location provider than using some fake directory or String as
relacement.
The advantage of a `Uri` at this place is the explicit `Uri.directory`
constructor available to ensure type and encoding safe directory
locations supporting both Windows and *nix.
Additionally, admitted, that's an edge-case, one could even
easily extend the use of a `Uri` based descriptor to support future
storage location accesses (e.g. IPFS or custom schemes for e.g. local
web browser based file system APIs). Using a `Uri`, one would only need
to override the three methods making use of the `fileStorageLocation`
property to handle different Uri schemes too.
Signed-off-by: The one with the braid <info@braid.business>
When user A invites user B to
a group chat, the avatar getter
should not return the
avatar of the inviting user A.
This is not intuitive. A client might
decide to do so but IMO it makes
no sense to do this by default.
If the
room is a DM invite, user A's
avatar is already used in the
code block before.
This makes use of dart
records to return three
different values for one
method. This makes the
special class no longer
necessary just for
returning data.
This changes the way how the last event is stored
for each room. It is now stored next to the
room event itself in the rooms box and no longer
stored like a room state. This way we need to
bump the database version which will cause an
inital sync for the client. Be aware of this when
updating the SDK!
This also makes sure that
the access token is
refreshed when calling
client.getEventByPushNotification()
which is porbably the most
common case for a client
with a stopped sync loop
doing network requests.
This fixes several problems with current soft logout
handling, as it now stores the refresh token correct and
only refreshs it 1 minute in advance instead of 5
minutes.
This was implicitly relying to the timestamp of state events getting
compared in the setState function. Fix this by using the helper
functions already used for invite and join rooms.
We used to add app the member counts of invited users and joined users,
which would make us assume the participants list is complete. Which
would mean we always return the wrong state.
Additionally there is no need to rely on if we have a cached response.
Instead we always only check for completeness instead of possibly
returning stale responses just because we fetched the members once.
We now handle state in the correct order in the sync handler. Using the
timestamp lead to false results when we still generated a default
timestamp of "now" for events, however even without that state events
can have an older timestamp like when accepting an invite on a server
with the clock behind by a minute and we should instead rely on the sync
handler giving us state in the right order.
This causes issues with state handling as we prefer the newer event. It
also has knock-on effects in other places. Instead set such events to
have an obviously invalid timestamp, which makes issues easier to
identify.
This may break invites showing a timestamp or the timestamps for just
sent events, if you rely on the timestamp getting set to "now".
This patch introduces a helper class for SQfLite encryption related operations.
Most matrix clients will encrypt their sqlite database at rest. Since
this is a quite fragmented task using the Flutter sqlite ecosystem, this
helper aims to simplify some more complex operations.
It in particular helps with the following tasks :
- loading the correct shared objects / dynamic libraries for sqlcipher
- check whether a database is encrypted
- migrate an unencrypted SQLite database to SQLCipher
- apply the cipher to a database while opening it and ensure it loads
This code is not exactly matrix related, though presumably any matrix
client will use parts of it.
Possible regressions :
- `package:sqlite3` became a direct dependency. As of now it already was a
transitive dependency of the SDK itself.
Signed-off-by: The one with the braid <info@braid.business>
This refactors the transaction
workaround with
"zone transactions" and
abstracts them in a mixin. Then
it just uses this mixin in the
HiveDatabase and the
sqflite_box and also applies
them on indexedDB to
fix transactions on web.
This creates a set before
requesting users from the
database. This prevents
doing the same check for
the same user multiple
times and also prevents
concurrent modifications
of the event list.
This changes the behavior
when client init fails. It
no longer calls logout and does
only clear local data while
returning all available
information in a new
exception type so that the
SDK consumer can decide
to logout or try again to init
with these information. This
should make it much more rare
that users loose their sessions.
This creates the timeline object
earlier in the Room.getTimeline() method.
This results to that the
Timeline object already starts
to listen on the event stream
while the getTimeline() method
requests users from the database
and tries to decrypt room
events. I assume that this
causes the problem that
on timeline creation new
events get lost because they
come in, while getTimeline() is
not yet completed but the
onEvent stream is not yet
connected at the same time.
This fixes the response
timeout for the initial
sync and sets it to 2
minutes instead of 10
seconds. This should increase
the speed for the initial
sync especially for large
accounts. This change
also adds some
documentation in the
code about what
timeout does what.
This refactors three methods
regarding powerlevels. It
makes them a little bit more
readable and removes
unnecessary checks. it
also changes the canSendDefaultMessage
method in a way that it also
checks the events map in the
powerlevels so that it returns
true if message events are
overwritten there. It also
improves the dart docs and
explains in more detail what it
does.
dynamic.copy returned a type
error so I reverted the previous
change of the copyMap
method to an extension. Also
I found out that we have used
two copyMap methods in the
SDK which did exactly the same.
I deleted the old one and
changed the tests.
Unfortunately we need to copy
all maps. I took the opportunity
and abstracted the copy map
method to utils. I kept the
copyMap method as a
reference in HiveCollections
database to not require a
huge refactoring there as we
are going to ditch it anyway.
BREAKING CHANGE: This replaces the old dehydrated devices
implementation, since there is no way to query what is supported easily
and supporting both would be complicated.
fixes https://github.com/famedly/matrix-dart-sdk/issues/1579
There were several issues here. Key uploads in general failed, because
the await caused a Future<dynamic> to be returned, which failed type
checking.
But also we never unset our future, which was used for the online key
backup uploads, which meant we would very quickly stop uploading any
keys at all.
This changes the behavior
of the markdown method to
only convert linebreaks inside
of p blocks. I found no better
solution yet for the problem
as otherwise also lists
will have linebreaks between
the list items. Unfortunately
the default linebreak syntax
seems not to fulfill our needs.
BREAKING CHANGE: This changes the runInRoot method to not return a
future. As a user, if you need the result of an async computation passed
to runInRoot, please await it directly. Also the KeyVerification start
and a few call methods now return a future.
- store left rooms in archive during sync (as well as they are removed
on join already)
- refactor room archive code
- fix typo
Internal reference: SMC-385
Signed-off-by: The one with the braid <info@braid.business>
Removes two test cases in the markdown test which do not work anymore.
Reason for this is that just parsing a word inside of $$ word $$
katex is not valid anyway because katex is only made for mathematical
things. So the output is undefined behavior anyway.
At least in our CI this throws a null assertion error and since we
explicitly expect this to sometimes be null in our code, we should store
it as such.
If you create DM room, but the other party doesn't join it, they might
be unable to create a new DM using startDirectChat. Since creating a new
DM is pretty much the same as joining the invite, we try to join the
pending DM invite first and fall back to creating a new room if that
fails.
This does make the reset take longer on big accounts, but otherwise
users might sign out before the keys are uploaded, which makes the reset
more destructive than necessary. In the common case of not having any
keys it shouldn't make a difference.
It wasn't quite obvious that invites were always sorted at the top, if
you just looked at the sort function. This makes it more explicit and
also makes invites always sort before favourited rooms.
fix: Also update last event on redaction in store
Closes famedly/company/product-management#990
See merge request famedly/company/frontend/famedlysdk!1298
If we join first, it is possible that our member event is not the invite
event anymore. As such we should fetch that state first, before joining.
But also there is little reason not to mark the room as a DM
immediately. That prevents the room from temporarily becoming a group
room, that might be visible in the UI temporarily.
fixes https://gitlab.com/famedly/company/product-management/-/issues/1006
Otherwise it would be possible, that we haven't loaded account data, so
we return that cross-signing is disabled and then we load it and return
a different result. Might fix the sentry issue for that.
fix: while singleShotStaleCallChecker code seems to be correct we are seeings some random disconnects in group calls, this makes sure we have all the to-device messages we are supposed to have before checking for stale calls
Without this, when new rules are added with new conditions, we would
always match on them. This would mean all messages now notify. It is
better to skip them instead.
currently in the app we start the group call (but do not enter it), then we use the localStreams provided by it to show the setup page (enable/disable media devices). This causes some issues because the user hasn't joined the group call so the member state events don't update and the group call is killed if they just sit on the setup call page. Also creating a group call, sends notifications in our apps but no one has entered it. With this MR, apps can get their own user media, then edit that stream on setup page add it to GroupCall.enter(stream). This way, a group call doesn't have to be started and we get to do the setup page as well.
You can either set them to private on the client or overwrite the
behaviour for that on each readMarker call. This also handles incoming
thread receipts and tries its best to figure out what is the latest
receipt. This however breaks the old m.receipt account data event.
This makes sure that the deleteFromDisk() method is
called AFTER the clear while
the execution order was
random before which could
lead to the problem that
Hive tries to clear a box after
it got deleted.
In Synapse 1.62.0 the default cache duration of initial sync responses
was changed to 2 minutes. That means our archive calls might return
stale data. Since different sync timeouts bust through the cache, we
make use of that to be able to load the new archive immediately.
fixes https://gitlab.com/famedly/company/frontend/famedly-web/-/issues/634
fix: implement activeGroupCallEvents to get all active group call state events in a room
refactor: move staleCallChecker and expires_Ts stuff to an extension on Room, instead of Voip because it makes much more sense per room rather than on voip, also makes testing easier
fix: populate local groupCalls list on instantiating VOIP()
fix: starting stale call checker is now handled by the sdk itself because clients can forget to do so
This fixes a bug that the
last message was sent
incorrectly when a session
key received for example
from the key backup. It may
fix several issues like the
last message is set as a
very old one or the last
message is not decrypted.
This deprecates the displayname
getter in favor of the new
getLocalizedDisplayname which
gets the default localization
by default so it can be
called without defining localizations. It adds a method
to calculate if a room is an
abandoned DM room where
it is made sure that the room
is actually empty.
The workaround was from the
time when we have used
sqflite or when Hive had
bugs. But now HiveCollections
already supports transactions
in Dart zones and concurrent
write operations shouldn't
be a problem anymore.
- migrate e2ee tests to DinD
- test e2ee against Synapse, Conduit and Dendrite
- fix error handling in push rules (thanks to Dendrite tests)
Signed-off-by: TheOneWithTheBraid <the-one@with-the-braid.cf>
Usually we store the keys we want to upload first, then upload them,
then store, that we uploaded them. So that should be fool proof.
But.
In some cases the filesyste lies to us and the database change isn't
actually persisted yet. That can happen when someone turns of their
phone aprubtly for example. In that case we generate new OTKs with the
same id. Uploading that will fail, since they already exist server side.
We can work around that by manually claiming them and removing them
locally.