Private
Public Access
Expand direct image links instead of showing nothing (#43 follow-up)
A URL that points straight at an image file (Content-Type: image/*) has no HTML to scrape Open Graph tags from, so the fetch found nothing and the message showed no preview at all -- reported against https://imgs.xkcd.com/comics/creepy.png. link_preview_service now recognizes an allowed image content-type (same list storage.py uses for uploads) before falling through to the HTML/og: path, and returns the URL itself as the preview (LinkPreview.is_image). No need to download the body -- the already-SSRF-validated URL is the image. The frontend renders that case as a real expandable image (message-image + lightbox, same as an actual attachment) instead of the small title+description card, which would have nothing to show anyway. Verified end-to-end against the reported URL. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
"""link previews flag direct image links
|
||||
|
||||
Revision ID: f3ec1c1d1992
|
||||
Revises: d00f93766fa5
|
||||
Create Date: 2026-08-17 17:56:19.078087
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = 'f3ec1c1d1992'
|
||||
down_revision: Union[str, Sequence[str], None] = 'd00f93766fa5'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""Upgrade schema."""
|
||||
# NOT NULL with a *constant* server_default (unlike a volatile one such
|
||||
# as now()/clock_timestamp()) doesn't force a table rewrite in Postgres
|
||||
# 11+ -- it's a metadata-only change, safe and instant regardless of
|
||||
# table size.
|
||||
op.add_column(
|
||||
"link_previews",
|
||||
sa.Column("is_image", sa.Boolean(), nullable=False, server_default=sa.false()),
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
op.drop_column("link_previews", "is_image")
|
||||
Reference in New Issue
Block a user