pub mod error;
pub mod html;
pub mod http_client;
pub mod link_header;
pub mod endpoint_discovery;
#[cfg(feature = "receive")]
pub mod storage;
pub mod webmention;
pub(crate) mod wm_url;
pub use crate::error::WebmentionError;
pub use crate::webmention::Webmention;
#[cfg(feature = "receive")]
pub async fn receive_webmention(
storage: &impl crate::storage::WebmentionStorage,
source: &Url,
target: &Url,
) -> Result<bool, WebmentionError> {
let mut mention = Webmention::from((source.clone(), target.clone()));
if mention.check().await? {
println!("Storing webmention {:?}", mention);
storage
.store(mention)
.map_err(|source| WebmentionError::StorageError {
source: Box::new(source),
})?;
return Ok(true);
} else {
Ok(false)
}
}