From 5f877b59b6ad9d319d6471bbb46ff890874e4a00 Mon Sep 17 00:00:00 2001
From: Dennis Beier <nanovim@gmail.com>
Date: Thu, 20 Sep 2018 17:32:35 +0200
Subject: [PATCH] covered insecure connections with reply urls

---
 api/meteorddp.cpp    | 7 ++++++-
 api/meteorddp.h      | 6 +++++-
 rocketchatserver.cpp | 6 +++++-
 3 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/api/meteorddp.cpp b/api/meteorddp.cpp
index ced3ea0..35f0ff5 100755
--- a/api/meteorddp.cpp
+++ b/api/meteorddp.cpp
@@ -41,7 +41,7 @@ void MeteorDDP::init( const QString &pUri, bool pUnsecure )
     mWsClient = new Websocket( this );
 
     QString protocol = QStringLiteral( "wss://" );
-
+    unsecure = pUnsecure;
     if ( pUnsecure ) {
         protocol = QStringLiteral( "ws://" );
     }
@@ -193,6 +193,11 @@ void MeteorDDP::sendJson( const QJsonObject &pMsgObj )
     mWsClient->sendTextMessage( msgString );
 }
 
+bool MeteorDDP::getUnsecure() const
+{
+    return unsecure;
+}
+
 void MeteorDDP::onConnected()
 {
     qDebug() << "connected websocket";
diff --git a/api/meteorddp.h b/api/meteorddp.h
index a5f10fe..60418de 100755
--- a/api/meteorddp.h
+++ b/api/meteorddp.h
@@ -60,10 +60,13 @@ class MeteorDDP : public QObject
         void setUserId( const QString &pUserId );
 
         void registerMessageHandler(MessageListener *);
+        void registerMessageHandler(MessageListener &);
         void init( const QString &pServer, bool pUnsecure = false );
 
 
-    private:
+        bool getUnsecure() const;
+
+private:
         QJsonParseError *mError;
 
         void pong();
@@ -71,6 +74,7 @@ class MeteorDDP : public QObject
         void loadLocale();
         void userPresenceOnline();
         void sendJson( const QJsonObject & );
+        bool unsecure;
 
         int frameCount = 0;
         Websocket *mWsClient = nullptr;
diff --git a/rocketchatserver.cpp b/rocketchatserver.cpp
index cb9b885..e02cace 100755
--- a/rocketchatserver.cpp
+++ b/rocketchatserver.cpp
@@ -559,7 +559,11 @@ void RocketChatServerData::offlineLogin()
 
 QString RocketChatServerData::getBaseUrl() const
 {
-    return "https://"+mBaseUrl;
+    QString protocol ="https://";
+    if(mDdpApi->getUnsecure()){
+        protocol ="http://";
+    }
+    return protocol+mBaseUrl;
 }
 
 QVariantList RocketChatServerData::getEmojisByCategory() const
-- 
GitLab