mirror of
https://github.com/Nutomic/ibis.git
synced 2024-11-25 22:51:09 +00:00
fix duplicate article test
This commit is contained in:
parent
aec05ac6b5
commit
04ba1ae48d
3 changed files with 10 additions and 2 deletions
|
@ -60,7 +60,8 @@ async fn create_article(
|
||||||
instance_id: local_instance.id,
|
instance_id: local_instance.id,
|
||||||
local: true,
|
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?;
|
CreateArticle::send_to_followers(article.clone(), &data).await?;
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,13 @@ impl DbArticle {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create(form: &DbArticleForm, conn: &Mutex<PgConnection>) -> MyResult<Self> {
|
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();
|
let mut conn = conn.lock().unwrap();
|
||||||
Ok(insert_into(article::table)
|
Ok(insert_into(article::table)
|
||||||
.values(form)
|
.values(form)
|
||||||
|
|
|
@ -76,7 +76,7 @@ impl Object for DbArticle {
|
||||||
local: false,
|
local: false,
|
||||||
instance_id: instance.id,
|
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?;
|
json.edits.dereference(&article, data).await?;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue