From 6a73ee7a4356a9a248a9e9d7c024b7478616c640 Mon Sep 17 00:00:00 2001 From: projectmoon Date: Sat, 30 Mar 2024 18:13:46 +0100 Subject: [PATCH] Better success output --- src/models/mentions.rs | 8 +++++++- src/models/web.rs | 8 +++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/models/mentions.rs b/src/models/mentions.rs index 9dc6cc2..d5cbee5 100644 --- a/src/models/mentions.rs +++ b/src/models/mentions.rs @@ -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 { diff --git a/src/models/web.rs b/src/models/web.rs index 7b507a1..1d4d5f7 100644 --- a/src/models/web.rs +++ b/src/models/web.rs @@ -12,7 +12,7 @@ impl From 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.", }