Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 6fc9d76

Browse files
authored
Remove room key history sharing (#12618)
* Remove room key history sharing * remove string from i18n
1 parent d6b9e2a commit 6fc9d76

File tree

6 files changed

+8
-57
lines changed

6 files changed

+8
-57
lines changed

src/RoomInvite.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,17 @@ export interface IInviteResult {
4040
*
4141
* @param {string} roomId The ID of the room to invite to
4242
* @param {string[]} addresses Array of strings of addresses to invite. May be matrix IDs or 3pids.
43-
* @param {boolean} sendSharedHistoryKeys whether to share e2ee keys with the invitees if applicable.
4443
* @param {function} progressCallback optional callback, fired after each invite.
4544
* @returns {Promise} Promise
4645
*/
4746
export function inviteMultipleToRoom(
4847
client: MatrixClient,
4948
roomId: string,
5049
addresses: string[],
51-
sendSharedHistoryKeys = false,
5250
progressCallback?: () => void,
5351
): Promise<IInviteResult> {
5452
const inviter = new MultiInviter(client, roomId, progressCallback);
55-
return inviter
56-
.invite(addresses, undefined, sendSharedHistoryKeys)
57-
.then((states) => Promise.resolve({ states, inviter }));
53+
return inviter.invite(addresses, undefined).then((states) => Promise.resolve({ states, inviter }));
5854
}
5955

6056
export function showStartChatInviteDialog(initialText = ""): void {
@@ -105,10 +101,9 @@ export function inviteUsersToRoom(
105101
client: MatrixClient,
106102
roomId: string,
107103
userIds: string[],
108-
sendSharedHistoryKeys = false,
109104
progressCallback?: () => void,
110105
): Promise<void> {
111-
return inviteMultipleToRoom(client, roomId, userIds, sendSharedHistoryKeys, progressCallback)
106+
return inviteMultipleToRoom(client, roomId, userIds, progressCallback)
112107
.then((result) => {
113108
const room = client.getRoom(roomId)!;
114109
showAnyInviteErrors(result.states, room, result.inviter);

src/SlashCommands.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ export const Commands = [
420420
return success(
421421
prom
422422
.then(() => {
423-
return inviter.invite([address], reason, true);
423+
return inviter.invite([address], reason);
424424
})
425425
.then(() => {
426426
if (inviter.getCompletionState(address) !== "invited") {

src/components/views/dialogs/InviteDialog.tsx

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import { MatrixCall } from "matrix-js-sdk/src/webrtc/call";
2222
import { logger } from "matrix-js-sdk/src/logger";
2323
import { uniqBy } from "lodash";
2424

25-
import { Icon as InfoIcon } from "../../../../res/img/element-icons/info.svg";
2625
import { Icon as EmailPillAvatarIcon } from "../../../../res/img/icon-email-pill-avatar.svg";
2726
import { _t, _td } from "../../../languageHandler";
2827
import { MatrixClientPeg } from "../../../MatrixClientPeg";
@@ -624,7 +623,7 @@ export default class InviteDialog extends React.PureComponent<Props, IInviteDial
624623
}
625624

626625
try {
627-
const result = await inviteMultipleToRoom(cli, this.props.roomId, targetIds, true);
626+
const result = await inviteMultipleToRoom(cli, this.props.roomId, targetIds);
628627
if (!this.shouldAbortAfterInviteError(result, room)) {
629628
// handles setting error message too
630629
this.props.onFinished(true);
@@ -1279,7 +1278,6 @@ export default class InviteDialog extends React.PureComponent<Props, IInviteDial
12791278
let consultConnectSection;
12801279
let extraSection;
12811280
let footer;
1282-
let keySharingWarning = <span />;
12831281

12841282
const identityServersEnabled = SettingsStore.getValue(UIFeature.IdentityServer);
12851283

@@ -1391,21 +1389,6 @@ export default class InviteDialog extends React.PureComponent<Props, IInviteDial
13911389

13921390
buttonText = _t("action|invite");
13931391
goButtonFn = this.inviteUsers;
1394-
1395-
if (cli.isRoomEncrypted(this.props.roomId)) {
1396-
const room = cli.getRoom(this.props.roomId)!;
1397-
const visibilityEvent = room.currentState.getStateEvents("m.room.history_visibility", "");
1398-
const visibility =
1399-
visibilityEvent && visibilityEvent.getContent() && visibilityEvent.getContent().history_visibility;
1400-
if (visibility === "world_readable" || visibility === "shared") {
1401-
keySharingWarning = (
1402-
<p className="mx_InviteDialog_helpText">
1403-
<InfoIcon height={14} width={14} />
1404-
{" " + _t("invite|key_share_warning")}
1405-
</p>
1406-
);
1407-
}
1408-
}
14091392
} else if (this.props.kind === InviteKind.CallTransfer) {
14101393
title = _t("action|transfer");
14111394

@@ -1471,7 +1454,6 @@ export default class InviteDialog extends React.PureComponent<Props, IInviteDial
14711454
{spinner}
14721455
</div>
14731456
</div>
1474-
{keySharingWarning}
14751457
{this.renderIdentityServerWarning()}
14761458
<div className="error">{this.state.errorText}</div>
14771459
{onlyOneThreepidNote}

src/i18n/strings/en_EN.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1294,7 +1294,6 @@
12941294
"failed_generic": "Operation failed",
12951295
"failed_title": "Failed to invite",
12961296
"invalid_address": "Unrecognised address",
1297-
"key_share_warning": "Invited people will be able to read old messages.",
12981297
"name_email_mxid_share_room": "Invite someone using their name, email address, username (like <userId/>) or <a>share this room</a>.",
12991298
"name_email_mxid_share_space": "Invite someone using their name, email address, username (like <userId/>) or <a>share this space</a>.",
13001299
"name_mxid_share_room": "Invite someone using their name, username (like <userId/>) or <a>share this room</a>.",

src/utils/MultiInviter.ts

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
import { MatrixError, MatrixClient, EventType, HistoryVisibility } from "matrix-js-sdk/src/matrix";
17+
import { MatrixError, MatrixClient, EventType } from "matrix-js-sdk/src/matrix";
1818
import { KnownMembership } from "matrix-js-sdk/src/types";
1919
import { defer, IDeferred } from "matrix-js-sdk/src/utils";
2020
import { logger } from "matrix-js-sdk/src/logger";
@@ -83,10 +83,9 @@ export default class MultiInviter {
8383
*
8484
* @param {array} addresses Array of addresses to invite
8585
* @param {string} reason Reason for inviting (optional)
86-
* @param {boolean} sendSharedHistoryKeys whether to share e2ee keys with the invitees if applicable.
8786
* @returns {Promise} Resolved when all invitations in the queue are complete
8887
*/
89-
public invite(addresses: string[], reason?: string, sendSharedHistoryKeys = false): Promise<CompletionStates> {
88+
public invite(addresses: string[], reason?: string): Promise<CompletionStates> {
9089
if (this.addresses.length > 0) {
9190
throw new Error("Already inviting/invited");
9291
}
@@ -105,31 +104,7 @@ export default class MultiInviter {
105104
this.deferred = defer<CompletionStates>();
106105
this.inviteMore(0);
107106

108-
if (!sendSharedHistoryKeys || !this.roomId || !this.matrixClient.isRoomEncrypted(this.roomId)) {
109-
return this.deferred.promise;
110-
}
111-
112-
const room = this.matrixClient.getRoom(this.roomId);
113-
const visibilityEvent = room?.currentState.getStateEvents(EventType.RoomHistoryVisibility, "");
114-
const visibility = visibilityEvent?.getContent().history_visibility;
115-
116-
if (visibility !== HistoryVisibility.WorldReadable && visibility !== HistoryVisibility.Shared) {
117-
return this.deferred.promise;
118-
}
119-
120-
return this.deferred.promise.then(async (states): Promise<CompletionStates> => {
121-
const invitedUsers: string[] = [];
122-
for (const [addr, state] of Object.entries(states)) {
123-
if (state === InviteState.Invited && getAddressType(addr) === AddressType.MatrixUserId) {
124-
invitedUsers.push(addr);
125-
}
126-
}
127-
128-
logger.log("Sharing history with", invitedUsers);
129-
this.matrixClient.sendSharedHistoryKeys(this.roomId, invitedUsers); // do this in the background
130-
131-
return states;
132-
});
107+
return this.deferred.promise;
133108
}
134109

135110
/**

src/utils/RoomUpgrade.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ export async function upgradeRoom(
120120

121121
if (toInvite.length > 0) {
122122
// Errors are handled internally to this function
123-
await inviteUsersToRoom(cli, newRoomId, toInvite, false, () => {
123+
await inviteUsersToRoom(cli, newRoomId, toInvite, () => {
124124
progress.inviteUsersProgress!++;
125125
progressCallback?.(progress);
126126
});

0 commit comments

Comments
 (0)