mirror of
https://github.com/element-hq/element-web
synced 2024-11-27 11:47:23 +03:00
Check whether user has permission to invite
Signed-off-by: Jaiwanth <jaiwanth2011@gmail.com>
This commit is contained in:
parent
f420c85985
commit
04d2bf1d6a
2 changed files with 18 additions and 6 deletions
|
@ -462,6 +462,16 @@ export default class RoomTile extends React.PureComponent<IProps, IState> {
|
|||
const isLowPriority = roomTags.includes(DefaultTagID.LowPriority);
|
||||
const lowPriorityLabel = _t("Low Priority");
|
||||
|
||||
const inRoom = this.props.room && this.props.room.getMyMembership() === "join";
|
||||
const userId = MatrixClientPeg.get().getUserId();
|
||||
let canInvite = inRoom;
|
||||
const powerLevels = this.props.room.currentState
|
||||
.getStateEvents("m.room.power_levels", "")
|
||||
?.getContent();
|
||||
const me = this.props.room.getMember(userId);
|
||||
if (powerLevels && me && powerLevels.invite > me.powerLevel) {
|
||||
canInvite = false;
|
||||
}
|
||||
contextMenu = <IconizedContextMenu
|
||||
{...contextMenuBelow(this.state.generalMenuPosition)}
|
||||
onFinished={this.onCloseGeneralMenu}
|
||||
|
@ -481,11 +491,13 @@ export default class RoomTile extends React.PureComponent<IProps, IState> {
|
|||
label={lowPriorityLabel}
|
||||
iconClassName="mx_RoomTile_iconArrowDown"
|
||||
/>
|
||||
<IconizedContextMenuOption
|
||||
onClick={this.onInviteClick}
|
||||
label={_t("Invite to this room")}
|
||||
iconClassName="mx_RoomTile_iconInvite"
|
||||
/>
|
||||
{canInvite ? (
|
||||
<IconizedContextMenuOption
|
||||
onClick={this.onInviteClick}
|
||||
label={_t("Invite to this room")}
|
||||
iconClassName="mx_RoomTile_iconInvite"
|
||||
/>
|
||||
) : null}
|
||||
<IconizedContextMenuOption
|
||||
onClick={this.onOpenRoomSettings}
|
||||
label={_t("Settings")}
|
||||
|
|
Loading…
Reference in a new issue