mirror of https://github.com/LemmyNet/lemmy.git
Implement webmention support (fixes #1395)
parent
329a282aac
commit
f86a99b336
File diff suppressed because it is too large
Load Diff
|
@ -44,3 +44,4 @@ anyhow = "1.0.43"
|
||||||
thiserror = "1.0.26"
|
thiserror = "1.0.26"
|
||||||
background-jobs = "0.9.0"
|
background-jobs = "0.9.0"
|
||||||
reqwest = { version = "0.11.4", features = ["json"] }
|
reqwest = { version = "0.11.4", features = ["json"] }
|
||||||
|
webmention = {version = "0.1.3", features = ["hyper"], default-features = false }
|
||||||
|
|
|
@ -21,12 +21,15 @@ use lemmy_db_queries::{source::post::Post_, Crud, Likeable};
|
||||||
use lemmy_db_schema::source::post::*;
|
use lemmy_db_schema::source::post::*;
|
||||||
use lemmy_utils::{
|
use lemmy_utils::{
|
||||||
request::fetch_site_data,
|
request::fetch_site_data,
|
||||||
|
settings::structs::Settings,
|
||||||
utils::{check_slurs, check_slurs_opt, clean_url_params, is_valid_post_title},
|
utils::{check_slurs, check_slurs_opt, clean_url_params, is_valid_post_title},
|
||||||
ApiError,
|
ApiError,
|
||||||
ConnectionId,
|
ConnectionId,
|
||||||
LemmyError,
|
LemmyError,
|
||||||
};
|
};
|
||||||
use lemmy_websocket::{send::send_post_ws_message, LemmyContext, UserOperationCrud};
|
use lemmy_websocket::{send::send_post_ws_message, LemmyContext, UserOperationCrud};
|
||||||
|
use url::Url;
|
||||||
|
use webmention::Webmention;
|
||||||
|
|
||||||
#[async_trait::async_trait(?Send)]
|
#[async_trait::async_trait(?Send)]
|
||||||
impl PerformCrud for CreatePost {
|
impl PerformCrud for CreatePost {
|
||||||
|
@ -125,6 +128,7 @@ impl PerformCrud for CreatePost {
|
||||||
// Mark the post as read
|
// Mark the post as read
|
||||||
mark_post_as_read(person_id, post_id, context.pool()).await?;
|
mark_post_as_read(person_id, post_id, context.pool()).await?;
|
||||||
|
|
||||||
|
let updated_post_url = updated_post.url.clone();
|
||||||
let object = PostOrComment::Post(Box::new(updated_post));
|
let object = PostOrComment::Post(Box::new(updated_post));
|
||||||
Vote::send(
|
Vote::send(
|
||||||
&object,
|
&object,
|
||||||
|
@ -135,6 +139,12 @@ impl PerformCrud for CreatePost {
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
if let Some(url) = updated_post_url {
|
||||||
|
let hostname = Url::parse(&Settings::get().get_protocol_and_hostname())?;
|
||||||
|
let mut webmention: Webmention = (hostname, url.clone().into_inner()).into();
|
||||||
|
webmention.send().await?;
|
||||||
|
}
|
||||||
|
|
||||||
send_post_ws_message(
|
send_post_ws_message(
|
||||||
inserted_post.id,
|
inserted_post.id,
|
||||||
UserOperationCrud::CreatePost,
|
UserOperationCrud::CreatePost,
|
||||||
|
|
Loading…
Reference in New Issue