diff --git a/src/main.rs b/src/main.rs
index 2ee4a15..3521339 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -25,5 +25,5 @@ async fn rocket() -> _ {
rocket::build()
.manage(db)
.attach(Template::fairing())
- .mount("/", routes![home, subscribe_form, unsubscribe_form])
+ .mount("/", routes![home, subscribe_form, unsubscribe_form, about_start, about_form])
}
diff --git a/src/routes.rs b/src/routes.rs
index 2f7c0db..44c3c4d 100644
--- a/src/routes.rs
+++ b/src/routes.rs
@@ -21,6 +21,41 @@ pub async fn home(flash: Option>) -> Template {
Template::render("base", context! { whoami, flash })
}
+#[get("/about")]
+pub async fn about_start() -> Template {
+ Template::render("about", context! {})
+}
+
+#[post("/about", data = "")]
+pub async fn about_form(peer: Form) -> Result> {
+ info!("Showing follow information about peer {}", &peer.public_key);
+
+ let whoami = match sbot::whoami().await {
+ Ok(value) => value,
+ Err(e) => return Err(Flash::error(Redirect::to(uri!(about_start)), e)),
+ };
+
+ if let Err(e) = utils::validate_public_key(&peer.public_key) {
+ let validation_err_msg = format!("Public key {} is invalid: {}", &peer.public_key, e);
+ warn!("{}", validation_err_msg);
+ return Err(Flash::error(Redirect::to(uri!(about_start)), validation_err_msg));
+ }
+ info!("Public key {} is valid.", &peer.public_key);
+
+ let follow_status = match sbot::is_following(&whoami, &peer.public_key).await {
+ Ok(status) => status,
+ Err(e) => {
+ warn!("{}", e);
+ return Err(Flash::error(Redirect::to(uri!(about_start)), e));
+ }
+ };
+ let success_msg = format!("Follow status for {} : '{}'", &peer.public_key, follow_status);
+ info!("{}", success_msg);
+
+ Ok(Template::render("about", context! { whoami, peer_pubkey: &peer.public_key, status: follow_status }))
+
+}
+
#[post("/subscribe", data = "")]
pub async fn subscribe_form(db: &State, peer: Form) -> Result> {
info!("Subscribing to peer {}", &peer.public_key);
diff --git a/src/sbot.rs b/src/sbot.rs
index 083b255..14be09b 100644
--- a/src/sbot.rs
+++ b/src/sbot.rs
@@ -87,12 +87,12 @@ pub async fn unfollow_if_not_following(remote_peer: &str) -> Result<(), String>
info!("Seeing whether we should unfollow {}", remote_peer);
if let Ok(whoami) = whoami().await {
match is_following(&whoami, remote_peer).await {
- Ok(status) if status.as_str() != "true" => {
+ Ok(status) if status != "true" => {
info!("Status: '{}'", status);
info!("Already not following peer {}. No further action taken", &remote_peer);
Ok(())
},
- Ok(status) if status.as_str() == "true" => {
+ Ok(status) if status == "true" => {
info!("Status: '{}'", status);
match unfollow_peer(remote_peer).await {
Ok(_) => {
diff --git a/templates/about.html.tera b/templates/about.html.tera
new file mode 100644
index 0000000..5eb640b
--- /dev/null
+++ b/templates/about.html.tera
@@ -0,0 +1,35 @@
+
+
+
+
+ lykin check
+
+
+
+ lykin follow
checker
+
+ {% if flash and flash.kind == "error" %}
+ [ {{ flash.message }} ]
+ {% endif %}
+
+ {% if peer_pubkey and whoami and status %}
+
+ me: {{ whoami }}
+ peer: {{ peer_pubkey }}
+ status: {{ status }}
+
+ {% endif %}
+
+
diff --git a/templates/base.html.tera b/templates/base.html.tera
index 47b6487..223f564 100644
--- a/templates/base.html.tera
+++ b/templates/base.html.tera
@@ -7,12 +7,13 @@
lykin
- {{ whoami }}
+ {{ whoami }}
{% if flash and flash.kind == "error" %}
[ {{ flash.message }} ]