aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-10-22 21:56:33 +0200
committerdec05eba <dec05eba@protonmail.com>2020-10-22 21:56:33 +0200
commit97564d40636aafb251644f61a0b990e392afd7a4 (patch)
treed6cb19849445d4d2683024072f1966c7bb17c619 /plugins
parent42ef59ef17cb0a56c6ac1d8f220db7ca461c5411 (diff)
Matrix: add pinned messages tab
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Matrix.hpp22
1 files changed, 17 insertions, 5 deletions
diff --git a/plugins/Matrix.hpp b/plugins/Matrix.hpp
index f24a08f..c3c5539 100644
--- a/plugins/Matrix.hpp
+++ b/plugins/Matrix.hpp
@@ -78,6 +78,8 @@ namespace QuickMedia {
// Ignores duplicates
void append_messages(const std::vector<std::shared_ptr<Message>> &new_messages);
+ void append_pinned_events(std::vector<std::string> new_pinned_events);
+
std::shared_ptr<Message> get_message_by_id(const std::string &id);
std::vector<std::shared_ptr<UserInfo>> get_users_excluding_me(const std::string &my_user_id);
@@ -86,6 +88,7 @@ namespace QuickMedia {
void release_room_lock();
const std::vector<std::shared_ptr<Message>>& get_messages_thread_unsafe() const;
+ const std::vector<std::string>& get_pinned_events_unsafe() const;
std::string id;
std::string name;
@@ -111,6 +114,7 @@ namespace QuickMedia {
std::unordered_map<std::string, std::shared_ptr<UserInfo>> user_info_by_user_id;
std::vector<std::shared_ptr<Message>> messages;
std::unordered_map<std::string, std::shared_ptr<Message>> message_by_event_id;
+ std::vector<std::string> pinned_events;
};
enum class MessageDirection {
@@ -127,16 +131,23 @@ namespace QuickMedia {
};
using Messages = std::vector<std::shared_ptr<Message>>;
- using RoomSyncMessages = std::unordered_map<RoomData*, Messages>;
+
+ struct SyncData {
+ Messages messages;
+ std::vector<std::string> pinned_events;
+ };
+
+ using RoomSyncData = std::unordered_map<RoomData*, SyncData>;
using Rooms = std::vector<RoomData*>;
bool message_contains_user_mention(const std::string &msg, const std::string &username);
class Matrix {
public:
- PluginResult sync(RoomSyncMessages &room_messages);
+ PluginResult sync(RoomSyncData &room_sync_data);
void get_room_join_updates(Rooms &new_rooms);
- PluginResult get_all_synced_room_messages(RoomData *room, Messages &messages);
+ void get_all_synced_room_messages(RoomData *room, Messages &messages);
+ void get_all_pinned_events(RoomData *room, std::vector<std::string> &events);
PluginResult get_previous_room_messages(RoomData *room, Messages &messages);
// |url| should only be set when uploading media.
@@ -176,12 +187,13 @@ namespace QuickMedia {
bool use_tor = false;
private:
- PluginResult sync_response_to_body_items(const rapidjson::Document &root, RoomSyncMessages &room_messages);
+ PluginResult sync_response_to_body_items(const rapidjson::Document &root, RoomSyncData &room_sync_data);
PluginResult get_previous_room_messages(RoomData *room_data);
void events_add_user_info(const rapidjson::Value &events_json, RoomData *room_data);
void events_add_user_read_markers(const rapidjson::Value &events_json, RoomData *room_data);
- void events_add_messages(const rapidjson::Value &events_json, RoomData *room_data, MessageDirection message_dir, RoomSyncMessages *room_messages, bool has_unread_notifications);
+ void events_add_messages(const rapidjson::Value &events_json, RoomData *room_data, MessageDirection message_dir, RoomSyncData *room_sync_data, bool has_unread_notifications);
void events_set_room_name(const rapidjson::Value &events_json, RoomData *room_data);
+ void events_add_pinned_events(const rapidjson::Value &events_json, RoomData *room_data, RoomSyncData &room_sync_data);
std::shared_ptr<Message> parse_message_event(const rapidjson::Value &event_item_json, RoomData *room_data);
PluginResult upload_file(RoomData *room, const std::string &filepath, UploadInfo &file_info, UploadInfo &thumbnail_info, std::string &err_msg);