diff --git a/src/models/pushrulemodel.cpp b/src/models/pushrulemodel.cpp index 36c72ad17..5cd22321e 100644 --- a/src/models/pushrulemodel.cpp +++ b/src/models/pushrulemodel.cpp @@ -312,8 +312,12 @@ void PushRuleModel::addKeyword(const QString &keyword, const QString &roomId) pushConditions.append(keywordCondition); } +#if Quotient_VERSION_MINOR > 8 + auto job = m_connection->callApi(PushRuleKind::kindString(kind), +#else auto job = m_connection->callApi(QLatin1String("global"), PushRuleKind::kindString(kind), +#endif keyword, actions, QString(), @@ -338,7 +342,11 @@ void PushRuleModel::removeKeyword(const QString &keyword) } auto kind = PushRuleKind::kindString(m_rules[index].kind); +#if Quotient_VERSION_MINOR > 8 + auto job = m_connection->callApi(kind, m_rules[index].id); +#else auto job = m_connection->callApi(QStringLiteral("global"), kind, m_rules[index].id); +#endif connect(job, &Quotient::BaseJob::failure, this, [this, job, index]() { qWarning() << QLatin1String("Unable to remove push rule for keyword %1: ").arg(m_rules[index].id) << job->errorString(); }); @@ -346,10 +354,18 @@ void PushRuleModel::removeKeyword(const QString &keyword) void PushRuleModel::setNotificationRuleEnabled(const QString &kind, const QString &ruleId, bool enabled) { +#if Quotient_VERSION_MINOR > 8 + auto job = m_connection->callApi(kind, ruleId); +#else auto job = m_connection->callApi(QStringLiteral("global"), kind, ruleId); +#endif connect(job, &Quotient::BaseJob::success, this, [job, kind, ruleId, enabled, this]() { if (job->enabled() != enabled) { +#if Quotient_VERSION_MINOR > 8 + m_connection->callApi(kind, ruleId, enabled); +#else m_connection->callApi(QStringLiteral("global"), kind, ruleId, enabled); +#endif } }); } @@ -363,7 +379,11 @@ void PushRuleModel::setNotificationRuleActions(const QString &kind, const QStrin actions = actionToVariant(action); } +#if Quotient_VERSION_MINOR > 8 + m_connection->callApi(kind, ruleId, actions); +#else m_connection->callApi(QStringLiteral("global"), kind, ruleId, actions); +#endif } PushRuleAction::Action PushRuleModel::variantToAction(const QList &actions, bool enabled) diff --git a/src/neochatroom.cpp b/src/neochatroom.cpp index 3c45bac58..cc8018bb1 100644 --- a/src/neochatroom.cpp +++ b/src/neochatroom.cpp @@ -1223,7 +1223,11 @@ void NeoChatRoom::setPushNotificationState(PushNotificationState::State state) for (const auto &i : roomRuleArray) { QJsonObject roomRule = i.toObject(); if (roomRule["rule_id"_ls] == id()) { - connection()->callApi("global"_ls, "room"_ls, id()); +#if Quotient_VERSION_MINOR > 8 + connection()->callApi("room"_ls, id()); +#else + connection()->callApi(QLatin1String("global"), "room"_ls, id()); +#endif } } } @@ -1234,7 +1238,11 @@ void NeoChatRoom::setPushNotificationState(PushNotificationState::State state) for (const auto &i : overrideRuleArray) { QJsonObject overrideRule = i.toObject(); if (overrideRule["rule_id"_ls] == id()) { +#if Quotient_VERSION_MINOR > 8 + connection()->callApi("override"_ls, id()); +#else connection()->callApi("global"_ls, "override"_ls, id()); +#endif } } } @@ -1270,9 +1278,17 @@ void NeoChatRoom::setPushNotificationState(PushNotificationState::State state) const QList conditions = {pushCondition}; // Add new override rule and make sure it's enabled +#if Quotient_VERSION_MINOR > 8 + auto job = connection()->callApi("override"_ls, id(), actions, QString(), QString(), conditions, QString()); +#else auto job = connection()->callApi("global"_ls, "override"_ls, id(), actions, QString(), QString(), conditions, QString()); +#endif connect(job, &BaseJob::success, this, [this]() { +#if Quotient_VERSION_MINOR > 8 + auto enableJob = connection()->callApi("override"_ls, id(), true); +#else auto enableJob = connection()->callApi("global"_ls, "override"_ls, id(), true); +#endif connect(enableJob, &BaseJob::success, this, [this]() { m_pushNotificationStateUpdating = false; }); @@ -1296,9 +1312,17 @@ void NeoChatRoom::setPushNotificationState(PushNotificationState::State state) // No conditions for a room rule const QList conditions; +#if Quotient_VERSION_MINOR > 8 + auto setJob = connection()->callApi("room"_ls, id(), actions, QString(), QString(), conditions, QString()); +#else auto setJob = connection()->callApi("global"_ls, "room"_ls, id(), actions, QString(), QString(), conditions, QString()); +#endif connect(setJob, &BaseJob::success, this, [this]() { +#if Quotient_VERSION_MINOR > 8 + auto enableJob = connection()->callApi("room"_ls, id(), true); +#else auto enableJob = connection()->callApi("global"_ls, "room"_ls, id(), true); +#endif connect(enableJob, &BaseJob::success, this, [this]() { m_pushNotificationStateUpdating = false; }); @@ -1327,9 +1351,17 @@ void NeoChatRoom::setPushNotificationState(PushNotificationState::State state) const QList conditions; // Add new room rule and make sure enabled +#if Quotient_VERSION_MINOR > 8 + auto setJob = connection()->callApi("room"_ls, id(), actions, QString(), QString(), conditions, QString()); +#else auto setJob = connection()->callApi("global"_ls, "room"_ls, id(), actions, QString(), QString(), conditions, QString()); +#endif connect(setJob, &BaseJob::success, this, [this]() { +#if Quotient_VERSION_MINOR > 8 + auto enableJob = connection()->callApi("room"_ls, id(), true); +#else auto enableJob = connection()->callApi("global"_ls, "room"_ls, id(), true); +#endif connect(enableJob, &BaseJob::success, this, [this]() { m_pushNotificationStateUpdating = false; }); diff --git a/src/roommanager.cpp b/src/roommanager.cpp index 9471a6a27..d9ab082de 100644 --- a/src/roommanager.cpp +++ b/src/roommanager.cpp @@ -357,7 +357,11 @@ void RoomManager::joinRoom(Quotient::Connection *account, const QString &roomAli void RoomManager::knockRoom(NeoChatConnection *account, const QString &roomAliasOrId, const QString &reason, const QStringList &viaServers) { +#if Quotient_VERSION_MINOR > 8 + auto job = account->callApi(roomAliasOrId, viaServers, viaServers, reason); +#else auto job = account->callApi(roomAliasOrId, viaServers, reason); +#endif // Upon completion, ensure a room object is created in case it hasn't come // with a sync yet. If the room object is not there, provideRoom() will // create it in Join state. finished() is used here instead of success()