Move PurgeDialog to Chat. Improve robustness of purge.
Also, set message retention to 60 seconds and make sure online user "forget"s room.
This commit is contained in:
parent
2d6f5d3df8
commit
12467f8a18
4 changed files with 32 additions and 24 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import olm from "@matrix-org/olm/olm";
|
||||
global.Olm = olm;
|
||||
import * as sdk from "matrix-js-sdk";
|
||||
import { TimelineWindow, EventTimeline } from "matrix-js-sdk";
|
||||
import { TimelineWindow, EventTimeline, EventStatus } from "matrix-js-sdk";
|
||||
import util, { STATE_EVENT_ROOM_DELETED } from "../plugins/utils";
|
||||
import User from "../models/user";
|
||||
|
||||
|
|
@ -403,7 +403,7 @@ export default {
|
|||
if (room.currentState.maySendStateEvent("m.room.power_levels", event.getSender())) {
|
||||
if (event.getSender() !== this.currentUserId) {
|
||||
this.leaveRoomAndNavigate(room.roomId).then(() => {
|
||||
this.matrixClient.store.removeRoom(room.roomId);
|
||||
this.matrixClient.forget(room.roomId, true);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -716,6 +716,8 @@ export default {
|
|||
purgeRoom(roomId, statusCallback) {
|
||||
this.currentRoomBeingPurged = true;
|
||||
|
||||
//console.log("Purge room");
|
||||
|
||||
const sleep = (ms) => {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||
};
|
||||
|
|
@ -744,30 +746,39 @@ export default {
|
|||
return;
|
||||
}
|
||||
|
||||
// Remove any possible pending events
|
||||
room.getLiveTimeline().getEvents().filter((e) => [EventStatus.ENCRYPTING, sdk.EventStatus.QUEUED].includes(e.status)).forEach((e) => {
|
||||
//console.log("Cancel pending event!");
|
||||
this.matrixClient.cancelPendingEvent(e);
|
||||
});
|
||||
|
||||
const timelineWindow = new TimelineWindow(this.matrixClient, room.getUnfilteredTimelineSet(), {});
|
||||
const self = this;
|
||||
|
||||
//console.log("Purge: set invite only");
|
||||
statusCallback(this.$t("room.purge_set_room_state"));
|
||||
this.matrixClient
|
||||
.sendStateEvent(roomId, "m.room.join_rules", { join_rule: "invite" }, "")
|
||||
withRetry(() => this.matrixClient.sendStateEvent(roomId, "m.room.join_rules", { join_rule: "invite" }, ""))
|
||||
.then(() => {
|
||||
//console.log("Purge: forbid guest access");
|
||||
return this.matrixClient.sendStateEvent(
|
||||
return withRetry(() => this.matrixClient.sendStateEvent(
|
||||
roomId,
|
||||
"m.room.guest_access",
|
||||
{ guest_access: "forbidden" },
|
||||
""
|
||||
);
|
||||
));
|
||||
})
|
||||
.then(() => {
|
||||
//console.log("Purge: set history visibility to 'joined'");
|
||||
return this.matrixClient.sendStateEvent(roomId, "m.room.history_visibility", {
|
||||
return withRetry(() => this.matrixClient.sendStateEvent(roomId, "m.room.history_visibility", {
|
||||
history_visibility: "joined",
|
||||
});
|
||||
}));
|
||||
})
|
||||
.then(() => {
|
||||
return this.matrixClient.sendStateEvent(roomId, STATE_EVENT_ROOM_DELETED, { status: "deleted" });
|
||||
return withRetry(() => this.matrixClient.sendStateEvent(roomId, STATE_EVENT_ROOM_DELETED, { status: "deleted" }));
|
||||
})
|
||||
.then(() => {
|
||||
// Set message retention 1 minute (may be limited by server)
|
||||
return withRetry(() => this.matrixClient.sendStateEvent(roomId, "m.room.retention", { max_lifetime: 60000 }));
|
||||
})
|
||||
.then(() => {
|
||||
//console.log("Purge: create timeline");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue