aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-10-05 09:12:41 +0200
committerdec05eba <dec05eba@protonmail.com>2020-10-05 09:15:34 +0200
commit27d5c7dcc37b0064801741a7c1e5500160c4c2d7 (patch)
tree62db36d36d462e7757585eb77467a9d3c0c1e8a7
parentcfef90021917df0052bb49e9e35298260e7ca38c (diff)
Commit before redesign of code
-rw-r--r--TODO3
-rw-r--r--matrix-requests-todo/org.matrix.poll.json34
-rw-r--r--src/plugins/Matrix.cpp33
3 files changed, 44 insertions, 26 deletions
diff --git a/TODO b/TODO
index 93f7396..829b9df 100644
--- a/TODO
+++ b/TODO
@@ -88,4 +88,5 @@ Add url preview for matrix (using matrix api, fallback to client url preview (us
IMPORTANT: Cleanup old messages in matrix (from matrix plugin), and instead either save them to disk or refetch them from server when going up to read old messages. (High memory usage, high disk space)
Use memberName() instead of key() when iterating json object. key() creates a copy, memberName() doesn't.
Do not try to reload/redownload thumbnail that fails to download after its cleared when its no longer visible on screen and then becomes visible.
-Sort matrix events by timestamp (not messages). This affects the applying of certain actions, such as changing avatar, room name, etc. \ No newline at end of file
+Sort matrix events by timestamp (not messages). This affects the applying of certain actions, such as changing avatar, room name, etc.
+Some services such as 4chan, youtube, matrix and nyaa supports knowing the size of an image before it has downloaded. Use that to deal with pop-in of images because the image fallback size is not the same as the image size. \ No newline at end of file
diff --git a/matrix-requests-todo/org.matrix.poll.json b/matrix-requests-todo/org.matrix.poll.json
new file mode 100644
index 0000000..c980e58
--- /dev/null
+++ b/matrix-requests-todo/org.matrix.poll.json
@@ -0,0 +1,34 @@
+{
+ "type": "m.room.message",
+ "sender": "@user.id.com",
+ "content": {
+ "body": "[Poll] Is this good?\n0: Yes\n1: No\n2: Probably\n3: I don't know",
+ "label": "Is this good?",
+ "msgtype": "org.matrix.options",
+ "type": "org.matrix.poll",
+ "options": [
+ {
+ "label": "Yes",
+ "value": "0. Yes"
+ },
+ {
+ "label": "No",
+ "value": "1. No"
+ },
+ {
+ "label": "Probably",
+ "value": "2. Probably"
+ },
+ {
+ "label": "I don't know",
+ "value": "3. I don't know"
+ }
+ ]
+ },
+ "origin_server_ts": 1601799929772,
+ "unsigned": {
+ "age": 574231
+ },
+ "event_id": "$Na3jPh4OmJdvnWB0tMCDaS94yoeK61m1Ul1YC5okJKw",
+ "room_id": "!oSXkiqBKooDcZsmiGO:home.server"
+} \ No newline at end of file
diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp
index ca3fc28..fb7c00d 100644
--- a/src/plugins/Matrix.cpp
+++ b/src/plugins/Matrix.cpp
@@ -1033,7 +1033,7 @@ namespace QuickMedia {
return result;
}
- static std::string create_body_for_message_reply(const Message *message, const std::string &body) {
+ static std::string get_reply_message(const Message *message) {
std::string related_to_body;
switch(message->type) {
case MessageType::TEXT: {
@@ -1056,33 +1056,16 @@ namespace QuickMedia {
related_to_body = "sent a file";
break;
}
- return "> <" + message->user->user_id + "> " + block_quote(std::move(related_to_body)) + "\n\n" + body;
+ return related_to_body;
+ }
+
+ static std::string create_body_for_message_reply(const Message *message, const std::string &body) {
+ return "> <" + message->user->user_id + "> " + block_quote(get_reply_message(message)) + "\n\n" + body;
}
static std::string create_formatted_body_for_message_reply(const Message *message, const std::string &body) {
- std::string related_to_body;
- switch(message->type) {
- case MessageType::TEXT: {
- if(!message->replaces_event_id.empty() && strncmp(message->body.c_str(), " * ", 3) == 0)
- related_to_body = remove_reply_formatting(message->body.substr(3));
- else
- related_to_body = remove_reply_formatting(message->body);
- break;
- }
- case MessageType::IMAGE:
- related_to_body = "sent an image";
- break;
- case MessageType::VIDEO:
- related_to_body = "sent a video";
- break;
- case MessageType::AUDIO:
- related_to_body = "sent an audio file";
- break;
- case MessageType::FILE:
- related_to_body = "sent a file";
- break;
- }
std::string formatted_body = body;
+ std::string related_to_body = get_reply_message(message);
html_escape_sequences(formatted_body);
html_escape_sequences(related_to_body);
return "<mx-reply>"
@@ -1093,7 +1076,7 @@ namespace QuickMedia {
"</mx-reply>" + std::move(formatted_body);
}
- // TODO: Add formatted_body just like element does with <mx-reply><blockquote... and also support greentext with that
+ // TODO: Support greentext
PluginResult Matrix::post_reply(const std::string &room_id, const std::string &body, void *relates_to) {
auto room = get_room_by_id(room_id);
if(!room) {