Skip to content

fix: save and display media in message history#381

Open
denfry wants to merge 1 commit into
AyuGram:devfrom
denfry:dev
Open

fix: save and display media in message history#381
denfry wants to merge 1 commit into
AyuGram:devfrom
denfry:dev

Conversation

@denfry

@denfry denfry commented Jun 2, 2026

Copy link
Copy Markdown

Problem

Deleted and edited messages with media (photos, videos, voice notes, stickers, GIFs, etc.) were stored in the database with a stub mediaPath = "/" and documentType = 0. The history viewer always passed MTP_messageMediaEmpty() to makeMessage(), so real media was never shown — only a text placeholder like "Photo" or "Video".

Solution

Storage (ayu_mapper.cpp, messages_storage.cpp):

  • Added kDocumentType* constants for media type classification
  • Added AyuMapper::mapMediaToMessage() which serializes MTPInputDocument / MTPInputPhoto into documentSerialized, sets documentType, mimeType, and mediaPath if the file is locally cached
  • Replaced the stub block in map() with a single AyuMapper::mapMediaToMessage(item, message) call

Display (history_item.cpp):

  • Added resolveMedia() lambda in GenerateItems() that deserializes the stored input, looks up the document/photo from session cache, and reconstructs a minimal MTPDocument / MTPPhoto
  • Document attributes are reconstructed from DocumentData public API: video (with round_message / supports_streaming flags), animated, sticker, audio/song, voice — so media renders with correct icons and controls
  • Falls back to existing text placeholder when session cache has been evicted

Notes

  • Documents are reconstructed without thumbnail sizes (no public API), but are downloadable and render correctly
  • This PR was AI-generated.

@denfry denfry changed the title fix: reset DPR on scaled tray icon logo to fix counter misalignment at high DPI fix: save and display media in message history Jun 2, 2026
…ter and group deletion issues

- Reset DPR on scaled tray icon logo to fix counter misalignment at high DPI
  AyuAssets::currentAppLogo() sets devicePixelRatio to style::DevicePixelRatio()
  (e.g. 2.0 at 200% scaling). After scaledToWidth() Qt preserves that DPR,
  making the logical canvas smaller than args.size while WithSmallCounter uses
  args.size as drawing coordinates — causing the badge to render partially
  outside bounds (visible as a grey triangle). Upstream loads from PNG files
  (DPR=1), so this mismatch only affects AyuGram. Fixes AyuGram#310

- Save and display media in message history
  Deleted/edited messages with media (photos, videos, voice notes, stickers, etc.)
  only stored a text placeholder. Media metadata was never serialized to the DB
  and the history viewer always passed MTP_messageMediaEmpty() to makeMessage().
  Added kDocumentType* constants, AyuMapper::mapMediaToMessage() to serialize
  MTPInputDocument/MTPInputPhoto into documentSerialized, and resolveMedia()
  lambda in GenerateItems() to reconstruct MTPDocument/MTPPhoto with proper
  attributes (video, sticker, voice, audio, animated) for correct rendering

- Save media-only deleted messages with type placeholder
- Show delete own messages option for admins and creators in groups
- Save expired TTL messages deleted via auto-delete in groups
- Remove deleted messages from shared media index to fix incorrect counts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant