Add kick,ban,make admin and make moderator operations
This commit is contained in:
parent
c9b033e637
commit
9081e34aa7
23 changed files with 281 additions and 27 deletions
|
|
@ -356,19 +356,22 @@ export default {
|
|||
event.getRoomId() == this.currentRoom.roomId
|
||||
) {
|
||||
// Don't use this.currentRoomId, may be an alias. We need the real id!
|
||||
if (
|
||||
if ((
|
||||
event.getContent().membership == "leave" &&
|
||||
(event.getPrevContent() || {}).membership == "join" &&
|
||||
event.getStateKey() == this.currentUserId &&
|
||||
event.getSender() != this.currentUserId
|
||||
) {
|
||||
// We were kicked
|
||||
) || (event.getContent().membership == "ban" && event.getStateKey() == this.currentUserId)) {
|
||||
// We were kicked or banned
|
||||
// If this is a live event (not just backpaging) then redirect to goodbye!
|
||||
if (this.matrixClientReady) {
|
||||
const wasPurged =
|
||||
event.getContent().reason == "Room Deleted";
|
||||
this.$navigation.push(
|
||||
{ name: "Goodbye", params: { roomWasPurged: wasPurged } },
|
||||
-1
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -546,6 +549,63 @@ export default {
|
|||
});
|
||||
},
|
||||
|
||||
kickUser(roomId, userId) {
|
||||
if (this.matrixClient && roomId && userId) {
|
||||
this.matrixClient.kick(
|
||||
roomId,
|
||||
userId,
|
||||
""
|
||||
)
|
||||
}
|
||||
},
|
||||
|
||||
banUser(roomId, userId) {
|
||||
if (this.matrixClient && roomId && userId) {
|
||||
this.matrixClient.ban(
|
||||
roomId,
|
||||
userId,
|
||||
""
|
||||
)
|
||||
}
|
||||
},
|
||||
|
||||
makeAdmin(roomId, userId) {
|
||||
if (this.matrixClient && roomId && userId) {
|
||||
const room = this.getRoom(roomId);
|
||||
if (room && room.currentState) {
|
||||
const powerLevelEvent = room.currentState.getStateEvents("m.room.power_levels", "");
|
||||
if (powerLevelEvent) {
|
||||
this.matrixClient.setPowerLevel(roomId, userId, 100, powerLevelEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
makeModerator(roomId, userId) {
|
||||
if (this.matrixClient && roomId && userId) {
|
||||
const room = this.getRoom(roomId);
|
||||
console.log("Room", room);
|
||||
if (room && room.currentState) {
|
||||
const powerLevelEvent = room.currentState.getStateEvents("m.room.power_levels", "");
|
||||
if (powerLevelEvent) {
|
||||
this.matrixClient.setPowerLevel(roomId, userId, 50, powerLevelEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
revokeModerator(roomId, userId) {
|
||||
if (this.matrixClient && roomId && userId) {
|
||||
const room = this.getRoom(roomId);
|
||||
if (room && room.currentState) {
|
||||
const powerLevelEvent = room.currentState.getStateEvents("m.room.power_levels", "");
|
||||
if (powerLevelEvent) {
|
||||
this.matrixClient.setPowerLevel(roomId, userId, 0, powerLevelEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purge the room with the given id! This means:
|
||||
* - Make room invite only
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue