Page MenuHomePhabricator

D4476.id14843.diff
No OneTemporary

D4476.id14843.diff

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
@@ -47,6 +47,9 @@
std::vector<std::shared_ptr<MessageItem>>
findMessageItemsByReceiver(const std::string &toDeviceID);
void removeMessageItem(const std::string &messageID);
+ void removeMessageItemsByIDsForDeviceID(
+ std::vector<std::string> &messageIDs,
+ const std::string &toDeviceID);
};
} // namespace database
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
@@ -209,6 +209,30 @@
this->innerRemoveItem(*item);
}
+void DatabaseManager::removeMessageItemsByIDsForDeviceID(
+ std::vector<std::string> &messageIDs,
+ const std::string &toDeviceID) {
+ std::vector<Aws::DynamoDB::Model::WriteRequest> writeRequests;
+ for (std::string &messageID : messageIDs) {
+ Aws::DynamoDB::Model::DeleteRequest deleteRequest;
+ deleteRequest.AddKey(
+ MessageItem::FIELD_TO_DEVICE_ID,
+ Aws::DynamoDB::Model::AttributeValue(toDeviceID));
+ deleteRequest.AddKey(
+ MessageItem::FIELD_MESSAGE_ID,
+ Aws::DynamoDB::Model::AttributeValue(messageID));
+ Aws::DynamoDB::Model::WriteRequest currentWriteRequest;
+ currentWriteRequest.SetDeleteRequest(deleteRequest);
+ writeRequests.push_back(currentWriteRequest);
+ }
+ this->innerBatchWriteItem(
+ MESSAGES_TABLE_NAME,
+ DYNAMODB_MAX_BATCH_ITEMS,
+ DYNAMODB_BACKOFF_FIRST_RETRY_DELAY,
+ DYNAMODB_MAX_BACKOFF_TIME,
+ writeRequests);
+}
+
} // namespace database
} // namespace network
} // namespace comm

File Metadata

Mime Type
text/plain
Expires
Thu, Jan 9, 12:05 PM (9 h, 32 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2834436
Default Alt Text
D4476.id14843.diff (1 KB)

Event Timeline