diff --git a/server/src/handlers/http/users/filters.rs b/server/src/handlers/http/users/filters.rs index dca63949b..458004125 100644 --- a/server/src/handlers/http/users/filters.rs +++ b/server/src/handlers/http/users/filters.rs @@ -17,7 +17,7 @@ */ use crate::{ - handlers::{http::ingest::PostError, STREAM_NAME_HEADER_KEY}, + handlers::http::ingest::PostError, option::CONFIG, storage::{object_storage::filter_path, ObjectStorageError}, users::filters::{Filter, CURRENT_FILTER_VERSION, FILTERS}, @@ -33,15 +33,7 @@ pub async fn list(req: HttpRequest) -> Result { .match_info() .get("user_id") .ok_or(FiltersError::Metadata("No User Id Provided"))?; - let stream_name = req - .headers() - .iter() - .find(|&(key, _)| key == STREAM_NAME_HEADER_KEY) - .ok_or_else(|| FiltersError::Metadata("Stream Name Not Provided"))? - .1 - .to_str() - .map_err(|_| FiltersError::Metadata("Non ASCII Stream Name Provided"))?; - let filters = FILTERS.list_filters_by_user_and_stream(user_id, stream_name); + let filters = FILTERS.list_filters_by_user(user_id); Ok((web::Json(filters), StatusCode::OK)) } @@ -59,7 +51,7 @@ pub async fn get(req: HttpRequest) -> Result { Err(FiltersError::Metadata("Filter Not Found")) } -pub async fn post(body: Bytes) -> Result { +pub async fn post(body: Bytes) -> Result { let filter: Filter = serde_json::from_slice(&body)?; let filter_id = rand::distributions::Alphanumeric.sample_string(&mut rand::thread_rng(), 10); let user_id = &filter.user_id; @@ -75,7 +67,7 @@ pub async fn post(body: Bytes) -> Result { let filter_bytes = serde_json::to_vec(&cloned_filter)?; store.put_object(&path, Bytes::from(filter_bytes)).await?; - Ok(HttpResponse::Ok().finish()) + Ok((web::Json(cloned_filter), StatusCode::OK)) } pub async fn update(req: HttpRequest, body: Bytes) -> Result { diff --git a/server/src/users/filters.rs b/server/src/users/filters.rs index 58d51a76a..33356270d 100644 --- a/server/src/users/filters.rs +++ b/server/src/users/filters.rs @@ -106,12 +106,12 @@ impl Filters { .cloned() } - pub fn list_filters_by_user_and_stream(&self, user_id: &str, stream_name: &str) -> Vec { + pub fn list_filters_by_user(&self, user_id: &str) -> Vec { self.0 .read() .expect(LOCK_EXPECT) .iter() - .filter(|f| f.user_id == user_id && f.stream_name == stream_name) + .filter(|f| f.user_id == user_id) .cloned() .collect() }