mirror of
https://github.com/oxen-io/session-open-group-server.git
synced 2023-12-13 20:30:35 +01:00
Add delete room endpoint
This commit is contained in:
parent
c4983c9b1c
commit
5fbf648ac8
1 changed files with 19 additions and 0 deletions
|
@ -56,6 +56,25 @@ pub async fn create_room(id: &str, name: &str) -> Result<Response, Rejection> {
|
|||
return Ok(warp::reply::json(&json).into_response());
|
||||
}
|
||||
|
||||
// Currently not exposed
|
||||
pub async fn delete_room(id: &str) -> Result<Response, Rejection> {
|
||||
// Get a connection
|
||||
let pool = &storage::MAIN_POOL;
|
||||
let conn = pool.get().map_err(|_| Error::DatabaseFailedInternally)?;
|
||||
// Insert the room
|
||||
let stmt = format!("DELETE FROM {} WHERE id = (?1)", storage::MAIN_TABLE);
|
||||
match conn.execute(&stmt, params![id]) {
|
||||
Ok(_) => (),
|
||||
Err(e) => {
|
||||
println!("Couldn't delete room due to error: {}.", e);
|
||||
return Err(warp::reject::custom(Error::DatabaseFailedInternally));
|
||||
}
|
||||
}
|
||||
// Return
|
||||
let json = models::StatusCode { status_code: StatusCode::OK.as_u16() };
|
||||
return Ok(warp::reply::json(&json).into_response());
|
||||
}
|
||||
|
||||
pub async fn get_room(room_id: &str) -> Result<Response, Rejection> {
|
||||
// Get a connection
|
||||
let pool = &storage::MAIN_POOL;
|
||||
|
|
Loading…
Reference in a new issue