|
@@ -3498,6 +3498,7 @@ void HttpServer::HandleCreateDocument(const httplib::Request& req, httplib::Resp
|
|
|
CreateDocumentRequest create_req;
|
|
CreateDocumentRequest create_req;
|
|
|
create_req.workspace_id = workspace_id;
|
|
create_req.workspace_id = workspace_id;
|
|
|
create_req.collection = collection_name;
|
|
create_req.collection = collection_name;
|
|
|
|
|
+ create_req.user_id = auth_user->user_id; // Set user for _created_by tracking
|
|
|
|
|
|
|
|
if (json.contains("id") && json["id"].is_string()) {
|
|
if (json.contains("id") && json["id"].is_string()) {
|
|
|
create_req.id = json["id"].get<std::string>();
|
|
create_req.id = json["id"].get<std::string>();
|
|
@@ -3628,11 +3629,26 @@ void HttpServer::HandleListDocuments(const httplib::Request& req, httplib::Respo
|
|
|
|
|
|
|
|
nlohmann::json docs_array = nlohmann::json::array();
|
|
nlohmann::json docs_array = nlohmann::json::array();
|
|
|
for (const auto& doc : result.documents) {
|
|
for (const auto& doc : result.documents) {
|
|
|
|
|
+ // Resolve user names for _created_by and _updated_by
|
|
|
|
|
+ nlohmann::json enriched_data = doc.data;
|
|
|
|
|
+ if (doc.data.contains("_created_by") && doc.data["_created_by"].is_string()) {
|
|
|
|
|
+ std::string created_by_name = ResolveUserName(doc.data["_created_by"].get<std::string>());
|
|
|
|
|
+ if (!created_by_name.empty()) {
|
|
|
|
|
+ enriched_data["_created_by_name"] = created_by_name;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (doc.data.contains("_updated_by") && doc.data["_updated_by"].is_string()) {
|
|
|
|
|
+ std::string updated_by_name = ResolveUserName(doc.data["_updated_by"].get<std::string>());
|
|
|
|
|
+ if (!updated_by_name.empty()) {
|
|
|
|
|
+ enriched_data["_updated_by_name"] = updated_by_name;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
nlohmann::json doc_json = {
|
|
nlohmann::json doc_json = {
|
|
|
{"id", doc.id},
|
|
{"id", doc.id},
|
|
|
{"collection", doc.collection},
|
|
{"collection", doc.collection},
|
|
|
{"workspace_id", doc.workspace_id},
|
|
{"workspace_id", doc.workspace_id},
|
|
|
- {"data", doc.data},
|
|
|
|
|
|
|
+ {"data", enriched_data},
|
|
|
{"created_at", doc.created_at},
|
|
{"created_at", doc.created_at},
|
|
|
{"updated_at", doc.updated_at},
|
|
{"updated_at", doc.updated_at},
|
|
|
{"version", doc.version}
|
|
{"version", doc.version}
|
|
@@ -3774,6 +3790,7 @@ void HttpServer::HandleUpdateDocument(const httplib::Request& req, httplib::Resp
|
|
|
update_req.workspace_id = workspace_id;
|
|
update_req.workspace_id = workspace_id;
|
|
|
update_req.collection = collection_name;
|
|
update_req.collection = collection_name;
|
|
|
update_req.id = document_id;
|
|
update_req.id = document_id;
|
|
|
|
|
+ update_req.user_id = auth_user->user_id; // Set user for _updated_by tracking
|
|
|
|
|
|
|
|
if (json.contains("data") && json["data"].is_object()) {
|
|
if (json.contains("data") && json["data"].is_object()) {
|
|
|
update_req.data = json["data"];
|
|
update_req.data = json["data"];
|