///////////////////////////////////////////////////////////////////////////
| 405 | |
| 406 | //////////////////////////////////////////////////////////////////////////////// |
| 407 | void Hooks::assertSameTask(const std::vector<std::string>& input, const Task& task, |
| 408 | const std::string& script) const { |
| 409 | std::string uuid = task.get("uuid"); |
| 410 | |
| 411 | for (auto& i : input) { |
| 412 | auto root_obj = (json::object*)json::parse(i); |
| 413 | |
| 414 | // If there is no UUID at all. |
| 415 | auto u = root_obj->_data.find("uuid"); |
| 416 | if (u == root_obj->_data.end() || u->second->type() != json::j_string) { |
| 417 | Context::getContext().error(format(STRING_HOOK_ERROR_SAME1, uuid, Path(script).name())); |
| 418 | throw 0; |
| 419 | } |
| 420 | |
| 421 | auto up = (json::string*)u->second; |
| 422 | auto text = up->dump(); |
| 423 | Lexer::dequote(text); |
| 424 | std::string json_uuid = json::decode(text); |
| 425 | if (json_uuid != uuid) { |
| 426 | Context::getContext().error( |
| 427 | format(STRING_HOOK_ERROR_SAME2, uuid, json_uuid, Path(script).name())); |
| 428 | throw 0; |
| 429 | } |
| 430 | |
| 431 | delete root_obj; |
| 432 | } |
| 433 | } |
| 434 | |
| 435 | //////////////////////////////////////////////////////////////////////////////// |
| 436 | void Hooks::assertFeedback(const std::vector<std::string>& input, const std::string& script) const { |