diff --git a/services/tunnelbroker/src/libcpp/src/Database/DatabaseManager.cpp b/services/tunnelbroker/src/libcpp/src/Database/DatabaseManager.cpp --- a/services/tunnelbroker/src/libcpp/src/Database/DatabaseManager.cpp +++ b/services/tunnelbroker/src/libcpp/src/Database/DatabaseManager.cpp @@ -40,7 +40,8 @@ Aws::DynamoDB::Model::AttributeValue(item.getNotifyToken())); request.AddItem( DeviceSessionItem::FIELD_DEVICE_TYPE, - Aws::DynamoDB::Model::AttributeValue(item.getDeviceType())); + Aws::DynamoDB::Model::AttributeValue( + std::to_string(item.getDeviceType()))); request.AddItem( DeviceSessionItem::FIELD_APP_VERSION, Aws::DynamoDB::Model::AttributeValue(item.getAppVersion())); diff --git a/services/tunnelbroker/src/libcpp/src/Database/DeviceSessionItem.h b/services/tunnelbroker/src/libcpp/src/Database/DeviceSessionItem.h --- a/services/tunnelbroker/src/libcpp/src/Database/DeviceSessionItem.h +++ b/services/tunnelbroker/src/libcpp/src/Database/DeviceSessionItem.h @@ -13,7 +13,7 @@ std::string deviceID; std::string pubKey; std::string notifyToken; - std::string deviceType; + size_t deviceType; std::string appVersion; std::string deviceOs; int64_t checkpointTime = 0; @@ -40,7 +40,7 @@ std::string getDeviceID() const; std::string getPubKey() const; std::string getNotifyToken() const; - std::string getDeviceType() const; + size_t getDeviceType() const; std::string getAppVersion() const; std::string getDeviceOs() const; int64_t getCheckpointTime() const; @@ -53,7 +53,7 @@ const std::string deviceID, const std::string pubKey, const std::string notifyToken, - const std::string deviceType, + size_t deviceType, const std::string appVersion, const std::string deviceOs); DeviceSessionItem(const AttributeValues &itemFromDB); diff --git a/services/tunnelbroker/src/libcpp/src/Database/DeviceSessionItem.cpp b/services/tunnelbroker/src/libcpp/src/Database/DeviceSessionItem.cpp --- a/services/tunnelbroker/src/libcpp/src/Database/DeviceSessionItem.cpp +++ b/services/tunnelbroker/src/libcpp/src/Database/DeviceSessionItem.cpp @@ -24,7 +24,7 @@ const std::string deviceID, const std::string pubKey, const std::string notifyToken, - const std::string deviceType, + const size_t deviceType, const std::string appVersion, const std::string deviceOs) : sessionID(sessionID), @@ -49,7 +49,6 @@ throw std::runtime_error("Error: DeviceID format is wrong."); } tools::checkIfNotEmpty("pubKey", this->pubKey); - tools::checkIfNotEmpty("deviceType", this->deviceType); tools::checkIfNotEmpty("appVersion", this->appVersion); tools::checkIfNotEmpty("deviceOs", this->deviceOs); } @@ -62,8 +61,9 @@ this->pubKey = itemFromDB.at(DeviceSessionItem::FIELD_PUBKEY).GetS(); this->notifyToken = itemFromDB.at(DeviceSessionItem::FIELD_NOTIFY_TOKEN).GetS(); - this->deviceType = - itemFromDB.at(DeviceSessionItem::FIELD_DEVICE_TYPE).GetS(); + this->deviceType = std::stoll( + std::string(itemFromDB.at(DeviceSessionItem::FIELD_DEVICE_TYPE).GetN()) + .c_str()); this->appVersion = itemFromDB.at(DeviceSessionItem::FIELD_APP_VERSION).GetS(); this->deviceOs = itemFromDB.at(DeviceSessionItem::FIELD_DEVICE_OS).GetS(); @@ -109,7 +109,7 @@ return this->notifyToken; } -std::string DeviceSessionItem::getDeviceType() const { +size_t DeviceSessionItem::getDeviceType() const { return this->deviceType; }