From 14381fdc52f899b0c75081c83806812feb64bf21 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Mon, 24 Aug 2020 16:57:14 +0200 Subject: [PATCH] in fetcher, replace post/comment::create with upsert --- server/src/apub/fetcher.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/src/apub/fetcher.rs b/server/src/apub/fetcher.rs index 0e1afc7b0..9b87b2fe5 100644 --- a/server/src/apub/fetcher.rs +++ b/server/src/apub/fetcher.rs @@ -342,7 +342,7 @@ async fn fetch_remote_community( .await?; match existing { Ok(e) => blocking(context.pool(), move |conn| Post::update(conn, e.id, &post)).await??, - Err(_) => blocking(context.pool(), move |conn| Post::create(conn, &post)).await??, + Err(_) => blocking(context.pool(), move |conn| Post::upsert(conn, &post)).await??, }; // TODO: we need to send a websocket update here } @@ -367,7 +367,7 @@ pub async fn get_or_fetch_and_insert_post( let post = fetch_remote_object::(context.client(), post_ap_id).await?; let post_form = PostForm::from_apub(&post, context, Some(post_ap_id.to_owned())).await?; - let post = blocking(context.pool(), move |conn| Post::create(conn, &post_form)).await??; + let post = blocking(context.pool(), move |conn| Post::upsert(conn, &post_form)).await??; Ok(post) } @@ -397,7 +397,7 @@ pub async fn get_or_fetch_and_insert_comment( CommentForm::from_apub(&comment, context, Some(comment_ap_id.to_owned())).await?; let comment = blocking(context.pool(), move |conn| { - Comment::create(conn, &comment_form) + Comment::upsert(conn, &comment_form) }) .await??;