Skip to content

Add kick extension and user management services#18

Open
chrisdedman wants to merge 8 commits into
mainfrom
mod-kick
Open

Add kick extension and user management services#18
chrisdedman wants to merge 8 commits into
mainfrom
mod-kick

Conversation

@chrisdedman

Copy link
Copy Markdown
Contributor

Added the kick extension for managing user removal from rooms and spaces, along with service modules for user management (which can be used for other moderation extension such as ban, mute, etc)

@chrisdedman chrisdedman requested a review from PenguinBoi12 June 16, 2026 00:20
@chrisdedman chrisdedman self-assigned this Jun 16, 2026

@PenguinBoi12 PenguinBoi12 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

In general it's good, there's going to be refactor needed eventually when adding support for Space but for now the services are fine.

There's one big issue though... There's no permission check on the command. This means everyone can run kick anyone through that command. I think in general we want to restrict this extension to admin/moderator only through a check if possible. It's a good time to implement reusable permission check for Ada (perhaps it could even be added as part of the default checks in matrix.py directly eventually).

I'm not sure why you used getattr everywhere, you want to avoid using that as much as possible unless it's absolutely necessary, which is rare.

It would be great to have tests.

Comment thread bot/extensions/moderation/kick_extension.py Outdated
Comment thread bot/extensions/moderation/kick_extension.py Outdated
Comment thread bot/extensions/moderation/kick_service.py Outdated
Comment thread bot/extensions/moderation/kick_service.py Outdated
Comment thread bot/extensions/moderation/space_service.py Outdated
Comment thread bot/extensions/moderation/space_service.py Outdated
Comment thread bot/extensions/moderation/space_service.py Outdated
Comment thread bot/extensions/moderation/space_service.py Outdated
Comment thread bot/extensions/moderation/space_service.py Outdated
@chrisdedman chrisdedman requested a review from PenguinBoi12 June 17, 2026 02:15
Comment thread bot/permissions.py
return moderators


async def is_moderator(ctx: Context) -> bool:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This could be fine for now, but I'm sure we can check a user's permission differently.

@PenguinBoi12 PenguinBoi12 Jun 18, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

depth: int = 0,
) -> None:
"""Collect non-space child room IDs from a Matrix space."""
if depth >= 10:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think we can reduce this to 3 since, from what I researched, most clients limit it to 3.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Also, we might want to log it and ideally find a way to notify admins that we reached the max depth. I have a couple of ideas. Like, raising an error that will notify us that we reached the max depth and that it needs to be ran with a flag enabled to "force it"/means we acknowledged it. (the error would also return the space at the max depth so we can use it later on.

Comment thread bot/extensions/moderation/space_service.py
Comment thread bot/extensions/moderation/space_service.py
Comment thread bot/extensions/moderation/space_service.py
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.

2 participants