From ecc4a40eeaeea2a7f04865f9b0766a9a0969056e Mon Sep 17 00:00:00 2001 From: Gero Gerke Date: Thu, 30 Sep 2021 16:16:43 +0200 Subject: [PATCH 1/2] Disallow sending to rooms with insufficient powerlevel Fixes #123 --- src/app/organisms/room/RoomViewInput.jsx | 8 ++++++++ src/app/organisms/room/RoomViewInput.scss | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/src/app/organisms/room/RoomViewInput.jsx b/src/app/organisms/room/RoomViewInput.jsx index edad9c9..20886c2 100644 --- a/src/app/organisms/room/RoomViewInput.jsx +++ b/src/app/organisms/room/RoomViewInput.jsx @@ -327,7 +327,15 @@ function RoomViewInput({ 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() { + if (!canISend) { + return ( +

You do not have permission to post to this room

+ ); + } return ( <>
diff --git a/src/app/organisms/room/RoomViewInput.scss b/src/app/organisms/room/RoomViewInput.scss index 112a4c4..a9d58f4 100644 --- a/src/app/organisms/room/RoomViewInput.scss +++ b/src/app/organisms/room/RoomViewInput.scss @@ -3,6 +3,12 @@ display: flex; min-height: 48px; + &__disallowed { + color: var(--tc-surface-low); + flex: 1; + text-align: center; + } + &__space { min-width: 0; align-self: center; From 1dd7f0371d9bef934295b5fb8d9b9df93713d089 Mon Sep 17 00:00:00 2001 From: kfiven <33421343+kfiven@users.noreply.github.com> Date: Thu, 30 Sep 2021 20:56:39 +0530 Subject: [PATCH 2/2] Changed p to Text component --- src/app/organisms/room/RoomViewInput.jsx | 2 +- src/app/organisms/room/RoomViewInput.scss | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/app/organisms/room/RoomViewInput.jsx b/src/app/organisms/room/RoomViewInput.jsx index 20886c2..6c354ed 100644 --- a/src/app/organisms/room/RoomViewInput.jsx +++ b/src/app/organisms/room/RoomViewInput.jsx @@ -333,7 +333,7 @@ function RoomViewInput({ function renderInputs() { if (!canISend) { return ( -

You do not have permission to post to this room

+ You do not have permission to post to this room ); } return ( diff --git a/src/app/organisms/room/RoomViewInput.scss b/src/app/organisms/room/RoomViewInput.scss index a9d58f4..9e0f1a9 100644 --- a/src/app/organisms/room/RoomViewInput.scss +++ b/src/app/organisms/room/RoomViewInput.scss @@ -4,7 +4,6 @@ min-height: 48px; &__disallowed { - color: var(--tc-surface-low); flex: 1; text-align: center; }