Story & Status Subsystem Architecture Spec
- Author:
Rénich Bon Ćirić
- Status:
Approved
- Type:
Technical Architecture Specification
- Date:
2026-08-24
Architectural Overview
The grm Story and Custom Emoji Status subsystem provides stateless C++23 CLI endpoints for TDLib’s Story and Status APIs, maintaining full backward and forward compatibility across local builds and system package updates.
Component Architecture
1. Module Layout
include/grm/cmd_story.hpp/src/cmd_story.cpp: Story argument parsing, interactive sticker payload builders, metadata prefetching, and execution handlers.include/grm/cmd_status.hpp/src/cmd_status.cpp: Emoji status parsing, duration calculation, and execution handlers.include/grm/json_utils.hpp/src/json_utils.cpp: RAII JSON utility wrappers includingJsonValue::get_doubleandJsonValue::as_double.include/grm/command_registry.hpp/src/command_registry.cpp: Self-registering subcommand metadata for global help and autocompletions.
2. TDLib JSON Dispatching & Preload Protocols
Story Posting & Overlays: Dispatches
postStorywithinputStoryContentPhotoorinputStoryContentVideo,storyPrivacySettings(everyone,contacts,close_friends), and interactive sticker areas viainputStoryAreas:Clickable link sticker:
inputStoryAreaTypeLinkwith normalizedstoryAreaPositioncoordinates.Suggested reaction sticker:
inputStoryAreaTypeSuggestedReactionwithreactionTypeEmoji.Upload tracking: Listens for
updateStoryPostSucceeded(and legacyupdateStorySendSucceeded) matchingold_story_idagainst the provisional story ID (>= 2,000,000,000) to confirm upload and obtain the finalized server story ID.
Story Listing: Dispatches
getChatActiveStories,getChatPostedToChatPageStories, andgetChatArchivedStories, fetching detailed story metadata viagetStorywith human-readable timestamps and pinned/posted indicators.Story Metadata Inspection: Dispatches
getStoryand formats comprehensive metadata (published date, sender ID, media type, view count, forward count, reaction count, capabilities, status, and interactive stickers).Viewers & Analytics: Dispatches
getStoryInteractionswith query filtering and pagination limits to list viewers, interaction types, and reaction emojis.Pin & Unpin Management: Dispatches
toggleStoryIsPostedToChatPageafter preloading the story into TDLib memory viagetStory.Story Reactions: Dispatches
setStoryReactionwithreactionTypeEmojiornullto remove reaction, preloaded viagetStory.Privacy Updates: Dispatches
setStoryPrivacySettingswith updatedstoryPrivacySettingspayload.Stealth Mode: Dispatches
activateStoryStealthModefor 25-minute anonymous story viewing.Story Editing: Uses TDLib
editStorywithinputStoryContentPhotoorinputStoryContentVideo, updatedinputStoryAreas, andformattedTextentities for captions.Story Deletion: Dispatches
deleteStorywithstory_poster_chat_id.Emoji Status Discovery: Dispatches
getDefaultEmojiStatuses,getRecentEmojiStatuses, andgetInstalledStickerSets(incorporating official sticker packs such asAnimated Emoji,Emoticon Emoji, andKawaii Emoji). Custom emojis in Telegram are vector document objects (TGS Lottie, WebM VP9, or WebP) identified by 64-bitdocument_id(TDLibcustom_emoji_id) with a Unicode fallbackaltstring. Document details are resolved in chunks of 50 viagetCustomEmojiStickers(extractingcustom_emoji_idfromstickerFullTypeCustomEmoji) and pack titles viagetStickerSet.Emoji Status Setting: Dispatches
setEmojiStatus(for user profiles) orsetChatEmojiStatus(for supergroups/channels) withemojiStatusTypeCustomEmoji.Emoji Status Clearing: Dispatches
setEmojiStatus/setChatEmojiStatuswithnullstatus payload.
3. Local TDLib Dependency Hierarchy & Fallback
CMake discovery prioritizes ~/.local/lib64/pkgconfig and ~/.local/lib/pkgconfig before system paths. When Fedora packages update to tdlib-devel >= 1.8.20, removal of the local prefix triggers an immediate, seamless fallback to the system library without build system reconfiguration.