Better success output
This commit is contained in:
parent
72a3c2f3cf
commit
6a73ee7a43
|
@ -1,6 +1,7 @@
|
|||
use async_trait::async_trait;
|
||||
use fluffer::{Client, GemBytes};
|
||||
use std::fmt::Display;
|
||||
use url::Url;
|
||||
|
||||
use crate::error::GementionError;
|
||||
|
||||
|
@ -103,6 +104,10 @@ impl Mention {
|
|||
&self.target
|
||||
}
|
||||
|
||||
pub fn target_url(&self) -> Url {
|
||||
Url::parse(&format!("gemini://{}", &self.target)).unwrap()
|
||||
}
|
||||
|
||||
pub fn mention_type(&self) -> &MentionType {
|
||||
&self.mention_type
|
||||
}
|
||||
|
@ -125,12 +130,13 @@ impl Mention {
|
|||
|
||||
fn valid_gemtext(&self) -> String {
|
||||
let headline = format!("## {} from {}", self.mention_type, self.user);
|
||||
let header = format!("=> {} In response to this page", self.target_url());
|
||||
let content = match &self.mention_type {
|
||||
MentionType::Reply => self.content.clone().unwrap_or(String::from("[no content]")),
|
||||
MentionType::Like => format!("{} liked this.", self.user),
|
||||
};
|
||||
|
||||
format!("{}\n\n{}", headline, content)
|
||||
format!("{}\n\n{}\n\n### Content\n{}", headline, header, content)
|
||||
}
|
||||
|
||||
fn invalid_gemtext(&self) -> String {
|
||||
|
|
|
@ -12,7 +12,7 @@ impl From<Mention> for MentionResponse {
|
|||
match mention.verify_status() {
|
||||
VerificationStatus::Verified { .. } => Self::VerifiedMention(mention),
|
||||
VerificationStatus::Invalid(_) => Self::InvalidMention(mention),
|
||||
VerificationStatus::NotYetVerified => Self::InvalidMention(mention)
|
||||
VerificationStatus::NotYetVerified => Self::InvalidMention(mention),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -45,9 +45,11 @@ impl MentionResponse {
|
|||
|
||||
pub fn description(&self) -> String {
|
||||
match self {
|
||||
Self::VerifiedMention(_) => "You have successfully submitted a gemention.",
|
||||
Self::VerifiedMention(_) => {
|
||||
"You have successfully submitted a gemention. It is shown below."
|
||||
}
|
||||
Self::InvalidMention(_) => {
|
||||
"There was an error submitting the gemention, detailed below."
|
||||
"There was an error submitting the gemention. The error is detailed below."
|
||||
}
|
||||
Self::NotTitanRequest => "Your request was not a Titan protocol request.",
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue