The current implementation uses number of invited and joined members for
"and {} others" message. This assigns rooms with 5 members the name "a,
b, c, and 5 others" suggesting 8 room members. The correct message is
"a, b, c, and 2 others". To get this, subtract number of heroes from
invited and joined member count.
Step 3.ii of the naming algorithm[0] confirms using a remaining users
count in the name.
[0] https://matrix.org/docs/spec/client_server/latest#calculating-the-display-name-for-a-room
Split `calculate_room_name()` into a high-level function using Matrix
data types and low-level function containing the core logic using plain
Rust data types. Since the low-level function uses simple data types,
unit testing becomes easier.
Step 3.ii of the name calculation algorithm[0] specifies the conditional
as `heroes < invited + joined - 1 AND invited + joined > 1`. However,
current implementation uses `invited + joined - 1 > 1` in the
conditional, which can trigger the conditional if the user is alone.
Correct this by using two variables representing `invited + joined` and
`invited_joined - 1` and updating the conditional. `invited + joined` is
kept as a variable since step 3.iii uses it for its conditional.
[0] https://matrix.org/docs/spec/client_server/latest#calculating-the-display-name-for-a-room
This patch adds types and methods to parse QR codes defined in the
[spec]. It supports parsing the QR format from an image or from a byte
string, converting back to an image and bytestring is possible as well.
[spec]: https://spec.matrix.org/unstable/client-server-api/#qr-code-format
Usually only room keys and forwarded room keys are sent as encrypted
to-device events, those are specially handled to avoid accepting room
keys coming in unencrypted.
Some clients might send out other events encrypted which might lower
metadata leakage and the spec doesn't disallow it.
This patch handles decrypted events the same way as non-encrypted ones,
we're still special casing the decryption handling to avoid decryption
loops/bombs (i.e. events that are encrypted multiple times).