Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Element-R: wire up device lists #24833

Closed
4 tasks done
Tracked by #24979
richvdh opened this issue Mar 15, 2023 · 1 comment
Closed
4 tasks done
Tracked by #24979

Element-R: wire up device lists #24833

richvdh opened this issue Mar 15, 2023 · 1 comment
Assignees
Labels
A-Element-R Issues affecting the port of Element's crypto layer to Rust A-Session-Mgmt Session / device names, management UI, etc. O-Frequent Affects or can be seen by most users regularly or impacts most users' first experience S-Tolerable Low/no impact on users T-Enhancement

Comments

@richvdh
Copy link
Member

richvdh commented Mar 15, 2023

We need to implement MatrixClient.downloadKeys and MatrixClient.getStoredDevicesForUser. This is used to populate the device list in the right panel, as well as determining whether we should use an encrypted room when starting DMs with a user (#24429).

Broadly, we need to:

  • decide if we are tracking a user's devices by calling OlmMachine.trackedUsers.
  • If we are, call OlmMachine.getUserDevices() and translate the returned info into an IDevice.
  • If we are not (and downloadUncached is set, see below), hit /_matrix/client/v3/keys/query to download the device list, and translate the result of that into an Device (new Device model from the js-sdk).

I'd like to take the opportunity to clean up the API a bit here, so I'd propose adding a single method to CryptoApi:

/**
 * Get the device information for the given list of users.
 *
 * @param userIds - The users to fetch.
 * @param downloadUncached - If true, download the device list for users whose device list we are not
 *    currently tracking. Defaults to false, in which case such users will not appear at all in the result map.
 *
 * @returns A map `userId->deviceId->{@link Device}`.
 */
getUserDeviceInfo(
    userIds: string[],
    downloadUncached?: boolean,
): Promise<Map<string, Map<string, Device>>>;

For legacy Crypto, we implement this with a thin shim onto the existing Crypto.downloadKeys and Crypto.getStoredDevicesForUser. We also replace MatrixClient.downloadKeys and MatrixClient.getStoredDevicesForUser with thin shims onto CryptoApi.getUserDeviceInfo.

The forceDownload parameter of MatrixClient.downloadKeys is used in exactly one place (when populating the right panel), and I think we should quietly ignore it: the magical "fix bugs in my caching logic by skipping the cache" logic does more harm than good.

@richvdh richvdh added T-Enhancement O-Frequent Affects or can be seen by most users regularly or impacts most users' first experience A-Element-R Issues affecting the port of Element's crypto layer to Rust labels Mar 15, 2023
@richvdh
Copy link
Member Author

richvdh commented Mar 15, 2023

some untested work on the translation to an IDevice in matrix-org/matrix-js-sdk@develop...rav/element-r/device_list_work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Element-R Issues affecting the port of Element's crypto layer to Rust A-Session-Mgmt Session / device names, management UI, etc. O-Frequent Affects or can be seen by most users regularly or impacts most users' first experience S-Tolerable Low/no impact on users T-Enhancement
Projects
None yet
Development

No branches or pull requests

3 participants