Private
Public Access
Add #roomname references in chat messages (#47)
Mirrors the existing @-mention system's shape: a regex finds #roomname tokens, extract_referenced_room_ids validates them against rooms the *sender* actually belongs to (mirrors mentions' "must be a real member" rule -- referencing a private room the sender isn't in would otherwise leak its existence), and a MessageRoomReference join row is stored per match in create_message. No notification/unread layer, unlike mentions -- referencing a room has no "you were referenced" semantics. Rendering is the same markdown-link rewrite trick MessageContent.tsx already uses for mentions (#username -> [#username](mention:username)), but resolved against the *viewer's* own room list (threaded down from ChatShellPage's room state through ChatPane/MessageList) rather than the stored server-side reference -- a reference to a room the current viewer isn't in quietly renders as plain text instead of a link, same as an @mention of someone outside the room does. The href scheme renders a real react-router Link instead of mentions' inert span, since a room reference is meant to be navigable. mention_service.strip_code_spans (was _strip_code_spans) is now shared between both extraction paths rather than private to one module. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
"""message room references for hash roomname links
|
||||
|
||||
Revision ID: 9484fbd1cb3a
|
||||
Revises: f3ec1c1d1992
|
||||
Create Date: 2026-08-17 18:57:16.584680
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '9484fbd1cb3a'
|
||||
down_revision: Union[str, Sequence[str], None] = 'f3ec1c1d1992'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""Upgrade schema."""
|
||||
op.create_table(
|
||||
"message_room_references",
|
||||
sa.Column("message_id", sa.Uuid(), nullable=False),
|
||||
sa.Column("room_id", sa.Uuid(), nullable=False),
|
||||
sa.ForeignKeyConstraint(["message_id"], ["messages.id"]),
|
||||
sa.ForeignKeyConstraint(["room_id"], ["rooms.id"]),
|
||||
sa.PrimaryKeyConstraint("message_id", "room_id"),
|
||||
)
|
||||
op.create_index(
|
||||
op.f("ix_message_room_references_room_id"),
|
||||
"message_room_references",
|
||||
["room_id"],
|
||||
unique=False,
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
op.drop_index(
|
||||
op.f("ix_message_room_references_room_id"), table_name="message_room_references"
|
||||
)
|
||||
op.drop_table("message_room_references")
|
||||
Reference in New Issue
Block a user