3 Commits 6572c46b4b ... f55dc748cc

Author SHA1 Message Date
  Marcus Rohrmoser f55dc748cc clean 1 month ago
  Marcus Rohrmoser 9352cae830 add sqlite3 test. 1 month ago
  Marcus Rohrmoser 7408292dd8 compact 1 month ago

+ 1 - 0
dune-project

@@ -38,6 +38,7 @@ or tech lore, but have a life.")
    (mirage-crypto-rng (< 1.0))
    (optint (>= 0.3.0))
    safepass
+   sqlite3
    timedesc
    tls-lwt
    tyre

+ 23 - 22
lib/iweb.ml

@@ -672,7 +672,7 @@ module Actor = struct
         (let*% pk =  Ap.PubKeyPem.(private_of_pem pk_pem)
                      |> Result.map_error (fun e ->
                          Logr.warn (fun m -> m "%s.%s %s" "Iweb.Actor.Icon" "get" e);
-                         Http.s500' )
+                         Http.s500')
          in
          let date = Ptime_clock.now () in
          let base = base () in
@@ -1364,27 +1364,28 @@ end
 module Notifyme = struct
   let get ~base uuid _tnow (r : Cgi.Request.t) =
     assert ("http://ostatus.org/schema/1.0/subscribe" = As2_vocab.Constants.Webfinger.ostatus_rel);
-    match r.query_string |> Uri.query_of_encoded with
-    | ["resource",[acct]; "rel",["http://ostatus.org/schema/1.0/subscribe"]] ->
-      (Logr.debug (fun m -> m "%s.%s %a %s" "Iweb.Notifyme" "get" Uuidm.pp uuid acct);
-       let*% o = acct |> Rfc7565.of_string
-                 |> Result.map_error (fun _ -> Http.s400') in
-       let wk = o |> Webfinger.well_known_uri in
-       Logr.debug (fun m -> m "%s.%s %a webfinger: %a" "Iweb.Notifyme" "get" Uuidm.pp uuid Uri.pp wk);
-       let%lwt wf = wk |> Webfinger.Client.http_get in
-       let*% wf = wf |> Result.map_error (fun _ -> Http.s500') in
-       let*% tpl = wf.links |> As2_vocab.Types.Webfinger.ostatus_subscribe 
-                   |> Option.to_result ~none:(Http.s502' ~body:("no ostatus subscribe url found in jrd" |> Cgi.Response.body ~ee:E.e1045)) in
-       Logr.debug (fun m -> m "%s.%s %a got template %s" "Iweb.Notifyme" "get" Uuidm.pp uuid tpl);
-       let rx = Str.regexp_string "{uri}" in
-       let uri = Http.reso ~base:(base()) (Uri.make ~path:Ap.proj ())
-                 |> Uri.to_string in
-       tpl
-       |> Str.replace_first rx uri
-       |> Http.s302
-       |> Lwt.return )
-    | _ -> Http.s400
-           |> Lwt.return
+    let base = base () in
+    let pq = Uri.make ~query:(r.query_string |> Uri.query_of_encoded) () in
+    let*% (rel,acct) = ("rel","resource") |> Http.par2 pq in
+    let*% _ = if rel |> Astring.String.equal "http://ostatus.org/schema/1.0/subscribe"
+      then Ok ()
+      else Http.s400 in
+    Logr.debug (fun m -> m "%s.%s %a %s" "Iweb.Notifyme" "get" Uuidm.pp uuid acct);
+    let*% o = acct |> Rfc7565.of_string
+              |> Result.map_error (fun _ -> Http.s400') in
+    let wk = o |> Webfinger.well_known_uri in
+    Logr.debug (fun m -> m "%s.%s %a webfinger: %a" "Iweb.Notifyme" "get" Uuidm.pp uuid Uri.pp wk);
+    let%lwt wf = wk |> Webfinger.Client.http_get in
+    let*% wf = wf |> Result.map_error (fun _ -> Http.s500') in
+    let*% tpl = wf.links |> As2_vocab.Types.Webfinger.ostatus_subscribe 
+                |> Option.to_result ~none:(Http.s502' ~body:("no ostatus subscribe url found in jrd" |> Cgi.Response.body ~ee:E.e1045)) in
+    Logr.debug (fun m -> m "%s.%s %a got template %s" "Iweb.Notifyme" "get" Uuidm.pp uuid tpl);
+    let rx = Str.regexp_string "{uri}" in
+    let me = Uri.make ~path:Ap.proj () |> Http.reso ~base |> Uri.to_string in
+    tpl
+    |> Str.replace_first rx me
+    |> Http.s302
+    |> Lwt.return
 end
 
 module Search = struct

+ 0 - 6
res/static/activitypub/blocked/0.xml

@@ -1,6 +0,0 @@
-<?xml version="1.0"?>
-<?xml-stylesheet type='text/xsl' href='../../themes/current/blocked.xsl'?>
-<feed xmlns="http://www.w3.org/2005/Atom">
-  <title>🤐 Blocked</title>
-  <id>0.xml</id>
-</feed>

+ 0 - 18
res/static/activitypub/liked/0.jsa

@@ -1,18 +0,0 @@
-{
-  "@context": [
-    "https://www.w3.org/ns/activitystreams",
-    "https://w3id.org/security/v1",
-    {
-      "schema": "http://schema.org#",
-      "PropertyValue": "schema:PropertyValue",
-      "value": "schema:value",
-      "@language": "und"
-    }
-  ],
-  "type": "OrderedCollectionPage",
-  "id": "0.jsa",
-  "current": "0.jsa",
-  "last": "0.jsa",
-  "partOf": "0.jsa",
-  "orderedItems": [ ]
-}

+ 0 - 6
res/static/activitypub/liked/0.xml

@@ -1,6 +0,0 @@
-<?xml version="1.0"?>
-<?xml-stylesheet type='text/xsl' href='../../themes/current/liked.xsl'?>
-<feed xmlns="http://www.w3.org/2005/Atom">
-  <title>⭐ Liked</title>
-  <id>0.xml</id>
-</feed>

+ 0 - 7
res/static/activitypub/notify/index.jsa

@@ -1,7 +0,0 @@
-{
-  "@context": "https://www.w3.org/ns/activitystreams",
-  "id": ".",
-  "type": "OrderedCollection",
-  "first": "0.jsa",
-  "last": "0.jsa"
-}

+ 0 - 1
res/static/activitypub/notify/index.xml

@@ -1 +0,0 @@
-0.xml

+ 0 - 18
res/static/activitypub/outbox/0.jsa

@@ -1,18 +0,0 @@
-{
-  "@context": [
-    "https://www.w3.org/ns/activitystreams",
-    "https://w3id.org/security/v1",
-    {
-      "schema": "http://schema.org#",
-      "PropertyValue": "schema:PropertyValue",
-      "value": "schema:value",
-      "@language": "und"
-    }
-  ],
-  "type": "OrderedCollectionPage",
-  "id": ".",
-  "current": ".",
-  "last": ".",
-  "partOf": ".",
-  "orderedItems": [ ]
-}

+ 0 - 6
res/static/activitypub/outbox/0.xml

@@ -1,6 +0,0 @@
-<?xml version="1.0"?>
-<?xml-stylesheet type='text/xsl' href='../../themes/current/outbox.xsl'?>
-<feed xmlns="http://www.w3.org/2005/Atom">
-  <title>Outbox</title>
-  <id>0.xml</id>
-</feed>

+ 0 - 0
res/static/activitypub/outbox/index.jsa


Some files were not shown because too many files changed in this diff