// SPDX-FileCopyrightText: 2026 Matvey Shcherbinin // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL #pragma once #include #include #include struct MessageEntry { QString sender; // The id behind the name: a Matrix user id or a Telegram user id, empty // where a backend has no per-row sender (a LAN peer chat is one person, so // the chat's own id is theirs). The card a message avatar opens is asked // for by this id, not by the name, because a display name is a label two // members of a room are allowed to share and an id is not. QString senderId; QString avatarUrl; // media URL of the sender's avatar, empty when none QString text; QString formattedText; double ts = 0.0; // unix timestamp, seconds (fractional) bool isOwn = false; QString color = QStringLiteral("#E0E0E0"); QString msgType = QStringLiteral("public"); // "public" | "private" | "group" bool isSystem = false; bool isEdited = false; QString replyToText; QString replyToSender; QString replyToId; QString chatId; QString msgId; bool isFile = false; QString filePath; // local path once downloaded/attached bool isImage = false; // an attachment that lives on a server rather than on this disk. A LAN // transfer has already put its file here and fills filePath instead; these // are the Matrix side, where the bytes are fetched by whatever loads the // URL and there is no local path to point at. Never both at once. QString mediaKind; // "", "image", "video", "audio" or "file" QString mediaUrl; // empty for anything but a picture, and empty again for a picture this // server could not scale. Kept next to the url it belongs to so a row read // back from the history file draws the same way it did when it was sent. QString mediaThumbnailUrl; QString mediaMime; qint64 mediaSize = 0; // as the sender reported them. Used to reserve the right space before the // download finishes, so the timeline does not jump under whoever is reading. int mediaWidth = 0; int mediaHeight = 0; int mediaDurationMs = 0; bool isRead = false; // A poll this row carries, empty unless it is one. Keys: question (string), // answers (list of {id, body}), disclosed (bool). Votes are tracked by the // bridge, not stored here, so a reload shows the question without the tally. QVariantMap poll; // True between an outgoing message appearing in the timeline and its // datagram being written. Not serialised - a "sending" state that survived // a restart would never resolve. bool pending = false; MessageEntry() = default; static MessageEntry fromJson(const QJsonObject &o); QJsonObject toJson() const; QVariantMap toVariantMap() const; void ensureMsgId() { if (msgId.isEmpty()) msgId = QString::number(ts, 'f', 3); } };