Skip to content

Commit

Permalink
fix: awa
Browse files Browse the repository at this point in the history
  • Loading branch information
CutestNekoAqua committed Jul 16, 2024
1 parent 45a7555 commit 81ef6f8
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/lysand/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,18 @@ async fn query_post(
.json(lysand_user));
}

let target = ObjectId::<post::Model>::from(query.url.clone().unwrap())
.dereference(&data.to_request_data())
.await?;
let opt_model = prelude::Post::find()
.filter(post::Column::Url.eq(query.url.clone().unwrap().as_str()))
.one(db)
.await?;
let target;
if let Some(model) = opt_model {
target = model;
} else {
target = ObjectId::<post::Model>::from(Url::parse(query.url.clone().unwrap().as_str())?)
.dereference(&data.to_request_data())
.await?;
}

Ok(HttpResponse::Ok()
.content_type("application/json")
Expand Down

0 comments on commit 81ef6f8

Please sign in to comment.