events.rs (2263B)
1 use crate::auth::{AdminHeaders, Headers}; 2 use rocket::{form::FromForm, serde::json::Json, Route}; 3 use serde_json::Value; 4 pub fn routes() -> Vec<Route> { 5 routes![get_cipher_events, get_org_events, get_user_events,] 6 } 7 8 #[derive(FromForm)] 9 struct EventRange { 10 #[allow(dead_code)] 11 start: String, 12 #[allow(dead_code)] 13 end: String, 14 #[allow(dead_code)] 15 #[field(name = "continuationToken")] 16 continuation_token: Option<String>, 17 } 18 19 // Upstream: https://github.com/bitwarden/server/blob/9ecf69d9cabce732cf2c57976dd9afa5728578fb/src/Api/Controllers/EventsController.cs#LL84C35-L84C41 20 #[allow(unused_variables, clippy::needless_pass_by_value)] 21 #[get("/organizations/<org_id>/events?<data..>")] 22 fn get_org_events(org_id: &str, data: EventRange, _headers: AdminHeaders) -> Json<Value> { 23 Json(json!({ 24 "data": Vec::<Value>::new(), 25 "object": "list", 26 "continuationToken": None::<&str>, 27 })) 28 } 29 30 #[allow(unused_variables, clippy::needless_pass_by_value)] 31 #[get("/ciphers/<cipher_id>/events?<data..>")] 32 fn get_cipher_events(cipher_id: &str, data: EventRange, _headers: Headers) -> Json<Value> { 33 Json(json!({ 34 "data": Vec::<Value>::new(), 35 "object": "list", 36 "continuationToken": None::<&str>, 37 })) 38 } 39 40 #[allow(unused_variables, clippy::needless_pass_by_value)] 41 #[get("/organizations/<org_id>/users/<user_org_id>/events?<data..>")] 42 fn get_user_events( 43 org_id: &str, 44 user_org_id: &str, 45 data: EventRange, 46 _headers: AdminHeaders, 47 ) -> Json<Value> { 48 Json(json!({ 49 "data": Vec::<Value>::new(), 50 "object": "list", 51 "continuationToken": None::<&str>, 52 })) 53 } 54 pub fn main_routes() -> Vec<Route> { 55 routes![post_events_collect,] 56 } 57 58 #[derive(Deserialize)] 59 struct EventCollection; 60 // Upstream: 61 // https://github.com/bitwarden/server/blob/8a22c0479e987e756ce7412c48a732f9002f0a2d/src/Events/Controllers/CollectController.cs 62 // https://github.com/bitwarden/server/blob/8a22c0479e987e756ce7412c48a732f9002f0a2d/src/Core/Services/Implementations/EventService.cs 63 #[allow(unused_variables, clippy::needless_pass_by_value)] 64 #[post("/collect", format = "application/json", data = "<data>")] 65 fn post_events_collect(data: Json<Vec<EventCollection>>, _headers: Headers) {}