Fix thumbnails for encrypted files and factor upload box out
This commit is contained in:
parent
dbd2bebe6c
commit
a9486ec896
8 changed files with 182 additions and 83 deletions
|
|
@ -139,6 +139,19 @@ struct EventFile
|
|||
}
|
||||
};
|
||||
|
||||
struct EventThumbnailFile
|
||||
{
|
||||
template<class Content>
|
||||
using file_t = decltype(Content::info.thumbnail_file);
|
||||
template<class T>
|
||||
std::optional<mtx::crypto::EncryptedFile> operator()(const mtx::events::Event<T> &e)
|
||||
{
|
||||
if constexpr (is_detected<file_t, T>::value)
|
||||
return e.content.info.thumbnail_file;
|
||||
return std::nullopt;
|
||||
}
|
||||
};
|
||||
|
||||
struct EventUrl
|
||||
{
|
||||
template<class Content>
|
||||
|
|
@ -163,6 +176,8 @@ struct EventThumbnailUrl
|
|||
std::string operator()(const mtx::events::Event<T> &e)
|
||||
{
|
||||
if constexpr (is_detected<thumbnail_url_t, T>::value) {
|
||||
if (auto file = EventThumbnailFile{}(e))
|
||||
return file->url;
|
||||
return e.content.info.thumbnail_url;
|
||||
}
|
||||
return "";
|
||||
|
|
@ -424,6 +439,12 @@ mtx::accessors::file(const mtx::events::collections::TimelineEvents &event)
|
|||
return std::visit(EventFile{}, event);
|
||||
}
|
||||
|
||||
std::optional<mtx::crypto::EncryptedFile>
|
||||
mtx::accessors::thumbnail_file(const mtx::events::collections::TimelineEvents &event)
|
||||
{
|
||||
return std::visit(EventThumbnailFile{}, event);
|
||||
}
|
||||
|
||||
std::string
|
||||
mtx::accessors::url(const mtx::events::collections::TimelineEvents &event)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue