@@ -312,8 +312,12 @@ void PushRuleModel::addKeyword(const QString &keyword, const QString &roomId)
|
|||||||
pushConditions.append(keywordCondition);
|
pushConditions.append(keywordCondition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if Quotient_VERSION_MINOR > 8
|
||||||
|
auto job = m_connection->callApi<Quotient::SetPushRuleJob>(PushRuleKind::kindString(kind),
|
||||||
|
#else
|
||||||
auto job = m_connection->callApi<Quotient::SetPushRuleJob>(QLatin1String("global"),
|
auto job = m_connection->callApi<Quotient::SetPushRuleJob>(QLatin1String("global"),
|
||||||
PushRuleKind::kindString(kind),
|
PushRuleKind::kindString(kind),
|
||||||
|
#endif
|
||||||
keyword,
|
keyword,
|
||||||
actions,
|
actions,
|
||||||
QString(),
|
QString(),
|
||||||
@@ -338,7 +342,11 @@ void PushRuleModel::removeKeyword(const QString &keyword)
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto kind = PushRuleKind::kindString(m_rules[index].kind);
|
auto kind = PushRuleKind::kindString(m_rules[index].kind);
|
||||||
|
#if Quotient_VERSION_MINOR > 8
|
||||||
|
auto job = m_connection->callApi<Quotient::DeletePushRuleJob>(kind, m_rules[index].id);
|
||||||
|
#else
|
||||||
auto job = m_connection->callApi<Quotient::DeletePushRuleJob>(QStringLiteral("global"), kind, m_rules[index].id);
|
auto job = m_connection->callApi<Quotient::DeletePushRuleJob>(QStringLiteral("global"), kind, m_rules[index].id);
|
||||||
|
#endif
|
||||||
connect(job, &Quotient::BaseJob::failure, this, [this, job, index]() {
|
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();
|
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)
|
void PushRuleModel::setNotificationRuleEnabled(const QString &kind, const QString &ruleId, bool enabled)
|
||||||
{
|
{
|
||||||
|
#if Quotient_VERSION_MINOR > 8
|
||||||
|
auto job = m_connection->callApi<Quotient::IsPushRuleEnabledJob>(kind, ruleId);
|
||||||
|
#else
|
||||||
auto job = m_connection->callApi<Quotient::IsPushRuleEnabledJob>(QStringLiteral("global"), kind, ruleId);
|
auto job = m_connection->callApi<Quotient::IsPushRuleEnabledJob>(QStringLiteral("global"), kind, ruleId);
|
||||||
|
#endif
|
||||||
connect(job, &Quotient::BaseJob::success, this, [job, kind, ruleId, enabled, this]() {
|
connect(job, &Quotient::BaseJob::success, this, [job, kind, ruleId, enabled, this]() {
|
||||||
if (job->enabled() != enabled) {
|
if (job->enabled() != enabled) {
|
||||||
|
#if Quotient_VERSION_MINOR > 8
|
||||||
|
m_connection->callApi<Quotient::SetPushRuleEnabledJob>(kind, ruleId, enabled);
|
||||||
|
#else
|
||||||
m_connection->callApi<Quotient::SetPushRuleEnabledJob>(QStringLiteral("global"), kind, ruleId, enabled);
|
m_connection->callApi<Quotient::SetPushRuleEnabledJob>(QStringLiteral("global"), kind, ruleId, enabled);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -363,7 +379,11 @@ void PushRuleModel::setNotificationRuleActions(const QString &kind, const QStrin
|
|||||||
actions = actionToVariant(action);
|
actions = actionToVariant(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if Quotient_VERSION_MINOR > 8
|
||||||
|
m_connection->callApi<Quotient::SetPushRuleActionsJob>(kind, ruleId, actions);
|
||||||
|
#else
|
||||||
m_connection->callApi<Quotient::SetPushRuleActionsJob>(QStringLiteral("global"), kind, ruleId, actions);
|
m_connection->callApi<Quotient::SetPushRuleActionsJob>(QStringLiteral("global"), kind, ruleId, actions);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
PushRuleAction::Action PushRuleModel::variantToAction(const QList<QVariant> &actions, bool enabled)
|
PushRuleAction::Action PushRuleModel::variantToAction(const QList<QVariant> &actions, bool enabled)
|
||||||
|
|||||||
@@ -1223,7 +1223,11 @@ void NeoChatRoom::setPushNotificationState(PushNotificationState::State state)
|
|||||||
for (const auto &i : roomRuleArray) {
|
for (const auto &i : roomRuleArray) {
|
||||||
QJsonObject roomRule = i.toObject();
|
QJsonObject roomRule = i.toObject();
|
||||||
if (roomRule["rule_id"_ls] == id()) {
|
if (roomRule["rule_id"_ls] == id()) {
|
||||||
connection()->callApi<DeletePushRuleJob>("global"_ls, "room"_ls, id());
|
#if Quotient_VERSION_MINOR > 8
|
||||||
|
connection()->callApi<DeletePushRuleJob>("room"_ls, id());
|
||||||
|
#else
|
||||||
|
connection()->callApi<DeletePushRuleJob>(QLatin1String("global"), "room"_ls, id());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1234,7 +1238,11 @@ void NeoChatRoom::setPushNotificationState(PushNotificationState::State state)
|
|||||||
for (const auto &i : overrideRuleArray) {
|
for (const auto &i : overrideRuleArray) {
|
||||||
QJsonObject overrideRule = i.toObject();
|
QJsonObject overrideRule = i.toObject();
|
||||||
if (overrideRule["rule_id"_ls] == id()) {
|
if (overrideRule["rule_id"_ls] == id()) {
|
||||||
|
#if Quotient_VERSION_MINOR > 8
|
||||||
|
connection()->callApi<DeletePushRuleJob>("override"_ls, id());
|
||||||
|
#else
|
||||||
connection()->callApi<DeletePushRuleJob>("global"_ls, "override"_ls, id());
|
connection()->callApi<DeletePushRuleJob>("global"_ls, "override"_ls, id());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1270,9 +1278,17 @@ void NeoChatRoom::setPushNotificationState(PushNotificationState::State state)
|
|||||||
const QList<PushCondition> conditions = {pushCondition};
|
const QList<PushCondition> conditions = {pushCondition};
|
||||||
|
|
||||||
// Add new override rule and make sure it's enabled
|
// Add new override rule and make sure it's enabled
|
||||||
|
#if Quotient_VERSION_MINOR > 8
|
||||||
|
auto job = connection()->callApi<SetPushRuleJob>("override"_ls, id(), actions, QString(), QString(), conditions, QString());
|
||||||
|
#else
|
||||||
auto job = connection()->callApi<SetPushRuleJob>("global"_ls, "override"_ls, id(), actions, QString(), QString(), conditions, QString());
|
auto job = connection()->callApi<SetPushRuleJob>("global"_ls, "override"_ls, id(), actions, QString(), QString(), conditions, QString());
|
||||||
|
#endif
|
||||||
connect(job, &BaseJob::success, this, [this]() {
|
connect(job, &BaseJob::success, this, [this]() {
|
||||||
|
#if Quotient_VERSION_MINOR > 8
|
||||||
|
auto enableJob = connection()->callApi<SetPushRuleEnabledJob>("override"_ls, id(), true);
|
||||||
|
#else
|
||||||
auto enableJob = connection()->callApi<SetPushRuleEnabledJob>("global"_ls, "override"_ls, id(), true);
|
auto enableJob = connection()->callApi<SetPushRuleEnabledJob>("global"_ls, "override"_ls, id(), true);
|
||||||
|
#endif
|
||||||
connect(enableJob, &BaseJob::success, this, [this]() {
|
connect(enableJob, &BaseJob::success, this, [this]() {
|
||||||
m_pushNotificationStateUpdating = false;
|
m_pushNotificationStateUpdating = false;
|
||||||
});
|
});
|
||||||
@@ -1296,9 +1312,17 @@ void NeoChatRoom::setPushNotificationState(PushNotificationState::State state)
|
|||||||
// No conditions for a room rule
|
// No conditions for a room rule
|
||||||
const QList<PushCondition> conditions;
|
const QList<PushCondition> conditions;
|
||||||
|
|
||||||
|
#if Quotient_VERSION_MINOR > 8
|
||||||
|
auto setJob = connection()->callApi<SetPushRuleJob>("room"_ls, id(), actions, QString(), QString(), conditions, QString());
|
||||||
|
#else
|
||||||
auto setJob = connection()->callApi<SetPushRuleJob>("global"_ls, "room"_ls, id(), actions, QString(), QString(), conditions, QString());
|
auto setJob = connection()->callApi<SetPushRuleJob>("global"_ls, "room"_ls, id(), actions, QString(), QString(), conditions, QString());
|
||||||
|
#endif
|
||||||
connect(setJob, &BaseJob::success, this, [this]() {
|
connect(setJob, &BaseJob::success, this, [this]() {
|
||||||
|
#if Quotient_VERSION_MINOR > 8
|
||||||
|
auto enableJob = connection()->callApi<SetPushRuleEnabledJob>("room"_ls, id(), true);
|
||||||
|
#else
|
||||||
auto enableJob = connection()->callApi<SetPushRuleEnabledJob>("global"_ls, "room"_ls, id(), true);
|
auto enableJob = connection()->callApi<SetPushRuleEnabledJob>("global"_ls, "room"_ls, id(), true);
|
||||||
|
#endif
|
||||||
connect(enableJob, &BaseJob::success, this, [this]() {
|
connect(enableJob, &BaseJob::success, this, [this]() {
|
||||||
m_pushNotificationStateUpdating = false;
|
m_pushNotificationStateUpdating = false;
|
||||||
});
|
});
|
||||||
@@ -1327,9 +1351,17 @@ void NeoChatRoom::setPushNotificationState(PushNotificationState::State state)
|
|||||||
const QList<PushCondition> conditions;
|
const QList<PushCondition> conditions;
|
||||||
|
|
||||||
// Add new room rule and make sure enabled
|
// Add new room rule and make sure enabled
|
||||||
|
#if Quotient_VERSION_MINOR > 8
|
||||||
|
auto setJob = connection()->callApi<SetPushRuleJob>("room"_ls, id(), actions, QString(), QString(), conditions, QString());
|
||||||
|
#else
|
||||||
auto setJob = connection()->callApi<SetPushRuleJob>("global"_ls, "room"_ls, id(), actions, QString(), QString(), conditions, QString());
|
auto setJob = connection()->callApi<SetPushRuleJob>("global"_ls, "room"_ls, id(), actions, QString(), QString(), conditions, QString());
|
||||||
|
#endif
|
||||||
connect(setJob, &BaseJob::success, this, [this]() {
|
connect(setJob, &BaseJob::success, this, [this]() {
|
||||||
|
#if Quotient_VERSION_MINOR > 8
|
||||||
|
auto enableJob = connection()->callApi<SetPushRuleEnabledJob>("room"_ls, id(), true);
|
||||||
|
#else
|
||||||
auto enableJob = connection()->callApi<SetPushRuleEnabledJob>("global"_ls, "room"_ls, id(), true);
|
auto enableJob = connection()->callApi<SetPushRuleEnabledJob>("global"_ls, "room"_ls, id(), true);
|
||||||
|
#endif
|
||||||
connect(enableJob, &BaseJob::success, this, [this]() {
|
connect(enableJob, &BaseJob::success, this, [this]() {
|
||||||
m_pushNotificationStateUpdating = false;
|
m_pushNotificationStateUpdating = false;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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)
|
void RoomManager::knockRoom(NeoChatConnection *account, const QString &roomAliasOrId, const QString &reason, const QStringList &viaServers)
|
||||||
{
|
{
|
||||||
|
#if Quotient_VERSION_MINOR > 8
|
||||||
|
auto job = account->callApi<KnockRoomJob>(roomAliasOrId, viaServers, viaServers, reason);
|
||||||
|
#else
|
||||||
auto job = account->callApi<KnockRoomJob>(roomAliasOrId, viaServers, reason);
|
auto job = account->callApi<KnockRoomJob>(roomAliasOrId, viaServers, reason);
|
||||||
|
#endif
|
||||||
// Upon completion, ensure a room object is created in case it hasn't come
|
// 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
|
// 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()
|
// create it in Join state. finished() is used here instead of success()
|
||||||
|
|||||||
Reference in New Issue
Block a user