make compatible with Talk 12 (NC 22) #31

Merged
blizzz merged 1 commits from enh/noid/conv-v4 into master 6 months ago
  1. 2
      src/roomservice.cpp
  2. 21
      src/services/capabilities.cpp
  3. 2
      src/services/capabilities.h
  4. 2
      src/services/participants.cpp

2
src/roomservice.cpp

@ -148,7 +148,7 @@ void RoomService::loadRooms() {
connect(&m_nam, &QNetworkAccessManager::finished, account->capabilities(), &Capabilities::checkTalkCapHash);
QUrl endpoint = QUrl(account->host());
QString apiV = account->capabilities()->hasConversationV2() ? "v2" : "v1";
QString apiV = "v" + QString::number(account->capabilities()->getConversationApiLevel());
endpoint.setPath(endpoint.path() + "/ocs/v2.php/apps/spreed/api/" + apiV + "/room");
endpoint.setQuery("format=json");
QNetworkRequest request = RequestFactory::getRequest(endpoint, account);

21
src/services/capabilities.cpp

@ -14,16 +14,25 @@ bool Capabilities::areAvailable() const {
return m_available;
}
bool Capabilities::hasConversationV2() const {
if(!m_available) {
qDebug() << "capabilities have not been requested yet!";
return false;
int Capabilities::getConversationApiLevel() const
{
if (m_capabilities
.find("spreed").value().toObject()
.find("features").value().toArray()
.toVariantList().contains("conversation-v4"))
{
return 4;
}
return m_capabilities
if (m_capabilities
.find("spreed").value().toObject()
.find("features").value().toArray()
.toVariantList().contains("conversation-v2");
.toVariantList().contains("conversation-v2"))
{
return 2;
}
return 1;
}
QColor Capabilities::primaryColor() const {

2
src/services/capabilities.h

@ -16,7 +16,7 @@ public:
bool areAvailable() const;
void request();
NextcloudAccount *m_account;
bool hasConversationV2() const;
int getConversationApiLevel() const;
QColor primaryColor() const;
QUrl logoUrl() const;
QString name() const;

2
src/services/participants.cpp

@ -83,7 +83,7 @@ void Participants::pullParticipants(QString token, int accountId)
m_reply->abort();
}
QUrl endpoint = QUrl(m_activeAccount->host());
QString apiV = m_activeAccount->capabilities()->hasConversationV2() ? "v2" : "v1";
QString apiV = "v" + QString::number(m_activeAccount->capabilities()->getConversationApiLevel());
endpoint.setPath(endpoint.path() + "/ocs/v2.php/apps/spreed/api/" + apiV+ "/room/" + token + "/participants");
QUrlQuery q(endpoint);
q.addQueryItem("format", "json");

Loading…
Cancel
Save