Event invitations in Mail, video previews, People tab, matching avatars
Invitations received by email (iMIP): above the message body, a card with when, what, where (or "Join video call"), the organizer, what else is in the calendar then (a conflict, else the previous event that day), and Yes / No / Maybe. Yes and Maybe put the event in the calendar (or update it), No takes it out — and is still shown as the answer given; each sends the organizer the iTIP REPLY, then a "Reply sent" toast, and an open calendar refreshes. A cancellation offers "Remove from calendar". It is the calendar plugin's message.banner slot (ui/invite.js, imip.py, /invitations endpoints); the SDK gains the user's own accounts and settings. An Outlook-style invitation sent only as text/calendar is now kept as invite.ics too. Calendar: clicking an empty day in the side panel's agenda opens a new event on that date; a video-call link can be removed (✕ beside Copy); the page guests see after answering, and our invitations' footer, say Ultimo Calendar (with the logo). Attachments: videos (mp4, mov, webm, …) play in the full-screen preview, paused until played; attachments are now served from disk with HTTP Range, so a video starts at once and can be seeked. People tab: everyone in the thread, the user included, A–Z, under the name any message gives them. Initials circles share one colour rule in the list, the reading pane and the People tab. The contact view drops its duplicate "Message" button. A general corner toast (webmail:toast) joins Undo's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -11,7 +11,7 @@ from typing import Annotated
|
||||
from urllib.parse import quote
|
||||
|
||||
from fastapi import APIRouter, Depends, Query
|
||||
from fastapi.responses import HTMLResponse, Response
|
||||
from fastapi.responses import FileResponse, HTMLResponse, Response
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
@@ -33,6 +33,26 @@ DbSession = Annotated[AsyncSession, Depends(get_session)]
|
||||
# Content types safe to serve inline (SPEC §10.8); everything else is forced to
|
||||
# an attachment download with a neutral type.
|
||||
_INLINE_SAFE = {"image/png", "image/jpeg", "image/gif", "image/webp", "application/pdf"}
|
||||
# Videos the browser can play, by extension — senders often label them
|
||||
# application/octet-stream. A QuickTime .mov is usually H.264 in an MP4-style
|
||||
# container: offered as video/mp4, browsers play it (an HEVC one stays unplayable,
|
||||
# and the preview offers a download instead). Media cannot run script: safe inline.
|
||||
_VIDEO_EXT_MIME = {
|
||||
"mp4": "video/mp4",
|
||||
"m4v": "video/mp4",
|
||||
"mov": "video/mp4",
|
||||
"webm": "video/webm",
|
||||
"ogv": "video/ogg",
|
||||
}
|
||||
|
||||
|
||||
def _inline_type(mime_type: str, filename: str) -> str | None:
|
||||
"""The type to serve an attachment as for in-app viewing, or None."""
|
||||
if mime_type in _INLINE_SAFE:
|
||||
return mime_type
|
||||
ext = filename.rsplit(".", 1)[-1].lower() if "." in filename else ""
|
||||
return _VIDEO_EXT_MIME.get(ext)
|
||||
|
||||
|
||||
# Base styles injected around the sanitized fragment so email content renders on a
|
||||
# readable light canvas with images that fit the pane (the iframe is sandboxed).
|
||||
@@ -309,12 +329,15 @@ async def message_attachment(
|
||||
)
|
||||
if att is None:
|
||||
raise_api_error(404, "not_found", "attachment not found")
|
||||
data = blobstore.load(msg.user_id, att.blob_sha256)
|
||||
inline = att.mime_type in _INLINE_SAFE and not download
|
||||
media_type = att.mime_type if inline else "application/octet-stream"
|
||||
disposition = "inline" if inline else "attachment"
|
||||
return Response(
|
||||
content=data,
|
||||
media_type=media_type,
|
||||
path = blobstore.blob_path(msg.user_id, att.blob_sha256)
|
||||
if not path.exists():
|
||||
raise_api_error(404, "not_found", "attachment content missing")
|
||||
inline_type = None if download else _inline_type(att.mime_type, att.filename)
|
||||
disposition = "inline" if inline_type else "attachment"
|
||||
# Streamed from disk, with HTTP Range: a video can be played and seeked
|
||||
# without being sent whole first (Safari will not play one otherwise).
|
||||
return FileResponse(
|
||||
path,
|
||||
media_type=inline_type or "application/octet-stream",
|
||||
headers={"Content-Disposition": _content_disposition(disposition, att.filename)},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user