Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't allow mods to demote bot or members of management room in protected rooms #555

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

H-Shay
Copy link
Contributor

@H-Shay H-Shay commented Oct 23, 2024

No description provided.

@H-Shay H-Shay requested a review from a team as a code owner October 23, 2024 17:20
@H-Shay H-Shay marked this pull request as draft October 23, 2024 17:21
@H-Shay H-Shay changed the title Don't allow mods to demote bot in protected rooms Don't allow mods to demote bot or members of management room in protected rooms Oct 23, 2024
@H-Shay H-Shay marked this pull request as ready for review October 23, 2024 18:30
@TheArcaneBrony
Copy link

As someone involved in communities using this command often: this needs a way to be turned off, as some communities explicitly use powerlevel changes amongst themselves, if not on themselves. This would be a breaking change for them.

@turt2live
Copy link
Member

Would you be able to expand on the use case there? Power level changes should be infrequent, and demotions are questionable.

@H-Shay
Copy link
Contributor Author

H-Shay commented Oct 23, 2024

As someone involved in communities using this command often: this needs a way to be turned off, as some communities explicitly use powerlevel changes amongst themselves, if not on themselves. This would be a breaking change for them.

Would allowing a --force argument (or similiar) to override the check be sufficient?

@TheArcaneBrony
Copy link

In most cases, it's generally moderators managing their own powerlevel through mjolnir (stepping down voluntarily (taking a break, leaving, ...), taking temporary permissions for a room action like re-setting room icons, ...) or using mutes as a "hey, calm down for a moment", or just removing powerlevels to reduce unnessecary permission grants.

As suggested, a --force flag would work, though would add extra annoyances while typing commands and might just lead to moderators using --force 100% of the time.

@H-Shay H-Shay requested a review from turt2live October 28, 2024 18:30
Copy link
Member

@turt2live turt2live left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

otherwise lgtm - thanks!

for (const targetRoomId of targetRooms) {
try {
if (!force) {
if (target === mjolnirId || mjolnir.moderators.checkMembership(target)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should fail if target === mjolnirId, and level < targetLevel, even with --force

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wait, can you break that one down real quick? this sounds like you're saying it should fail when it tries to promote itself, which sounds like expected API behavior anyways?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

targetLevel is the current level - see other comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, you're trying to prevent demoting the bot itself? how would you handle gracefully removing the bot from a room, given you cant explicitly have it demote itself?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you would puppet the bot and have it demote itself. Mjolnir is tolerable to a human operator using the account at the same time (deliberately - this is also why it doesn't filter itself out when checking for commands. Worst case, a human operator can go to the management room as the bot, send a ban command, and it all works fine)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't the bot immune to self-bans via how powerlevels work? or is that not why protection-invoked selfbans fail?
besides, how does this work in an environment where humans dont possess either the login nor homeserver admin privilges, and use mjolnir to delegate permissions in an auditable fashion?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Power levels don't prevent the bot from banning itself. They also don't prevent the bot from demoting itself, either. I'm not sure what you mean by "protection-invoked selfbans", but it sounds like an unrelated issue.

At the current stage in the project, Mjolnir isn't really meant to be run on behalf of someone else. We aren't able to commit a ton of time into supporting alternative use cases at the moment, so have narrowed our maintenance scope to, roughly speaking, "matrix.org plus 10%". This means some features required by matrix.org may interfere with usage that falls outside the plus 10% range. Alternative bots, like Draupnir, have different allocations for maintenance and feature set which may be more beneficial for your particular use case.

Comment on lines 48 to 49
const targetLevel = currentLevels["users"][mjolnirId];
if (level < targetLevel) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

targetLevel at a glance feels like the destination level, making this statement a bit confusing. Maybe currentLevel would fit better?

@H-Shay H-Shay requested a review from turt2live November 6, 2024 06:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants