Merge pull request #125 from Empty2k12/fix/powerlevel-sending

Disallow sending messages to rooms with insufficient powerlevel
This commit is contained in:
Krishan 2021-09-30 21:00:00 +05:30 committed by GitHub
commit 3deb8eb488
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View file

@ -327,7 +327,15 @@ function RoomViewInput({
if (file !== null) roomsInput.setAttachment(roomId, file); if (file !== null) roomsInput.setAttachment(roomId, file);
} }
const myPowerlevel = roomTimeline.room.getMember(mx.getUserId()).powerLevel;
const canISend = roomTimeline.room.currentState.hasSufficientPowerLevelFor('events_default', myPowerlevel);
function renderInputs() { function renderInputs() {
if (!canISend) {
return (
<Text className="room-input__disallowed">You do not have permission to post to this room</Text>
);
}
return ( return (
<> <>
<div className={`room-input__option-container${attachment === null ? '' : ' room-attachment__option'}`}> <div className={`room-input__option-container${attachment === null ? '' : ' room-attachment__option'}`}>

View file

@ -3,6 +3,11 @@
display: flex; display: flex;
min-height: 48px; min-height: 48px;
&__disallowed {
flex: 1;
text-align: center;
}
&__space { &__space {
min-width: 0; min-width: 0;
align-self: center; align-self: center;