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; } diff --git a/services/tunnelbroker/src/libcpp/test/DatabaseManagerTest.cpp b/services/tunnelbroker/src/libcpp/test/DatabaseManagerTest.cpp --- a/services/tunnelbroker/src/libcpp/test/DatabaseManagerTest.cpp +++ b/services/tunnelbroker/src/libcpp/test/DatabaseManagerTest.cpp @@ -141,7 +141,7 @@ "ECqgx4zqajPTzVt7EAOGaIh/dPyQ6x2Ul1GlkkSYXUhhixEzExGp9g84eCyVkbCB" "U3SK6SNKyR7anAXDVQIDAQAB", "hbI93aGAwPF9au0eYsawRz0jtYi4lSFXC9KleyQDg+6J+UW1kiWvE3", - "phone", + 3, "ios:1.1.1", "iOS 99.99.99"); EXPECT_EQ( @@ -169,7 +169,7 @@ "mobile:" + tools::generateRandomString(DEVICEID_CHAR_LENGTH), tools::generateRandomString(451), tools::generateRandomString(64), - tools::generateRandomString(12), + 3, tools::generateRandomString(12), tools::generateRandomString(12)); EXPECT_EQ( @@ -219,7 +219,7 @@ "ECqgx4zqajPTzVt7EAOGaIh/dPyQ6x2Ul1GlkkSYXUhhixEzExGp9g84eCyVkbCB" "U3SK6SNKyR7anAXDVQIDAQAB", "hbI93aGAwPF9au0eYsawRz0jtYi4lSFXC9KleyQDg+6J+UW1kiWvE3", - "phone", + 3, "ios:1.1.1", "iOS 99.99.99"); EXPECT_EQ( @@ -254,7 +254,7 @@ "ECqgx4zqajPTzVt7EAOGaIh/dPyQ6x2Ul1GlkkSYXUhhixEzExGp9g84eCyVkbCB" "U3SK6SNKyR7anAXDVQIDAQAB", "hbI93aGAwPF9au0eYsawRz0jtYi4lSFXC9KleyQDg+6J+UW1kiWvE3", - "phone", + 3, "ios:1.1.1", "iOS 99.99.99"); EXPECT_EQ(