Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3378829
D5179.id16949.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D5179.id16949.diff
View Options
diff --git a/services/tunnelbroker/src/Database/DatabaseManager.h b/services/tunnelbroker/src/Database/DatabaseManager.h
--- a/services/tunnelbroker/src/Database/DatabaseManager.h
+++ b/services/tunnelbroker/src/Database/DatabaseManager.h
@@ -43,6 +43,9 @@
findSessionItem(const std::string &deviceID);
void removeSessionItem(const std::string &sessionID);
void updateSessionItemIsOnline(const std::string &sessionID, bool isOnline);
+ bool updateSessionItemDeviceToken(
+ const std::string &sessionID,
+ const std::string &newDeviceToken);
void putSessionSignItem(const SessionSignItem &item);
std::shared_ptr<SessionSignItem>
diff --git a/services/tunnelbroker/src/Database/DatabaseManager.cpp b/services/tunnelbroker/src/Database/DatabaseManager.cpp
--- a/services/tunnelbroker/src/Database/DatabaseManager.cpp
+++ b/services/tunnelbroker/src/Database/DatabaseManager.cpp
@@ -115,6 +115,45 @@
}
}
+bool DatabaseManager::updateSessionItemDeviceToken(
+ const std::string &sessionID,
+ const std::string &newDeviceToken) {
+ std::shared_ptr<DeviceSessionItem> item = this->findSessionItem(sessionID);
+ if (item == nullptr) {
+ LOG(ERROR) << "Can't find for update sessionItem for sessionID: "
+ << sessionID;
+ return false;
+ }
+ Aws::DynamoDB::Model::UpdateItemRequest request;
+ request.SetTableName(item->getTableName());
+
+ Aws::DynamoDB::Model::AttributeValue attributeKeyValue;
+ attributeKeyValue.SetS(sessionID);
+ request.AddKey(DeviceSessionItem::FIELD_SESSION_ID, attributeKeyValue);
+ Aws::String update_expression("SET #a = :valueA");
+ request.SetUpdateExpression(update_expression);
+ Aws::Map<Aws::String, Aws::String> expressionAttributeNames;
+ expressionAttributeNames["#a"] = DeviceSessionItem::FIELD_NOTIFY_TOKEN;
+ request.SetExpressionAttributeNames(expressionAttributeNames);
+
+ Aws::DynamoDB::Model::AttributeValue attributeUpdatedValue;
+ attributeUpdatedValue.SetS(newDeviceToken);
+ Aws::Map<Aws::String, Aws::DynamoDB::Model::AttributeValue>
+ expressionAttributeValue;
+ expressionAttributeValue[":valueA"] = attributeUpdatedValue;
+ request.SetExpressionAttributeValues(expressionAttributeValue);
+
+ const Aws::DynamoDB::Model::UpdateItemOutcome &result =
+ getDynamoDBClient()->UpdateItem(request);
+ if (!result.IsSuccess()) {
+ LOG(ERROR)
+ << "Error updating device token at updateSessionItemDeviceToken: "
+ << result.GetError().GetMessage();
+ return false;
+ }
+ return true;
+}
+
void DatabaseManager::putSessionSignItem(const SessionSignItem &item) {
Aws::DynamoDB::Model::PutItemRequest request;
request.SetTableName(item.getTableName());
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Nov 28, 1:26 PM (21 h, 39 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2594093
Default Alt Text
D5179.id16949.diff (2 KB)
Attached To
Mode
D5179: [services] Tunnelbroker - Add `updateSessionItemDeviceToken` database method
Attached
Detach File
Event Timeline
Log In to Comment