aboutsummaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-02-11 22:23:58 +0100
committerdec05eba <dec05eba@protonmail.com>2021-02-11 22:26:41 +0100
commitba0f42d30f87ca80ac933137cba5995f4f2c39bf (patch)
tree9927c96454c2f047e68f1e6a09d949e456d66350 /src/plugins
parent41d7a62457a48d7d76a226bb7bd3d562500dddc2 (diff)
Matrix: mark local edit/reply as read
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/Matrix.cpp24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp
index a47b588..2b72f03 100644
--- a/src/plugins/Matrix.cpp
+++ b/src/plugins/Matrix.cpp
@@ -1857,12 +1857,12 @@ namespace QuickMedia {
if(origin_server_ts.IsInt64())
timestamp = origin_server_ts.GetInt64();
- bool provisional = false;
+ std::string transaction_id;
const rapidjson::Value &unsigned_json = GetMember(event_item_json, "unsigned");
if(unsigned_json.IsObject()) {
const rapidjson::Value &transaction_id_json = GetMember(unsigned_json, "transaction_id");
if(transaction_id_json.IsString() && my_events_transaction_ids.find(transaction_id_json.GetString()) != my_events_transaction_ids.end())
- provisional = true;
+ transaction_id = std::string(transaction_id_json.GetString(), transaction_id_json.GetStringLength());
}
RelatedEventType related_event_type = RelatedEventType::NONE;
@@ -1892,7 +1892,7 @@ namespace QuickMedia {
message->related_event_id = relates_to_event_id_json.GetString();
message->related_event_type = RelatedEventType::REACTION;
message->timestamp = timestamp;
- message->provisional = provisional;
+ message->transaction_id = std::move(transaction_id);
return message;
}
}
@@ -1911,7 +1911,7 @@ namespace QuickMedia {
message->body = "Message deleted";
message->timestamp = timestamp;
message->related_event_type = RelatedEventType::REDACTION;
- message->provisional = provisional;
+ message->transaction_id = std::move(transaction_id);
const rapidjson::Value &reason_json = GetMember(*content_json, "reason");
if(reason_json.IsString()) {
@@ -2033,7 +2033,7 @@ namespace QuickMedia {
message->related_event_id = std::move(related_event_id);
message->related_event_type = related_event_type;
message->timestamp = timestamp;
- message->provisional = provisional;
+ message->transaction_id = std::move(transaction_id);
return message;
} else {
auto message = std::make_shared<Message>();
@@ -2044,7 +2044,7 @@ namespace QuickMedia {
message->related_event_id = std::move(related_event_id);
message->related_event_type = related_event_type;
message->timestamp = timestamp;
- message->provisional = provisional;
+ message->transaction_id = std::move(transaction_id);
return message;
}
@@ -2118,7 +2118,7 @@ namespace QuickMedia {
message->related_event_id = std::move(related_event_id);
message->related_event_type = related_event_type;
message->timestamp = timestamp;
- message->provisional = provisional;
+ message->transaction_id = std::move(transaction_id);
return message;
}
@@ -2541,7 +2541,7 @@ namespace QuickMedia {
return result.str();
}
- static std::string create_transaction_id() {
+ std::string create_transaction_id() {
char random_characters[18];
if(!generate_random_characters(random_characters, sizeof(random_characters)))
return "";
@@ -2751,13 +2751,17 @@ namespace QuickMedia {
}
// TODO: Support greentext
- PluginResult Matrix::post_reply(RoomData *room, const std::string &body, void *relates_to, std::string &event_id_response) {
+ PluginResult Matrix::post_reply(RoomData *room, const std::string &body, void *relates_to, std::string &event_id_response, const std::string &custom_transaction_id) {
// TODO: Store shared_ptr<Message> instead of raw pointer...
Message *relates_to_message_raw = (Message*)relates_to;
- std::string transaction_id = create_transaction_id();
+ std::string transaction_id = custom_transaction_id;
+ if(transaction_id.empty())
+ transaction_id = create_transaction_id();
+
if(transaction_id.empty())
return PluginResult::ERR;
+
my_events_transaction_ids.insert(transaction_id);
rapidjson::Document in_reply_to_json(rapidjson::kObjectType);