Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3747620
D3117.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D3117.diff
View Options
diff --git a/services/tunnelbroker/docker-server/contents/server/src/Database/DatabaseManager.h b/services/tunnelbroker/docker-server/contents/server/src/Database/DatabaseManager.h
--- a/services/tunnelbroker/docker-server/contents/server/src/Database/DatabaseManager.h
+++ b/services/tunnelbroker/docker-server/contents/server/src/Database/DatabaseManager.h
@@ -3,7 +3,6 @@
#include "AwsTools.h"
#include "Constants.h"
#include "DatabaseEntitiesTools.h"
-#include "DeviceSessionItem.h"
#include "Tools.h"
#include <aws/core/Aws.h>
@@ -48,6 +47,10 @@
void putPublicKeyItem(const PublicKeyItem &item);
std::shared_ptr<PublicKeyItem> findPublicKeyItem(const std::string &deviceID);
void removePublicKeyItem(const std::string &deviceID);
+
+ void putMessageItem(const MessageItem &item);
+ std::shared_ptr<MessageItem> findMessageItem(const std::string &messageID);
+ void removeMessageItem(const std::string &messageID);
};
} // namespace database
diff --git a/services/tunnelbroker/docker-server/contents/server/src/Database/DatabaseManager.cpp b/services/tunnelbroker/docker-server/contents/server/src/Database/DatabaseManager.cpp
--- a/services/tunnelbroker/docker-server/contents/server/src/Database/DatabaseManager.cpp
+++ b/services/tunnelbroker/docker-server/contents/server/src/Database/DatabaseManager.cpp
@@ -160,6 +160,43 @@
this->innerRemoveItem(*(createItemByType<PublicKeyItem>()), deviceID);
}
+void DatabaseManager::putMessageItem(const MessageItem &item) {
+ Aws::DynamoDB::Model::PutItemRequest request;
+ request.SetTableName(item.getTableName());
+ request.AddItem(
+ MessageItem::FIELD_MESSAGE_ID,
+ Aws::DynamoDB::Model::AttributeValue(item.getMessageID()));
+ request.AddItem(
+ MessageItem::FIELD_FROM_DEVICE_ID,
+ Aws::DynamoDB::Model::AttributeValue(item.getFromDeviceID()));
+ request.AddItem(
+ MessageItem::FIELD_TO_DEVICE_ID,
+ Aws::DynamoDB::Model::AttributeValue(item.getToDeviceID()));
+ request.AddItem(
+ MessageItem::FIELD_PAYLOAD,
+ Aws::DynamoDB::Model::AttributeValue(item.getPayload()));
+ request.AddItem(
+ MessageItem::FIELD_BLOB_HASHES,
+ Aws::DynamoDB::Model::AttributeValue(item.getBlobHashes()));
+ request.AddItem(
+ MessageItem::FIELD_EXPIRE,
+ Aws::DynamoDB::Model::AttributeValue(std::to_string(item.getExpire())));
+ this->innerPutItem(std::make_shared<MessageItem>(item), request);
+}
+
+std::shared_ptr<MessageItem>
+DatabaseManager::findMessageItem(const std::string &messageID) {
+ Aws::DynamoDB::Model::GetItemRequest request;
+ request.AddKey(
+ MessageItem::FIELD_MESSAGE_ID,
+ Aws::DynamoDB::Model::AttributeValue(messageID));
+ return std::move(this->innerFindItem<MessageItem>(request));
+}
+
+void DatabaseManager::removeMessageItem(const std::string &messageID) {
+ this->innerRemoveItem(*(createItemByType<MessageItem>()), messageID);
+}
+
} // namespace database
} // namespace network
} // namespace comm
diff --git a/services/tunnelbroker/docker-server/contents/server/src/Service/TunnelbrokerServiceImpl.cpp b/services/tunnelbroker/docker-server/contents/server/src/Service/TunnelbrokerServiceImpl.cpp
--- a/services/tunnelbroker/docker-server/contents/server/src/Service/TunnelbrokerServiceImpl.cpp
+++ b/services/tunnelbroker/docker-server/contents/server/src/Service/TunnelbrokerServiceImpl.cpp
@@ -20,7 +20,9 @@
config::ConfigManager::getInstance().getParameter(
config::ConfigManager::OPTION_DYNAMODB_SESSIONS_VERIFICATION_TABLE),
config::ConfigManager::getInstance().getParameter(
- config::ConfigManager::OPTION_DYNAMODB_SESSIONS_PUBLIC_KEY_TABLE)};
+ config::ConfigManager::OPTION_DYNAMODB_SESSIONS_PUBLIC_KEY_TABLE),
+ config::ConfigManager::getInstance().getParameter(
+ config::ConfigManager::OPTION_DYNAMODB_MESSAGES_TABLE)};
for (const std::string &table : tablesList) {
if (!database::DatabaseManager::getInstance().isTableAvailable(table)) {
throw std::runtime_error(
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Jan 10, 7:20 PM (17 h, 20 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2854198
Default Alt Text
D3117.diff (3 KB)
Attached To
Mode
D3117: [services] Tunnelbroker - Database public functions for messages.
Attached
Detach File
Event Timeline
Log In to Comment