aboutsummaryrefslogtreecommitdiff
path: root/avatar.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'avatar.cpp')
-rw-r--r--avatar.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/avatar.cpp b/avatar.cpp
index a13507fb..040bf9bb 100644
--- a/avatar.cpp
+++ b/avatar.cpp
@@ -62,6 +62,11 @@ QImage Avatar::get(int width, int height, notifier_t notifier) const
return d->get({width, height}, notifier);
}
+QString Avatar::mediaId() const
+{
+ return d->_url.authority() + d->_url.path();
+}
+
QImage Avatar::Private::get(QSize size, Avatar::notifier_t notifier) const
{
// FIXME: Alternating between longer-width and longer-height requests
@@ -113,6 +118,13 @@ bool Avatar::updateUrl(const QUrl& newUrl)
if (newUrl == d->_url)
return false;
+ // FIXME: Make it a library-wide constant and maybe even make the URL checker
+ // a Connection(?) method.
+ if (newUrl.scheme() != "mxc" || newUrl.path().count('/') != 1)
+ {
+ qCWarning(MAIN) << "Malformed avatar URL:" << newUrl.toDisplayString();
+ return false;
+ }
d->_url = newUrl;
d->_valid = false;
return true;