Fix deprecation warning for notifications

pull/275/head
Michael Zanetti 2020-03-24 15:22:24 +01:00
parent 8f846434b9
commit b01e8c8ee4
1 changed files with 8 additions and 8 deletions

View File

@ -744,14 +744,6 @@ void JsonRPCServerImplementation::sendNotification(const QVariantMap &params)
notification.insert("id", m_notificationId++);
notification.insert("notification", handler->name() + "." + method.name());
// Add deprecation warning if necessary
if (m_api.value("notifications").toMap().value(handler->name() + '.' + method.name()).toMap().contains("deprecated")) {
QString deprecationMessage = m_api.value("notifications").toMap().value(handler->name() + '.' + method.name()).toMap().value("deprecated").toString();
qCWarning(dcJsonRpc()) << "Client uses deprecated API. Please update client implementation!";
qCWarning(dcJsonRpc()) << handler->name() + '.' + method.name() + ':' << deprecationMessage;
notification.insert("deprecationWarning", deprecationMessage);
}
foreach (const QUuid &clientId, m_clientNotifications.keys()) {
// Check if this client wants to be notified
@ -759,6 +751,14 @@ void JsonRPCServerImplementation::sendNotification(const QVariantMap &params)
continue;
}
// Add deprecation warning if necessary
if (m_api.value("notifications").toMap().value(handler->name() + '.' + method.name()).toMap().contains("deprecated")) {
QString deprecationMessage = m_api.value("notifications").toMap().value(handler->name() + '.' + method.name()).toMap().value("deprecated").toString();
qCWarning(dcJsonRpc()) << "Client" << clientId << "uses deprecated API. Please update client implementation!";
qCWarning(dcJsonRpc()) << handler->name() + '.' + method.name() + ':' << deprecationMessage;
notification.insert("deprecationWarning", deprecationMessage);
}
QLocale locale = m_clientLocales.value(clientId);
QVariantMap translatedParams = handler->translateNotification(method.name(), params, locale);