From 6fc9d7641c51ca3db8225cf58b9d6e6fdd2d6556 Mon Sep 17 00:00:00 2001
From: Hubert Chathi
Date: Fri, 14 Jun 2024 09:13:41 -0400
Subject: [PATCH] Remove room key history sharing (#12618)
* Remove room key history sharing
* remove string from i18n
---
src/RoomInvite.tsx | 9 ++----
src/SlashCommands.tsx | 2 +-
src/components/views/dialogs/InviteDialog.tsx | 20 +-----------
src/i18n/strings/en_EN.json | 1 -
src/utils/MultiInviter.ts | 31 ++-----------------
src/utils/RoomUpgrade.ts | 2 +-
6 files changed, 8 insertions(+), 57 deletions(-)
diff --git a/src/RoomInvite.tsx b/src/RoomInvite.tsx
index 35a7a1d4df..72d9d50c8d 100644
--- a/src/RoomInvite.tsx
+++ b/src/RoomInvite.tsx
@@ -40,7 +40,6 @@ export interface IInviteResult {
*
* @param {string} roomId The ID of the room to invite to
* @param {string[]} addresses Array of strings of addresses to invite. May be matrix IDs or 3pids.
- * @param {boolean} sendSharedHistoryKeys whether to share e2ee keys with the invitees if applicable.
* @param {function} progressCallback optional callback, fired after each invite.
* @returns {Promise} Promise
*/
@@ -48,13 +47,10 @@ export function inviteMultipleToRoom(
client: MatrixClient,
roomId: string,
addresses: string[],
- sendSharedHistoryKeys = false,
progressCallback?: () => void,
): Promise {
const inviter = new MultiInviter(client, roomId, progressCallback);
- return inviter
- .invite(addresses, undefined, sendSharedHistoryKeys)
- .then((states) => Promise.resolve({ states, inviter }));
+ return inviter.invite(addresses, undefined).then((states) => Promise.resolve({ states, inviter }));
}
export function showStartChatInviteDialog(initialText = ""): void {
@@ -105,10 +101,9 @@ export function inviteUsersToRoom(
client: MatrixClient,
roomId: string,
userIds: string[],
- sendSharedHistoryKeys = false,
progressCallback?: () => void,
): Promise {
- return inviteMultipleToRoom(client, roomId, userIds, sendSharedHistoryKeys, progressCallback)
+ return inviteMultipleToRoom(client, roomId, userIds, progressCallback)
.then((result) => {
const room = client.getRoom(roomId)!;
showAnyInviteErrors(result.states, room, result.inviter);
diff --git a/src/SlashCommands.tsx b/src/SlashCommands.tsx
index 682145bd38..d7728f9761 100644
--- a/src/SlashCommands.tsx
+++ b/src/SlashCommands.tsx
@@ -420,7 +420,7 @@ export const Commands = [
return success(
prom
.then(() => {
- return inviter.invite([address], reason, true);
+ return inviter.invite([address], reason);
})
.then(() => {
if (inviter.getCompletionState(address) !== "invited") {
diff --git a/src/components/views/dialogs/InviteDialog.tsx b/src/components/views/dialogs/InviteDialog.tsx
index bb81d7a05f..401b047496 100644
--- a/src/components/views/dialogs/InviteDialog.tsx
+++ b/src/components/views/dialogs/InviteDialog.tsx
@@ -22,7 +22,6 @@ import { MatrixCall } from "matrix-js-sdk/src/webrtc/call";
import { logger } from "matrix-js-sdk/src/logger";
import { uniqBy } from "lodash";
-import { Icon as InfoIcon } from "../../../../res/img/element-icons/info.svg";
import { Icon as EmailPillAvatarIcon } from "../../../../res/img/icon-email-pill-avatar.svg";
import { _t, _td } from "../../../languageHandler";
import { MatrixClientPeg } from "../../../MatrixClientPeg";
@@ -624,7 +623,7 @@ export default class InviteDialog extends React.PureComponent;
const identityServersEnabled = SettingsStore.getValue(UIFeature.IdentityServer);
@@ -1391,21 +1389,6 @@ export default class InviteDialog extends React.PureComponent
-
- {" " + _t("invite|key_share_warning")}
-
- );
- }
- }
} else if (this.props.kind === InviteKind.CallTransfer) {
title = _t("action|transfer");
@@ -1471,7 +1454,6 @@ export default class InviteDialog extends React.PureComponent
- {keySharingWarning}
{this.renderIdentityServerWarning()}
{this.state.errorText}
{onlyOneThreepidNote}
diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json
index 1a0b8b63ae..fb20c84345 100644
--- a/src/i18n/strings/en_EN.json
+++ b/src/i18n/strings/en_EN.json
@@ -1294,7 +1294,6 @@
"failed_generic": "Operation failed",
"failed_title": "Failed to invite",
"invalid_address": "Unrecognised address",
- "key_share_warning": "Invited people will be able to read old messages.",
"name_email_mxid_share_room": "Invite someone using their name, email address, username (like ) or share this room.",
"name_email_mxid_share_space": "Invite someone using their name, email address, username (like ) or share this space.",
"name_mxid_share_room": "Invite someone using their name, username (like ) or share this room.",
diff --git a/src/utils/MultiInviter.ts b/src/utils/MultiInviter.ts
index 3df4e747a9..dd1c70a236 100644
--- a/src/utils/MultiInviter.ts
+++ b/src/utils/MultiInviter.ts
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
-import { MatrixError, MatrixClient, EventType, HistoryVisibility } from "matrix-js-sdk/src/matrix";
+import { MatrixError, MatrixClient, EventType } from "matrix-js-sdk/src/matrix";
import { KnownMembership } from "matrix-js-sdk/src/types";
import { defer, IDeferred } from "matrix-js-sdk/src/utils";
import { logger } from "matrix-js-sdk/src/logger";
@@ -83,10 +83,9 @@ export default class MultiInviter {
*
* @param {array} addresses Array of addresses to invite
* @param {string} reason Reason for inviting (optional)
- * @param {boolean} sendSharedHistoryKeys whether to share e2ee keys with the invitees if applicable.
* @returns {Promise} Resolved when all invitations in the queue are complete
*/
- public invite(addresses: string[], reason?: string, sendSharedHistoryKeys = false): Promise {
+ public invite(addresses: string[], reason?: string): Promise {
if (this.addresses.length > 0) {
throw new Error("Already inviting/invited");
}
@@ -105,31 +104,7 @@ export default class MultiInviter {
this.deferred = defer();
this.inviteMore(0);
- if (!sendSharedHistoryKeys || !this.roomId || !this.matrixClient.isRoomEncrypted(this.roomId)) {
- return this.deferred.promise;
- }
-
- const room = this.matrixClient.getRoom(this.roomId);
- const visibilityEvent = room?.currentState.getStateEvents(EventType.RoomHistoryVisibility, "");
- const visibility = visibilityEvent?.getContent().history_visibility;
-
- if (visibility !== HistoryVisibility.WorldReadable && visibility !== HistoryVisibility.Shared) {
- return this.deferred.promise;
- }
-
- return this.deferred.promise.then(async (states): Promise => {
- const invitedUsers: string[] = [];
- for (const [addr, state] of Object.entries(states)) {
- if (state === InviteState.Invited && getAddressType(addr) === AddressType.MatrixUserId) {
- invitedUsers.push(addr);
- }
- }
-
- logger.log("Sharing history with", invitedUsers);
- this.matrixClient.sendSharedHistoryKeys(this.roomId, invitedUsers); // do this in the background
-
- return states;
- });
+ return this.deferred.promise;
}
/**
diff --git a/src/utils/RoomUpgrade.ts b/src/utils/RoomUpgrade.ts
index ea9f773e34..3696aa34c5 100644
--- a/src/utils/RoomUpgrade.ts
+++ b/src/utils/RoomUpgrade.ts
@@ -120,7 +120,7 @@ export async function upgradeRoom(
if (toInvite.length > 0) {
// Errors are handled internally to this function
- await inviteUsersToRoom(cli, newRoomId, toInvite, false, () => {
+ await inviteUsersToRoom(cli, newRoomId, toInvite, () => {
progress.inviteUsersProgress!++;
progressCallback?.(progress);
});