Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return tan to API requests whenever possible #1002

Merged
merged 2 commits into from
Sep 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/api/JsonAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ private slots:
///
/// Handle an incoming JSON message of unknown type
///
void handleNotImplemented();
void handleNotImplemented(const QString &command, int tan);

///
/// Send a standard reply indicating success
Expand Down
18 changes: 10 additions & 8 deletions libsrc/api/JsonAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,23 +97,25 @@ void JsonAPI::handleMessage(const QString &messageString, const QString &httpAut
return;
}

int tan = 0;
if (message.value("tan") != QJsonValue::Undefined)
tan = message["tan"].toInt();

// check basic message
if (!JsonUtils::validate(ident, message, ":schema", _log))
{
sendErrorReply("Errors during message validation, please consult the Hyperion Log.");
sendErrorReply("Errors during message validation, please consult the Hyperion Log.", "" /*command*/, tan);
return;
}

// check specific message
const QString command = message["command"].toString();
if (!JsonUtils::validate(ident, message, QString(":schema-%1").arg(command), _log))
{
sendErrorReply("Errors during specific message validation, please consult the Hyperion Log", command);
sendErrorReply("Errors during specific message validation, please consult the Hyperion Log", command, tan);
return;
}

int tan = message["tan"].toInt();

// client auth before everything else but not for http
if (!_noListener && command == "authorize")
{
Expand Down Expand Up @@ -177,12 +179,12 @@ void JsonAPI::handleMessage(const QString &messageString, const QString &httpAut
else if (command == "clearall")
handleClearallCommand(message, command, tan);
else if (command == "transform" || command == "correction" || command == "temperature")
sendErrorReply("The command " + command + "is deprecated, please use the Hyperion Web Interface to configure");
sendErrorReply("The command " + command + "is deprecated, please use the Hyperion Web Interface to configure", command, tan);
// END

// handle not implemented commands
else
handleNotImplemented();
handleNotImplemented(command, tan);
}

void JsonAPI::handleColorCommand(const QJsonObject &message, const QString &command, int tan)
Expand Down Expand Up @@ -1426,9 +1428,9 @@ void JsonAPI::handleLedDeviceCommand(const QJsonObject &message, const QString &
}
}

void JsonAPI::handleNotImplemented()
void JsonAPI::handleNotImplemented(const QString &command, int tan)
{
sendErrorReply("Command not implemented");
sendErrorReply("Command not implemented", command, tan);
}

void JsonAPI::sendSuccessReply(const QString &command, int tan)
Expand Down