|
@@ -30,15 +30,6 @@ static CLIENT: Lazy<Client> = Lazy::new(|| {
|
|
|
Arc::new(Mutex::new(None))
|
|
|
});
|
|
|
|
|
|
-/// folders -> GET, returns list of all mailboxes
|
|
|
-/// sorted_threads_by_date -> GET, returns hashmap with date: list of thread ids sorted by date
|
|
|
-/// get_thread -> GET, returns all information about one thread
|
|
|
-/// get_thread_messages -> GET, returns a list of SerializableMessage in the thread
|
|
|
-/// email -> GET, returns html for the message
|
|
|
-/// search -> GET, returns a list of message ids where search found matches
|
|
|
-/// create_folder -> POST, creates a new mailbox
|
|
|
-/// rename_folder -> POST, renames a mailbox
|
|
|
-/// delete_folder -> POST, deletes a mailbox
|
|
|
pub async fn run_api() {
|
|
|
let cors = warp::cors()
|
|
|
.allow_any_origin()
|
|
@@ -76,6 +67,10 @@ pub async fn run_api() {
|
|
|
.and(warp::get())
|
|
|
.and(warp::query::<SearchQuery>())
|
|
|
.and_then(search_handle))
|
|
|
+ .or(warp::path("get_threads_by_message")
|
|
|
+ .and(warp::get())
|
|
|
+ .and(warp::query::<GetThreadsByMessageQuery>())
|
|
|
+ .and_then(get_threads_by_message_handle))
|
|
|
.or(warp::path("create_folder")
|
|
|
.and(warp::post())
|
|
|
.and(warp::body::json())
|
|
@@ -566,6 +561,18 @@ async fn search_handle(query: SearchQuery) -> Result<impl warp::Reply, warp::Rej
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+#[derive(Deserialize)]
|
|
|
+struct GetThreadsByMessageQuery {
|
|
|
+ id: String
|
|
|
+}
|
|
|
+
|
|
|
+async fn get_threads_by_message_handle(query: GetThreadsByMessageQuery) -> Result<impl warp::Reply, warp::Rejection> {
|
|
|
+ match Indexes::get_threads_with_message(query.id){
|
|
|
+ Ok(result) => Ok(warp::reply::json(&result)),
|
|
|
+ Err(_) => Ok(warp::reply::json(&Vec::<String>::new()))
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
#[derive(Deserialize, Serialize)]
|
|
|
struct IsLoggedInResponse{
|
|
|
is_logged_in: bool
|