1
0
Fork 0
mirror of https://github.com/Nutomic/ibis.git synced 2024-11-22 13:51:09 +00:00

fix duplicate article test

This commit is contained in:
Felix Ableitner 2023-12-04 15:15:43 +01:00
parent aec05ac6b5
commit 04ba1ae48d
3 changed files with 10 additions and 2 deletions

View file

@ -60,7 +60,8 @@ async fn create_article(
instance_id: local_instance.id,
local: true,
};
let article = DbArticle::create(&form, &data.db_connection)?;
dbg!(&form.ap_id);
let article = dbg!(DbArticle::create(&form, &data.db_connection))?;
CreateArticle::send_to_followers(article.clone(), &data).await?;

View file

@ -52,6 +52,13 @@ impl DbArticle {
}
pub fn create(form: &DbArticleForm, conn: &Mutex<PgConnection>) -> MyResult<Self> {
let mut conn = conn.lock().unwrap();
Ok(insert_into(article::table)
.values(form)
.get_result(conn.deref_mut())?)
}
pub fn create_or_update(form: &DbArticleForm, conn: &Mutex<PgConnection>) -> MyResult<Self> {
let mut conn = conn.lock().unwrap();
Ok(insert_into(article::table)
.values(form)

View file

@ -76,7 +76,7 @@ impl Object for DbArticle {
local: false,
instance_id: instance.id,
};
let article = DbArticle::create(&form, &data.db_connection)?;
let article = DbArticle::create_or_update(&form, &data.db_connection)?;
json.edits.dereference(&article, data).await?;