Remove room key history sharing (#12618)

* Remove room key history sharing

* remove string from i18n
This commit is contained in:
Hubert Chathi 2024-06-14 09:13:41 -04:00 committed by GitHub
parent d6b9e2aa8a
commit 6fc9d7641c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 8 additions and 57 deletions

View file

@ -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<CompletionStates> {
public invite(addresses: string[], reason?: string): Promise<CompletionStates> {
if (this.addresses.length > 0) {
throw new Error("Already inviting/invited");
}
@ -105,31 +104,7 @@ export default class MultiInviter {
this.deferred = defer<CompletionStates>();
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<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;
});
return this.deferred.promise;
}
/**