- let res = Post::update(context.pool(), post_id, &post_form).await;
- let updated_post: Post = match res {
- Ok(post) => post,
- Err(e) => {
- let err_type = if e.to_string() == "value too long for type character varying(200)" {
- "post_title_too_long"
- } else {
- "couldnt_update_post"
- };
-
- return Err(LemmyError::from_error_message(e, err_type));
- }
- };
-
- // Send apub update
- CreateOrUpdatePost::send(
- updated_post.into(),
- &local_user_view.person.clone().into(),
- CreateOrUpdateType::Update,
- context,
- )
- .await?;
+ Post::update(&mut context.pool(), post_id, &post_form)
+ .await
+ .with_lemmy_type(LemmyErrorType::CouldntUpdatePost)?;