Fix #2243: use server url instead of hard coded string.
authorCamila <hello@camila.codes>
Mon, 3 Aug 2020 17:00:45 +0000 (19:00 +0200)
committerKevin Ottens (Rebase PR Action) <er-vin@users.noreply.github.com>
Tue, 4 Aug 2020 16:28:19 +0000 (16:28 +0000)
Signed-off-by: Camila <hello@camila.codes>
src/gui/tray/UserModel.cpp
src/gui/tray/UserModel.h

index 77c5e399150fd63a218464f1d20ae92094c1d3cd..f7008c42c61991bd8a76a1c0d361f0667194b410 100644 (file)
@@ -486,6 +486,11 @@ bool User::serverHasTalk() const
     return _account->hasTalk();
 }
 
+AccountApp *User::talkApp() const
+{
+    return _account->findApp(QStringLiteral("spreed"));
+}
+
 bool User::hasActivities() const
 {
     return _account->account()->capabilities().hasActivities();
@@ -643,14 +648,15 @@ Q_INVOKABLE void UserModel::openCurrentAccountLocalFolder()
 
 Q_INVOKABLE void UserModel::openCurrentAccountTalk()
 {
-    if (_users.isEmpty())
+    if (!currentUser())
         return;
 
-    QString url = _users[_currentUserId]->server(false) + "/apps/spreed";
-    if (!(url.contains("http://") || url.contains("https://"))) {
-        url = "https://" + _users[_currentUserId]->server(false) + "/apps/spreed";
+    const auto talkApp = currentUser()->talkApp();
+    if (talkApp) {
+        QDesktopServices::openUrl(talkApp->url());
+    } else {
+        qCWarning(lcActivity) << "The Talk app is not enabled on" << currentUser()->server();
     }
-    QDesktopServices::openUrl(QUrl(url));
 }
 
 Q_INVOKABLE void UserModel::openCurrentAccountServer()
index 3a28e65e3257c01f095ee0d0027877df352cce4f..3057f0c28527c8589249b144980cefd605055ff7 100644 (file)
@@ -36,6 +36,7 @@ public:
     QString server(bool shortened = true) const;
     bool hasLocalFolder() const;
     bool serverHasTalk() const;
+    AccountApp *talkApp() const;
     bool hasActivities() const;
     AccountAppList appList() const;
     QImage avatar(bool whiteBg = false) const;