no need to do an actual update in post/comment::upsert

This commit is contained in:
Felix Ableitner 2020-08-24 16:48:42 +02:00
parent ba1135184b
commit 934f83dbe4
3 changed files with 17 additions and 6 deletions

View File

@ -166,7 +166,8 @@ impl Comment {
let existing = Self::read_from_apub_id(conn, &comment_form.ap_id);
match existing {
Err(NotFound {}) => Ok(Self::create(conn, &comment_form)?),
Ok(p) => Ok(Self::update(conn, p.id, &comment_form)?),
// both the old and new comment should be identical so no need to do an update here
Ok(p) => Ok(Self::read(conn, p.id)?),
Err(e) => Err(e),
}
}

View File

@ -183,7 +183,8 @@ impl Post {
let existing = Self::read_from_apub_id(conn, &post_form.ap_id);
match existing {
Err(NotFound {}) => Ok(Self::create(conn, &post_form)?),
Ok(p) => Ok(Self::update(conn, p.id, &post_form)?),
// both the old and new comment should be identical so no need to do an update here
Ok(p) => Ok(Self::read(conn, p.id)?),
Err(e) => Err(e),
}
}

View File

@ -76,13 +76,22 @@ async fn main() -> Result<(), LemmyError> {
);
let activity_queue = create_activity_queue();
let chat_server =
ChatServer::startup(pool.clone(), rate_limiter.clone(), Client::default(), activity_queue.clone()).start();
let chat_server = ChatServer::startup(
pool.clone(),
rate_limiter.clone(),
Client::default(),
activity_queue.clone(),
)
.start();
// Create Http server with websocket support
HttpServer::new(move || {
let context =
LemmyContext::create(pool.clone(), chat_server.to_owned(), Client::default(), activity_queue.to_owned());
let context = LemmyContext::create(
pool.clone(),
chat_server.to_owned(),
Client::default(),
activity_queue.to_owned(),
);
let settings = Settings::get();
let rate_limiter = rate_limiter.clone();
App::new()