diff --git a/server/src/routes.rs b/server/src/routes.rs
index 2ea6ae9..c29fc6a 100644
--- a/server/src/routes.rs
+++ b/server/src/routes.rs
@@ -1,17 +1,6 @@
-use upend::addressing::{Address, Addressable};
-use upend::common::build;
-use upend::config::UpEndConfig;
-use upend::database::constants::{ADDED_ATTR, LABEL_ATTR};
-use upend::database::entry::{Entry, EntryValue, InvariantEntry};
-use upend::database::hierarchies::{list_roots, resolve_path, UHierPath};
-use upend::database::lang::Query;
-use upend::database::stores::{Blob, UpStore};
-use upend::database::UpEndDatabase;
use crate::extractors::{self};
use crate::previews::PreviewStore;
use crate::util::exec::block_background;
-use upend::util::hash::{b58_decode, b58_encode};
-use upend::util::jobs;
use actix_files::NamedFile;
use actix_multipart::Multipart;
use actix_web::error::{
@@ -35,6 +24,17 @@ use std::sync::Arc;
use std::time::{SystemTime, UNIX_EPOCH};
use tempfile::NamedTempFile;
use tracing::{debug, info, trace};
+use upend::addressing::{Address, Addressable};
+use upend::common::build;
+use upend::config::UpEndConfig;
+use upend::database::constants::{ADDED_ATTR, LABEL_ATTR};
+use upend::database::entry::{Entry, EntryValue, InvariantEntry};
+use upend::database::hierarchies::{list_roots, resolve_path, UHierPath};
+use upend::database::lang::Query;
+use upend::database::stores::{Blob, UpStore};
+use upend::database::UpEndDatabase;
+use upend::util::hash::{b58_decode, b58_encode};
+use upend::util::jobs;
use uuid::Uuid;
#[cfg(feature = "desktop")]
@@ -369,11 +369,17 @@ impl TryInto
for InAddress {
}
}
+#[derive(Deserialize)]
+pub struct UpdateQuery {
+ provenance: Option,
+}
+
#[put("/api/obj")]
pub async fn put_object(
req: HttpRequest,
state: web::Data,
payload: Either, Multipart>,
+ web::Query(query): web::Query,
) -> Result {
check_auth(&req, &state)?;
@@ -391,7 +397,10 @@ pub async fn put_object(
entity,
attribute: in_entry.attribute,
value: in_entry.value,
- provenance: "USER API".to_string(),
+ provenance: match &query.provenance {
+ Some(s) => format!("API {}", s),
+ None => "API".to_string(),
+ },
timestamp: chrono::Utc::now().naive_utc(),
};
@@ -443,7 +452,10 @@ pub async fn put_object(
entity: address.clone(),
attribute: LABEL_ATTR.to_string(),
value: url.clone().into(),
- provenance: "USER API".to_string(),
+ provenance: match &query.provenance {
+ Some(s) => format!("API {}", s),
+ None => "API".to_string(),
+ },
timestamp: chrono::Utc::now().naive_utc(),
}),
};
@@ -473,7 +485,10 @@ pub async fn put_object(
.as_secs()
as f64,
),
- provenance: "USER API".to_string(),
+ provenance: match &query.provenance {
+ Some(s) => format!("API {}", s),
+ None => "API".to_string(),
+ },
timestamp: chrono::Utc::now().naive_utc(),
})?;
}
@@ -552,6 +567,7 @@ pub async fn put_object_attribute(
state: web::Data,
web::Path((address, attribute)): web::Path<(Address, String)>,
value: web::Json,
+ web::Query(query): web::Query,
) -> Result {
check_auth(&req, &state)?;
let connection = state.upend.connection().map_err(ErrorInternalServerError)?;
@@ -569,7 +585,10 @@ pub async fn put_object_attribute(
entity: address,
attribute,
value: value.into_inner(),
- provenance: "USER API".to_string(),
+ provenance: match &query.provenance {
+ Some(s) => format!("API {}", s),
+ None => "API".to_string(),
+ },
timestamp: chrono::Utc::now().naive_utc(),
};