about summary refs log tree commit diff
path: root/kittybox-rs/templates
diff options
context:
space:
mode:
authorVika <vika@fireburn.ru>2022-10-24 00:51:46 +0300
committerVika <vika@fireburn.ru>2022-10-24 00:52:22 +0300
commit729bf77efb0812d0aed6234576fdd06effa5019e (patch)
tree79b9ed227fe6d320e0887e596d52f77d3e3ea532 /kittybox-rs/templates
parent3fd63e5e9d6a05e1dcd84a0ca6dd0930f3ef9cf6 (diff)
downloadkittybox-729bf77efb0812d0aed6234576fdd06effa5019e.tar.zst
indieauth: parse application metadata
Diffstat (limited to 'kittybox-rs/templates')
-rw-r--r--kittybox-rs/templates/src/indieauth.rs23
1 files changed, 19 insertions, 4 deletions
diff --git a/kittybox-rs/templates/src/indieauth.rs b/kittybox-rs/templates/src/indieauth.rs
index e901d7b..908cd2c 100644
--- a/kittybox-rs/templates/src/indieauth.rs
+++ b/kittybox-rs/templates/src/indieauth.rs
@@ -5,7 +5,7 @@ markup::define! {
     AuthorizationRequestPage(
         request: AuthorizationRequest,
         credentials: Vec<EnrolledCredential>,
-        app: serde_json::Value,
+        app: Option<serde_json::Value>,
         user: serde_json::Value
     ) {
         script[type="module"] {
@@ -31,12 +31,27 @@ document.getElementById("indieauth_page").addEventListener("submit", submit_hand
                     }
 
                     p."mini-h-card" {
-                        @if let Some(icon) = app["properties"]["logo"][0].as_str() {
+                        @if let Some(icon) = app
+                            .as_ref()
+                            .and_then(|app| app["properties"]["logo"][0].as_str())
+                        {
                             img.app_icon[src=icon];
+                        } else if let Some(icon) = app
+                            .as_ref()
+                            .and_then(|app| app["properties"]["logo"][0].as_object())
+                        {
+                            img.app_icon[src=icon["src"].as_str().unwrap(), alt=icon["alt"].as_str().unwrap()];
                         }
                         span {
-                            a[href=app["properties"]["url"][0].as_str().unwrap()] {
-                                @app["properties"]["name"][0].as_str().unwrap()
+                            a[href=app
+                              .as_ref()
+                              .and_then(|app| app["properties"]["url"][0].as_str())
+                              .unwrap_or_else(|| request.client_id.as_str())
+                            ] {
+                                @app
+                                    .as_ref()
+                                    .and_then(|app| app["properties"]["name"][0].as_str())
+                                    .unwrap_or_else(|| request.client_id.as_str())
                             }
                             " wants to confirm your identity."
                         }