37 lines
1.3 KiB
Rust
37 lines
1.3 KiB
Rust
use crate::error::GementionError;
|
|
use crate::models::mentions::{C2SMentionRequest, Mention};
|
|
use crate::models::web::MentionResponse;
|
|
use crate::validation::Validation;
|
|
use crate::verification::verify;
|
|
use fluffer::Client;
|
|
|
|
/// Receive a client-to-server Gemention: i.e. a user posting a
|
|
/// comment to a gemention-enabled page. The client must identify
|
|
/// themselves with a cert that at least has a username.
|
|
pub(crate) async fn receive_c2s_gemention(
|
|
client: Client,
|
|
) -> Result<MentionResponse, GementionError> {
|
|
let mention_upload = C2SMentionRequest::try_from(&client)?.validate()?;
|
|
let mut mention = Mention::try_from(mention_upload)?;
|
|
verify(&client.url, &mut mention).await?;
|
|
|
|
Ok(MentionResponse::from(mention))
|
|
}
|
|
|
|
/// Receive a server-to-server Gemention: another capsule linking to a
|
|
/// gemention-enabled page on this capsule. There is an exchange of
|
|
/// titan keys so that the servers can talk to one another.
|
|
pub(crate) async fn receive_s2s_gemention(
|
|
client: Client,
|
|
) -> Result<MentionResponse, GementionError> {
|
|
let mention_upload = C2SMentionRequest::try_from(&client)?;
|
|
let mut mention = Mention::try_from(mention_upload)?;
|
|
verify(&client.url, &mut mention).await?;
|
|
|
|
Ok(MentionResponse::from(mention))
|
|
}
|
|
|
|
// Render comments gemtext by requesting comments for a page.
|
|
|
|
// Proxy a webmention to Titan endpoint.
|