Remove room key history sharing (#12618)
* Remove room key history sharing * remove string from i18n
This commit is contained in:
parent
d6b9e2aa8a
commit
6fc9d7641c
6 changed files with 8 additions and 57 deletions
|
@ -40,7 +40,6 @@ export interface IInviteResult {
|
||||||
*
|
*
|
||||||
* @param {string} roomId The ID of the room to invite to
|
* @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 {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.
|
* @param {function} progressCallback optional callback, fired after each invite.
|
||||||
* @returns {Promise} Promise
|
* @returns {Promise} Promise
|
||||||
*/
|
*/
|
||||||
|
@ -48,13 +47,10 @@ export function inviteMultipleToRoom(
|
||||||
client: MatrixClient,
|
client: MatrixClient,
|
||||||
roomId: string,
|
roomId: string,
|
||||||
addresses: string[],
|
addresses: string[],
|
||||||
sendSharedHistoryKeys = false,
|
|
||||||
progressCallback?: () => void,
|
progressCallback?: () => void,
|
||||||
): Promise<IInviteResult> {
|
): Promise<IInviteResult> {
|
||||||
const inviter = new MultiInviter(client, roomId, progressCallback);
|
const inviter = new MultiInviter(client, roomId, progressCallback);
|
||||||
return inviter
|
return inviter.invite(addresses, undefined).then((states) => Promise.resolve({ states, inviter }));
|
||||||
.invite(addresses, undefined, sendSharedHistoryKeys)
|
|
||||||
.then((states) => Promise.resolve({ states, inviter }));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function showStartChatInviteDialog(initialText = ""): void {
|
export function showStartChatInviteDialog(initialText = ""): void {
|
||||||
|
@ -105,10 +101,9 @@ export function inviteUsersToRoom(
|
||||||
client: MatrixClient,
|
client: MatrixClient,
|
||||||
roomId: string,
|
roomId: string,
|
||||||
userIds: string[],
|
userIds: string[],
|
||||||
sendSharedHistoryKeys = false,
|
|
||||||
progressCallback?: () => void,
|
progressCallback?: () => void,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
return inviteMultipleToRoom(client, roomId, userIds, sendSharedHistoryKeys, progressCallback)
|
return inviteMultipleToRoom(client, roomId, userIds, progressCallback)
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
const room = client.getRoom(roomId)!;
|
const room = client.getRoom(roomId)!;
|
||||||
showAnyInviteErrors(result.states, room, result.inviter);
|
showAnyInviteErrors(result.states, room, result.inviter);
|
||||||
|
|
|
@ -420,7 +420,7 @@ export const Commands = [
|
||||||
return success(
|
return success(
|
||||||
prom
|
prom
|
||||||
.then(() => {
|
.then(() => {
|
||||||
return inviter.invite([address], reason, true);
|
return inviter.invite([address], reason);
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
if (inviter.getCompletionState(address) !== "invited") {
|
if (inviter.getCompletionState(address) !== "invited") {
|
||||||
|
|
|
@ -22,7 +22,6 @@ import { MatrixCall } from "matrix-js-sdk/src/webrtc/call";
|
||||||
import { logger } from "matrix-js-sdk/src/logger";
|
import { logger } from "matrix-js-sdk/src/logger";
|
||||||
import { uniqBy } from "lodash";
|
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 { Icon as EmailPillAvatarIcon } from "../../../../res/img/icon-email-pill-avatar.svg";
|
||||||
import { _t, _td } from "../../../languageHandler";
|
import { _t, _td } from "../../../languageHandler";
|
||||||
import { MatrixClientPeg } from "../../../MatrixClientPeg";
|
import { MatrixClientPeg } from "../../../MatrixClientPeg";
|
||||||
|
@ -624,7 +623,7 @@ export default class InviteDialog extends React.PureComponent<Props, IInviteDial
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = await inviteMultipleToRoom(cli, this.props.roomId, targetIds, true);
|
const result = await inviteMultipleToRoom(cli, this.props.roomId, targetIds);
|
||||||
if (!this.shouldAbortAfterInviteError(result, room)) {
|
if (!this.shouldAbortAfterInviteError(result, room)) {
|
||||||
// handles setting error message too
|
// handles setting error message too
|
||||||
this.props.onFinished(true);
|
this.props.onFinished(true);
|
||||||
|
@ -1279,7 +1278,6 @@ export default class InviteDialog extends React.PureComponent<Props, IInviteDial
|
||||||
let consultConnectSection;
|
let consultConnectSection;
|
||||||
let extraSection;
|
let extraSection;
|
||||||
let footer;
|
let footer;
|
||||||
let keySharingWarning = <span />;
|
|
||||||
|
|
||||||
const identityServersEnabled = SettingsStore.getValue(UIFeature.IdentityServer);
|
const identityServersEnabled = SettingsStore.getValue(UIFeature.IdentityServer);
|
||||||
|
|
||||||
|
@ -1391,21 +1389,6 @@ export default class InviteDialog extends React.PureComponent<Props, IInviteDial
|
||||||
|
|
||||||
buttonText = _t("action|invite");
|
buttonText = _t("action|invite");
|
||||||
goButtonFn = this.inviteUsers;
|
goButtonFn = this.inviteUsers;
|
||||||
|
|
||||||
if (cli.isRoomEncrypted(this.props.roomId)) {
|
|
||||||
const room = cli.getRoom(this.props.roomId)!;
|
|
||||||
const visibilityEvent = room.currentState.getStateEvents("m.room.history_visibility", "");
|
|
||||||
const visibility =
|
|
||||||
visibilityEvent && visibilityEvent.getContent() && visibilityEvent.getContent().history_visibility;
|
|
||||||
if (visibility === "world_readable" || visibility === "shared") {
|
|
||||||
keySharingWarning = (
|
|
||||||
<p className="mx_InviteDialog_helpText">
|
|
||||||
<InfoIcon height={14} width={14} />
|
|
||||||
{" " + _t("invite|key_share_warning")}
|
|
||||||
</p>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (this.props.kind === InviteKind.CallTransfer) {
|
} else if (this.props.kind === InviteKind.CallTransfer) {
|
||||||
title = _t("action|transfer");
|
title = _t("action|transfer");
|
||||||
|
|
||||||
|
@ -1471,7 +1454,6 @@ export default class InviteDialog extends React.PureComponent<Props, IInviteDial
|
||||||
{spinner}
|
{spinner}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{keySharingWarning}
|
|
||||||
{this.renderIdentityServerWarning()}
|
{this.renderIdentityServerWarning()}
|
||||||
<div className="error">{this.state.errorText}</div>
|
<div className="error">{this.state.errorText}</div>
|
||||||
{onlyOneThreepidNote}
|
{onlyOneThreepidNote}
|
||||||
|
|
|
@ -1294,7 +1294,6 @@
|
||||||
"failed_generic": "Operation failed",
|
"failed_generic": "Operation failed",
|
||||||
"failed_title": "Failed to invite",
|
"failed_title": "Failed to invite",
|
||||||
"invalid_address": "Unrecognised address",
|
"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 <userId/>) or <a>share this room</a>.",
|
"name_email_mxid_share_room": "Invite someone using their name, email address, username (like <userId/>) or <a>share this room</a>.",
|
||||||
"name_email_mxid_share_space": "Invite someone using their name, email address, username (like <userId/>) or <a>share this space</a>.",
|
"name_email_mxid_share_space": "Invite someone using their name, email address, username (like <userId/>) or <a>share this space</a>.",
|
||||||
"name_mxid_share_room": "Invite someone using their name, username (like <userId/>) or <a>share this room</a>.",
|
"name_mxid_share_room": "Invite someone using their name, username (like <userId/>) or <a>share this room</a>.",
|
||||||
|
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
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 { KnownMembership } from "matrix-js-sdk/src/types";
|
||||||
import { defer, IDeferred } from "matrix-js-sdk/src/utils";
|
import { defer, IDeferred } from "matrix-js-sdk/src/utils";
|
||||||
import { logger } from "matrix-js-sdk/src/logger";
|
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 {array} addresses Array of addresses to invite
|
||||||
* @param {string} reason Reason for inviting (optional)
|
* @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
|
* @returns {Promise} Resolved when all invitations in the queue are complete
|
||||||
*/
|
*/
|
||||||
public invite(addresses: string[], reason?: string, sendSharedHistoryKeys = false): Promise<CompletionStates> {
|
public invite(addresses: string[], reason?: string): Promise<CompletionStates> {
|
||||||
if (this.addresses.length > 0) {
|
if (this.addresses.length > 0) {
|
||||||
throw new Error("Already inviting/invited");
|
throw new Error("Already inviting/invited");
|
||||||
}
|
}
|
||||||
|
@ -105,33 +104,9 @@ export default class MultiInviter {
|
||||||
this.deferred = defer<CompletionStates>();
|
this.deferred = defer<CompletionStates>();
|
||||||
this.inviteMore(0);
|
this.inviteMore(0);
|
||||||
|
|
||||||
if (!sendSharedHistoryKeys || !this.roomId || !this.matrixClient.isRoomEncrypted(this.roomId)) {
|
|
||||||
return this.deferred.promise;
|
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<CompletionStates> => {
|
|
||||||
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;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stops inviting. Causes promises returned by invite() to be rejected.
|
* Stops inviting. Causes promises returned by invite() to be rejected.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -120,7 +120,7 @@ export async function upgradeRoom(
|
||||||
|
|
||||||
if (toInvite.length > 0) {
|
if (toInvite.length > 0) {
|
||||||
// Errors are handled internally to this function
|
// Errors are handled internally to this function
|
||||||
await inviteUsersToRoom(cli, newRoomId, toInvite, false, () => {
|
await inviteUsersToRoom(cli, newRoomId, toInvite, () => {
|
||||||
progress.inviteUsersProgress!++;
|
progress.inviteUsersProgress!++;
|
||||||
progressCallback?.(progress);
|
progressCallback?.(progress);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue