* @brief Delete a stored session by id. */
| 430 | * @brief Delete a stored session by id. |
| 431 | */ |
| 432 | API::CommandResponse API::Handlers::SessionsHandler::deleteSession(const QString& id, |
| 433 | const QJsonObject& params) |
| 434 | { |
| 435 | if (!params.contains(QStringLiteral("sessionId"))) |
| 436 | return CommandResponse::makeError( |
| 437 | id, ErrorCode::MissingParam, QStringLiteral("Missing required parameter: sessionId")); |
| 438 | |
| 439 | const int sessionId = params.value(QStringLiteral("sessionId")).toInt(); |
| 440 | auto& db = Sessions::DatabaseManager::instance(); |
| 441 | if (!db.isOpen()) |
| 442 | return CommandResponse::makeError( |
| 443 | id, |
| 444 | ErrorCode::ExecutionError, |
| 445 | QStringLiteral("No database open. Call sessions.openDatabase first.")); |
| 446 | |
| 447 | db.confirmDeleteSession(sessionId); |
| 448 | |
| 449 | QJsonObject result; |
| 450 | result[QStringLiteral("sessionId")] = sessionId; |
| 451 | result[QStringLiteral("deleting")] = true; |
| 452 | return CommandResponse::makeSuccess(id, result); |
| 453 | } |
| 454 | |
| 455 | /** |
| 456 | * @brief Set the free-form notes on a stored session. |
nothing calls this directly
no test coverage detected