mirror of https://github.com/LemmyNet/lemmy.git
use post url instead of instance or, better error handling
parent
53079c113a
commit
75e758b557
|
@ -21,7 +21,6 @@ use lemmy_db_queries::{source::post::Post_, Crud, Likeable};
|
|||
use lemmy_db_schema::source::post::*;
|
||||
use lemmy_utils::{
|
||||
request::fetch_site_data,
|
||||
settings::structs::Settings,
|
||||
utils::{check_slurs, check_slurs_opt, clean_url_params, is_valid_post_title},
|
||||
ApiError,
|
||||
ConnectionId,
|
||||
|
@ -29,8 +28,7 @@ use lemmy_utils::{
|
|||
};
|
||||
use lemmy_websocket::{send::send_post_ws_message, LemmyContext, UserOperationCrud};
|
||||
use log::warn;
|
||||
use url::Url;
|
||||
use webmention::Webmention;
|
||||
use webmention::{Webmention, WebmentionError};
|
||||
|
||||
#[async_trait::async_trait(?Send)]
|
||||
impl PerformCrud for CreatePost {
|
||||
|
@ -129,7 +127,19 @@ impl PerformCrud for CreatePost {
|
|||
// Mark the post as read
|
||||
mark_post_as_read(person_id, post_id, context.pool()).await?;
|
||||
|
||||
let updated_post_url = updated_post.url.clone();
|
||||
if let Some(url) = &updated_post.url {
|
||||
let mut webmention = Webmention::new(
|
||||
updated_post.ap_id.clone().into_inner(),
|
||||
url.clone().into_inner(),
|
||||
)?;
|
||||
webmention.set_checked(true);
|
||||
match webmention.send().await {
|
||||
Ok(_) => {}
|
||||
Err(WebmentionError::NoEndpointDiscovered(_)) => {}
|
||||
Err(e) => warn!("Failed to send webmention: {}", e),
|
||||
}
|
||||
}
|
||||
|
||||
let object = PostOrComment::Post(Box::new(updated_post));
|
||||
Vote::send(
|
||||
&object,
|
||||
|
@ -140,15 +150,6 @@ impl PerformCrud for CreatePost {
|
|||
)
|
||||
.await?;
|
||||
|
||||
if let Some(url) = updated_post_url {
|
||||
let hostname = Url::parse(&Settings::get().get_protocol_and_hostname())?;
|
||||
let mut webmention: Webmention = (hostname, url.into_inner()).into();
|
||||
webmention.set_checked(true);
|
||||
if let Err(e) = webmention.send().await {
|
||||
warn!("Failed to send webmention: {}", e);
|
||||
}
|
||||
}
|
||||
|
||||
send_post_ws_message(
|
||||
inserted_post.id,
|
||||
UserOperationCrud::CreatePost,
|
||||
|
|
Loading…
Reference in New Issue