Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3512932
D5560.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D5560.diff
View Options
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;
@@ -33,6 +33,8 @@
static const std::string FIELD_EXPIRE;
static const std::string FIELD_IS_ONLINE;
+ enum DeviceTypes { MOBILE = 0, WEB = 1, KEYSERVER = 2 };
+
PrimaryKeyDescriptor getPrimaryKeyDescriptor() const override;
PrimaryKeyValue getPrimaryKeyValue() const override;
std::string getTableName() const override;
@@ -40,7 +42,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 +55,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);
}
@@ -63,7 +62,7 @@
this->notifyToken =
itemFromDB.at(DeviceSessionItem::FIELD_NOTIFY_TOKEN).GetS();
this->deviceType =
- itemFromDB.at(DeviceSessionItem::FIELD_DEVICE_TYPE).GetS();
+ std::stoul(itemFromDB.at(DeviceSessionItem::FIELD_DEVICE_TYPE).GetS());
this->appVersion =
itemFromDB.at(DeviceSessionItem::FIELD_APP_VERSION).GetS();
this->deviceOs = itemFromDB.at(DeviceSessionItem::FIELD_DEVICE_OS).GetS();
@@ -109,7 +108,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",
+ database::DeviceSessionItem::DeviceTypes::MOBILE,
"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),
+ database::DeviceSessionItem::DeviceTypes::MOBILE,
tools::generateRandomString(12),
tools::generateRandomString(12));
EXPECT_EQ(
@@ -219,7 +219,7 @@
"ECqgx4zqajPTzVt7EAOGaIh/dPyQ6x2Ul1GlkkSYXUhhixEzExGp9g84eCyVkbCB"
"U3SK6SNKyR7anAXDVQIDAQAB",
"hbI93aGAwPF9au0eYsawRz0jtYi4lSFXC9KleyQDg+6J+UW1kiWvE3",
- "phone",
+ database::DeviceSessionItem::DeviceTypes::MOBILE,
"ios:1.1.1",
"iOS 99.99.99");
EXPECT_EQ(
@@ -254,7 +254,7 @@
"ECqgx4zqajPTzVt7EAOGaIh/dPyQ6x2Ul1GlkkSYXUhhixEzExGp9g84eCyVkbCB"
"U3SK6SNKyR7anAXDVQIDAQAB",
"hbI93aGAwPF9au0eYsawRz0jtYi4lSFXC9KleyQDg+6J+UW1kiWvE3",
- "phone",
+ database::DeviceSessionItem::DeviceTypes::MOBILE,
"ios:1.1.1",
"iOS 99.99.99");
EXPECT_EQ(
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 22, 9:05 PM (18 h, 16 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2692655
Default Alt Text
D5560.diff (5 KB)
Attached To
Mode
D5560: [services] Tunnelbroker - Changes to store the `deviceType` as an int instead of string
Attached
Detach File
Event Timeline
Log In to Comment