diff options
author | dec05eba <dec05eba@protonmail.com> | 2020-12-04 20:47:15 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-12-04 20:47:15 +0100 |
commit | 3a501ffbe0cd705eed09e697e22023754558aa89 (patch) | |
tree | 139669e1ad59d04790417ddf26d4dd5afbd046a3 | |
parent | df33764eeb6d038419d8a88a2888b5472b86316b (diff) |
Matrix: wait until message is deleted remote before removing locally, to fix removing messages we dont have permission to remove and reset avatar to posters avatar, not the deleters
-rw-r--r-- | TODO | 3 | ||||
-rw-r--r-- | matrix-todo/Formatting.txt | 74 | ||||
-rw-r--r-- | src/QuickMedia.cpp | 9 | ||||
-rw-r--r-- | src/plugins/Matrix.cpp | 2 |
4 files changed, 83 insertions, 5 deletions
@@ -147,4 +147,5 @@ Limit size of Entry and scroll content instead. Have an option to remove membership events from room unread messages, so that only text/media messages update room unread description in the room list. This could be implemented by doing /sync and filtering to only show m.room.message event types or something similar and limiting it to the last message, then comparing that to the read marker. Comparing latest message for unread message should be done by comparing event id ascii-wise instead of checking if the latest message is equal to the read marker event id. This is to fix unread messages in the case of the latest message in a room being deleted. -Support replying to messages with media, by typing /upload in the reply text.
\ No newline at end of file +Support replying to messages with media, by typing /upload in the reply text. +Instead of doing a GET for the first N bytes to check if a video is streamable, start streaming the video and if the first bytes doesn't contain MOOV then wait until the whole video has downloaded before playing it.
\ No newline at end of file diff --git a/matrix-todo/Formatting.txt b/matrix-todo/Formatting.txt new file mode 100644 index 0000000..810ce85 --- /dev/null +++ b/matrix-todo/Formatting.txt @@ -0,0 +1,74 @@ +13.2.2.6.1.1 Fallbacks and event representation +Some clients may not have support for rich replies and therefore need a fallback to use instead. Clients that do not support rich replies should render the event as if rich replies were not special. + +Clients that do support rich replies MUST provide the fallback format on replies, and MUST strip the fallback before rendering the reply. Rich replies MUST have a format of org.matrix.custom.html and therefore a formatted_body alongside the body and appropriate msgtype. The specific fallback text is different for each msgtype, however the general format for the body is: + +> <@alice:example.org> This is the original body + +This is where the reply goes +The formatted_body should use the following template: + +<mx-reply> + <blockquote> + <a href="https://matrix.to/#/!somewhere:example.org/$event:example.org">In reply to</a> + <a href="https://matrix.to/#/@alice:example.org">@alice:example.org</a> + <br /> + <!-- This is where the related event's HTML would be. --> + </blockquote> +</mx-reply> +This is where the reply goes. +If the related event does not have a formatted_body, the event's body should be considered after encoding any HTML special characters. Note that the href in both of the anchors use a matrix.to URI. + + +13.2.2.6.1.1.1 Stripping the fallback +Clients which support rich replies MUST strip the fallback from the event before rendering the event. This is because the text provided in the fallback cannot be trusted to be an accurate representation of the event. After removing the fallback, clients are recommended to represent the event referenced by m.in_reply_to similar to the fallback's representation, although clients do have creative freedom for their user interface. Clients should prefer the formatted_body over the body, just like with other m.room.message events. + +To strip the fallback on the body, the client should iterate over each line of the string, removing any lines that start with the fallback prefix ("> ", including the space, without quotes) and stopping when a line is encountered without the prefix. This prefix is known as the "fallback prefix sequence". + +To strip the fallback on the formatted_body, the client should remove the entirety of the mx-reply tag. + + +13.2.2.6.1.1.2 Fallback for m.text, m.notice, and unrecognised message types +Using the prefix sequence, the first line of the related event's body should be prefixed with the user's ID, followed by each line being prefixed with the fallback prefix sequence. For example: + +> <@alice:example.org> This is the first line +> This is the second line + +This is the reply +The formatted_body uses the template defined earlier in this section. + + +13.2.2.6.1.1.3 Fallback for m.emote +Similar to the fallback for m.text, each line gets prefixed with the fallback prefix sequence. However an asterisk should be inserted before the user's ID, like so: + +> * <@alice:example.org> feels like today is going to be a great day + +This is the reply +The formatted_body has a subtle difference for the template where the asterisk is also inserted ahead of the user's ID: + +<mx-reply> + <blockquote> + <a href="https://matrix.to/#/!somewhere:example.org/$event:example.org">In reply to</a> + * <a href="https://matrix.to/#/@alice:example.org">@alice:example.org</a> + <br /> + <!-- This is where the related event's HTML would be. --> + </blockquote> +</mx-reply> +This is where the reply goes. + +13.2.2.6.1.1.4 Fallback for m.image, m.video, m.audio, and m.file +The related event's body would be a file name, which may not be very descriptive. The related event should additionally not have a format or formatted_body in the content - if the event does have a format and/or formatted_body, those fields should be ignored. Because the filename alone may not be descriptive, the related event's body should be considered to be "sent a file." such that the output looks similar to the following: + +> <@alice:example.org> sent a file. + +This is the reply +<mx-reply> + <blockquote> + <a href="https://matrix.to/#/!somewhere:example.org/$event:example.org">In reply to</a> + <a href="https://matrix.to/#/@alice:example.org">@alice:example.org</a> + <br /> + sent a file. + </blockquote> +</mx-reply> +This is where the reply goes. +For m.image, the text should be "sent an image.". For m.video, the text should be "sent a video.". For m.audio, the text should be "sent an audio file".
\ No newline at end of file diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index 424ccbb..d3a745f 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -3211,8 +3211,11 @@ namespace QuickMedia { message->type = MessageType::REDACTION; //message->related_event_id.clear(); //message->related_event_type = RelatedEventType::NONE; - body_item->thumbnail_url = current_room->get_user_avatar_url(message->user); - body_item->thumbnail_mask_type = ThumbnailMaskType::CIRCLE; + Message *original_message = static_cast<Message*>(body_item->userdata); + if(original_message) { + body_item->thumbnail_url = current_room->get_user_avatar_url(original_message->user); + body_item->thumbnail_mask_type = ThumbnailMaskType::CIRCLE; + } body_item->set_description("Message deleted"); body_item->set_description_color(sf::Color::White); body_item->thumbnail_size = sf::Vector2i(32, 32); @@ -4231,7 +4234,7 @@ namespace QuickMedia { // TODO: Show inline notification show_notification("QuickMedia", "You can't delete a message that hasn't been sent yet"); } else { - set_body_as_deleted(static_cast<Message*>(selected->userdata), selected); + //set_body_as_deleted(static_cast<Message*>(selected->userdata), selected); void *selected_message = selected->userdata; post_task_queue.push([this, ¤t_room, selected_message]() { ProvisionalMessage provisional_message; diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp index 33eb3a4..a7d50d0 100644 --- a/src/plugins/Matrix.cpp +++ b/src/plugins/Matrix.cpp @@ -3141,7 +3141,7 @@ namespace QuickMedia { std::string transaction_id = create_transaction_id(); if(transaction_id.empty()) return PluginResult::ERR; - my_events_transaction_ids.insert(transaction_id); + //my_events_transaction_ids.insert(transaction_id); Message *message_typed = (Message*)message; |