aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/plugins/Matrix.cpp35
1 files changed, 20 insertions, 15 deletions
diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp
index 220a059..e0a9a4b 100644
--- a/src/plugins/Matrix.cpp
+++ b/src/plugins/Matrix.cpp
@@ -1668,21 +1668,6 @@ namespace QuickMedia {
}
}
- static std::string message_content_extract_thumbnail_url(const rapidjson::Value &content_json, const std::string &homeserver) {
- const rapidjson::Value &info_json = GetMember(content_json, "info");
- if(info_json.IsObject()) {
- const rapidjson::Value &thumbnail_url_json = GetMember(info_json, "thumbnail_url");
- if(thumbnail_url_json.IsString()) {
- std::string thumbnail_str = thumbnail_url_json.GetString();
- if(strncmp(thumbnail_str.c_str(), "mxc://", 6) == 0) {
- thumbnail_str.erase(thumbnail_str.begin(), thumbnail_str.begin() + 6);
- return homeserver + "/_matrix/media/r0/download/" + std::move(thumbnail_str);
- }
- }
- }
- return "";
- }
-
static bool message_content_extract_thumbnail_size(const rapidjson::Value &content_json, sf::Vector2i &thumbnail_size) {
const rapidjson::Value &info_json = GetMember(content_json, "info");
if(!info_json.IsObject())
@@ -1711,6 +1696,26 @@ namespace QuickMedia {
return found_resolution;
}
+ static std::string message_content_extract_thumbnail_url(const rapidjson::Value &content_json, const std::string &homeserver) {
+ const rapidjson::Value &info_json = GetMember(content_json, "info");
+ if(info_json.IsObject()) {
+ sf::Vector2i thumbnail_size;
+ if(!message_content_extract_thumbnail_size(content_json, thumbnail_size))
+ return "";
+
+ const rapidjson::Value &thumbnail_url_json = GetMember(info_json, "thumbnail_url");
+ if(thumbnail_url_json.IsString()) {
+ std::string thumbnail_str = thumbnail_url_json.GetString();
+ if(strncmp(thumbnail_str.c_str(), "mxc://", 6) == 0) {
+ thumbnail_str.erase(thumbnail_str.begin(), thumbnail_str.begin() + 6);
+ return homeserver + "/_matrix/media/r0/thumbnail/" + std::move(thumbnail_str) + "?width=" + std::to_string(thumbnail_size.x) + "&height=" + std::to_string(thumbnail_size.y);
+ }
+ }
+ }
+
+ return "";
+ }
+
// TODO: Is this really the proper way to check for username mentions?
static bool is_username_seperating_character(char c) {
switch(c) {