mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-09-08 13:03:34 +02:00
This commit introduces the ability for you to add messages locally to a chat. These messages are displayed only on the client and are not sent to the server. Key changes include: - Data Layer: - Added a new `LocalMessage` class inheriting from `AyuMessageBase` in `ayu/data/entities.h`. - Implemented functions in `ayu/data/messages_storage.cpp` and `.h` (`addLocalMessage`, `getLocalMessages`, `hasLocalMessages`) to manage the storage of these messages in the AyuGram SQLite database, including creating a new table for local messages. - UI and Display: - Modified `ayu/ui/message_history/history_item.cpp` to ensure `LocalMessage` objects are rendered in the chat history. - Added a visual distinction for local messages by prepending "[Local] " to their text content. - UI Flow: - Implemented a new dialog box (`AddLocalMessageBox` in `boxes/add_local_message_box.cpp` and `.h`) for composing local messages, allowing you to specify a sender name (defaults to the current user) and the message text. - Added a context menu option ("Add Local Message") to the message input field in `HistoryWidget` to launch this dialog. - Testing: - Defined a suite of manual test cases covering data storage, retrieval, UI display, and the creation flow via the new UI, ensuring the feature's correctness and usability. This feature enhances AyuGram by allowing you to annotate chats or add notes directly within the message flow, visible only to yourselves.
116 lines
1.8 KiB
C++
116 lines
1.8 KiB
C++
// This is the source code of AyuGram for Desktop.
|
|
//
|
|
// We do not and cannot prevent the use of our code,
|
|
// but be respectful and credit the original author.
|
|
//
|
|
// Copyright @Radolyn, 2025
|
|
#pragma once
|
|
|
|
#include <string>
|
|
|
|
#define ID long long
|
|
|
|
class AyuMessageBase
|
|
{
|
|
public:
|
|
ID fakeId;
|
|
ID userId;
|
|
ID dialogId;
|
|
ID groupedId;
|
|
ID peerId;
|
|
ID fromId;
|
|
ID topicId;
|
|
int messageId;
|
|
int date;
|
|
int flags;
|
|
int editDate;
|
|
int views;
|
|
int fwdFlags;
|
|
ID fwdFromId;
|
|
std::string fwdName;
|
|
int fwdDate;
|
|
std::string fwdPostAuthor;
|
|
std::string postAuthor;
|
|
int replyFlags;
|
|
int replyMessageId;
|
|
ID replyPeerId;
|
|
int replyTopId;
|
|
bool replyForumTopic;
|
|
std::vector<char> replySerialized;
|
|
std::vector<char> replyMarkupSerialized;
|
|
int entityCreateDate;
|
|
std::string text;
|
|
std::vector<char> textEntities;
|
|
std::string mediaPath;
|
|
std::string hqThumbPath;
|
|
int documentType;
|
|
std::vector<char> documentSerialized;
|
|
std::vector<char> thumbsSerialized;
|
|
std::vector<char> documentAttributesSerialized;
|
|
std::string mimeType;
|
|
};
|
|
|
|
class DeletedMessage : public AyuMessageBase
|
|
{
|
|
};
|
|
|
|
class EditedMessage : public AyuMessageBase
|
|
{
|
|
};
|
|
|
|
class LocalMessage : public AyuMessageBase
|
|
{
|
|
};
|
|
|
|
class DeletedDialog
|
|
{
|
|
public:
|
|
ID fakeId;
|
|
ID userId;
|
|
ID dialogId;
|
|
ID peerId;
|
|
std::unique_ptr<int> folderId; // nullable
|
|
int topMessage;
|
|
int lastMessageDate;
|
|
int flags;
|
|
int entityCreateDate;
|
|
};
|
|
|
|
class RegexFilter
|
|
{
|
|
public:
|
|
std::vector<char> id;
|
|
std::string text;
|
|
bool enabled;
|
|
bool reversed;
|
|
bool caseInsensitive;
|
|
std::unique_ptr<ID> dialogId; // nullable
|
|
};
|
|
|
|
class RegexFilterGlobalExclusion
|
|
{
|
|
public:
|
|
ID fakeId;
|
|
ID dialogId;
|
|
std::vector<char> filterId;
|
|
};
|
|
|
|
class SpyMessageRead
|
|
{
|
|
public:
|
|
ID fakeId;
|
|
ID userId;
|
|
ID dialogId;
|
|
int messageId;
|
|
int entityCreateDate;
|
|
};
|
|
|
|
class SpyMessageContentsRead
|
|
{
|
|
public:
|
|
ID fakeId;
|
|
ID userId;
|
|
ID dialogId;
|
|
int messageId;
|
|
int entityCreateDate;
|
|
};
|