edd3eee178
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}`.
39 lines
1.3 KiB
Python
39 lines
1.3 KiB
Python
from __future__ import annotations
|
|
|
|
from mautrix.util.async_db import UpgradeTable, Connection
|
|
|
|
upgrade_table = UpgradeTable()
|
|
|
|
@upgrade_table.register(description="Table initialization")
|
|
async def upgrade_v1(conn: Connection) -> None:
|
|
await conn.execute(
|
|
"""CREATE TABLE user_events (
|
|
mxid TEXT PRIMARY KEY,
|
|
last_message_timestamp BIGINT NOT NULL,
|
|
ignore_inactivity INT
|
|
)"""
|
|
)
|
|
|
|
@upgrade_table.register(description="Include message redaction tracking")
|
|
async def upgrade_v2(conn: Connection) -> None:
|
|
await conn.execute(
|
|
"""CREATE TABLE redaction_tasks (
|
|
event_id TEXT PRIMARY KEY,
|
|
room_id TEXT NOT NULL
|
|
)"""
|
|
)
|
|
|
|
@upgrade_table.register(description="Add verification states table")
|
|
async def upgrade_v3(conn: Connection) -> None:
|
|
await conn.execute(
|
|
"""CREATE TABLE verification_states (
|
|
dm_room_id TEXT PRIMARY KEY,
|
|
user_id TEXT NOT NULL,
|
|
target_room_id TEXT NOT NULL,
|
|
verification_phrase TEXT NOT NULL,
|
|
attempts_remaining INTEGER NOT NULL,
|
|
required_power_level INTEGER NOT NULL,
|
|
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
)"""
|
|
)
|