Clean up subscription code; handle error properly.

This commit is contained in:
Paul
2021-02-19 12:48:52 +00:00
parent 02077a4024
commit 78cfbf9d21
7 changed files with 17 additions and 12 deletions

View File

@@ -6,7 +6,7 @@ use rauth::auth::Session;
#[post("/unsubscribe")]
pub async fn req(session: Session) -> Result<()> {
let col = get_collection("accounts")
get_collection("accounts")
.update_one(
doc! {
"_id": session.user_id,
@@ -20,7 +20,10 @@ pub async fn req(session: Session) -> Result<()> {
None,
)
.await
.unwrap();
.map_err(|_| Error::DatabaseError {
operation: "to_document",
with: "subscription",
})?;
Ok(())
}