Extend the notification system to include member leave, kick and ban events,
mirroring the existing join notification functionality.
### Changes
- Added `_handle_leave_notifications` to process LEAVE, KICK and BAN events
- Integrated new notifications into existing membership event handlers
- Introduced `{actor}` placeholder with Matrix URI pill support
- Added `{actor_display}` as plaintext fallback
- Extended template renderer to support actor context
- Ensured consistent rendering across plaintext and HTML messages
- Added template cleanup for cases without an actor (e.g. voluntary leave)
### Templates
New placeholders:
- `{actor}` → clickable Matrix user pill
- `{actor_display}` → plain display name
### Configuration
New config keys:
- `leave_notification_message`
- `kick_notification_message`
- `ban_notification_message`
### Notes
- Fully async and non-blocking implementation
- Backwards compatible with existing templates
- No impact on join notification logic
- Scoped to rooms within configured space
This change introduces native `matrix:` URI-based rendering for `{user}` and `{room}` placeholders,
replacing previous plaintext and matrix.to-based links. Users and rooms are now rendered as clickable
pills in supporting clients, with a clean display using display names and room names (no @/# prefixes).
Reporting, moderation, and auto-redaction messages have been updated to use the same rendering logic.
Inspect and event links now also use native `matrix:` URIs for direct in-client navigation.
Internally, URI generation and rendering logic have been unified via central helper functions,
ensuring consistent handling of user IDs, room IDs, aliases, and event IDs.
This commit also includes a broader refactor of the codebase:
- decomposed complex flows (e.g. join handling) into smaller helpers
- moved mutable class-level state to instance-level
- reduced duplicate API calls and redundant logic
- improved overall structure and maintainability
Test coverage has been extended for URI helpers and rendering logic to prevent regressions.
No breaking changes to existing template parameters like `{user_link}` or `{room_link}`.