|
|
|
@ -59,6 +59,10 @@ impl Comment {
|
|
|
|
|
) -> Result<Comment, Error> {
|
|
|
|
|
let conn = &mut get_conn(pool).await?;
|
|
|
|
|
|
|
|
|
|
conn
|
|
|
|
|
.build_transaction()
|
|
|
|
|
.run(|conn| {
|
|
|
|
|
Box::pin(async move {
|
|
|
|
|
// Insert, to get the id
|
|
|
|
|
let inserted_comment = insert_into(comment)
|
|
|
|
|
.values(comment_form)
|
|
|
|
@ -66,10 +70,9 @@ impl Comment {
|
|
|
|
|
.do_update()
|
|
|
|
|
.set(comment_form)
|
|
|
|
|
.get_result::<Self>(conn)
|
|
|
|
|
.await;
|
|
|
|
|
.await?;
|
|
|
|
|
|
|
|
|
|
if let Ok(comment_insert) = inserted_comment {
|
|
|
|
|
let comment_id = comment_insert.id;
|
|
|
|
|
let comment_id = inserted_comment.id;
|
|
|
|
|
|
|
|
|
|
// You need to update the ltree column
|
|
|
|
|
let ltree = Ltree(if let Some(parent_path) = parent_path {
|
|
|
|
@ -119,9 +122,9 @@ where ca.comment_id = c.id"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
updated_comment
|
|
|
|
|
} else {
|
|
|
|
|
inserted_comment
|
|
|
|
|
}
|
|
|
|
|
}) as _
|
|
|
|
|
})
|
|
|
|
|
.await
|
|
|
|
|
}
|
|
|
|
|
pub async fn read_from_apub_id(
|
|
|
|
|
pool: &mut DbPool<'_>,
|
|
|
|
|