2 Commits 991c750e6c ... a9a072d8d0

Autor SHA1 Mensaje Fecha
  Marcus Rohrmoser a9a072d8d0 comments and gentle clean. hace 1 mes
  Marcus Rohrmoser 19e08347f1 notify (current) subscribers on recreated notes. hace 1 mes
Se han modificado 10 ficheros con 105 adiciones y 82 borrados
  1. 1 0
      as2_vocab/encode.ml
  2. 23 22
      as2_vocab/types.ml
  3. 2 2
      chkr/cgi.ml
  4. 4 1
      doc/wb/themes/current/posts.js
  5. 34 21
      lib/ap.ml
  6. 4 2
      lib/cgi.ml
  7. 3 3
      lib/http.ml
  8. 31 29
      lib/iweb.ml
  9. 3 2
      lib/job.ml
  10. 0 0
      lib/main.ml

+ 1 - 0
as2_vocab/encode.ml

@@ -225,6 +225,7 @@ let state = function
   | `Cancelled -> E.string "cancelled"
 
 
+(** https://www.w3.org/TR/activitystreams-vocabulary/#dfn-follow *)
 let follow ?(context = Constants.ActivityStreams.und) ~base ({ id; actor; cc; end_time; object_; to_; state=st(*; raw=_*) }: Types.follow) =
   ap_obj ~context "Follow" [
     "id"      @ id        <: uri ~base;

+ 23 - 22
as2_vocab/types.ml

@@ -40,8 +40,8 @@ type 'a collection = {
   total_items: int option;
 } [@@deriving show, eq]
 
-(** https://www.w3.org/TR/activitystreams-vocabulary/#activity-types *)
-(** https://www.w3.org/TR/activitystreams-vocabulary/#dfn-create *)
+(** https://www.w3.org/TR/activitystreams-vocabulary/#activity-types
+    https://www.w3.org/TR/activitystreams-vocabulary/#dfn-create *)
 type 'a create = {
   id            : uri;
   actor         : uri;
@@ -53,8 +53,8 @@ type 'a create = {
   (* raw: jsonm; *)
 } [@@deriving show, eq]
 
-(** https://www.w3.org/TR/activitystreams-vocabulary/#activity-types *)
-(** https://www.w3.org/TR/activitystreams-vocabulary/#dfn-update *)
+(** https://www.w3.org/TR/activitystreams-vocabulary/#activity-types
+    https://www.w3.org/TR/activitystreams-vocabulary/#dfn-update *)
 type 'a update = {
   id            : uri;
   actor         : uri;
@@ -134,12 +134,12 @@ type public_key = {
   signatureAlgorithm: string option;
 } [@@deriving show, eq]
 
-(* Attachment as seen on typical actor/person profiles, e.g.
- * $ curl -L -H 'Accept: application/activity+json' 'https://digitalcourage.social/users/mro'
- *
- * https://www.w3.org/TR/activitystreams-vocabulary/#dfn-attachment
- * https://docs.joinmastodon.org/spec/activitypub/#schema
- *
+(** Attachment as seen on typical actor/person profiles, e.g.
+    $ curl -L -H 'Accept: application/activity+json' 'https://digitalcourage.social/users/mro'
+
+    https://www.w3.org/TR/activitystreams-vocabulary/#dfn-attachment
+    https://docs.joinmastodon.org/spec/activitypub/#schema
+
     {
       "name": "Support",
       "value": "<a href=\"https://seppo.social/support\">Seppo.Social/support</a>",
@@ -153,7 +153,7 @@ type property_value = {
   value_map : (string * string) list;
 } [@@deriving show, eq]
 
-(* https://www.w3.org/TR/activitystreams-vocabulary/#dfn-link *)
+(** https://www.w3.org/TR/activitystreams-vocabulary/#dfn-link *)
 type link = {
   href      : uri;
   name      : string option;
@@ -161,8 +161,8 @@ type link = {
   rel       : string option;
 } [@@deriving show, eq]
 
-(* https://www.w3.org/TR/activitystreams-vocabulary/#dfn-person
- * https://www.w3.org/TR/activitystreams-core/#actors
+(** https://www.w3.org/TR/activitystreams-vocabulary/#dfn-person
+    https://www.w3.org/TR/activitystreams-core/#actors
 *)
 type person = {
   id                         : uri;
@@ -190,7 +190,7 @@ type person = {
   (*  raw: jsonm; *)
 }  [@@deriving show, eq]
 
-(* https://www.w3.org/TR/activitystreams-vocabulary/#dfn-follow *)
+(** https://www.w3.org/TR/activitystreams-vocabulary/#dfn-follow *)
 type follow = {
   id       : uri;
   actor    : uri;
@@ -202,14 +202,14 @@ type follow = {
   (*  raw: jsonm; *)
 } [@@deriving show, eq]
 
-(* https://www.w3.org/TR/activitystreams-vocabulary/#dfn-tag *)
+(** https://www.w3.org/TR/activitystreams-vocabulary/#dfn-tag *)
 type tag = {
   ty  : [`Mention | `Hashtag ];
   href: uri;
   name: string;
 } [@@deriving show, eq]
 
-(* https://www.w3.org/TR/activitystreams-vocabulary/#dfn-attachment *)
+(** https://www.w3.org/TR/activitystreams-vocabulary/#dfn-attachment *)
 type attachment = {
   type_     : string option;
   (* https://www.w3.org/TR/activitystreams-vocabulary/#dfn-mediatype *)
@@ -218,7 +218,7 @@ type attachment = {
   url       : uri;
 } [@@deriving show, eq]
 
-(* https://www.w3.org/TR/activitystreams-vocabulary/#dfn-note *)
+(** https://www.w3.org/TR/activitystreams-vocabulary/#dfn-note *)
 type note = {
   id         : uri;
   actor      : uri;
@@ -239,7 +239,7 @@ type note = {
   (*raw: jsonm;*)
 } [@@deriving show, eq]
 
-(*  https://www.w3.org/TR/activitystreams-vocabulary/#dfn-follow  *)
+(**  https://www.w3.org/TR/activitystreams-vocabulary/#dfn-follow  *)
 type block = {
   id       : uri;
   actor    : uri;
@@ -248,7 +248,7 @@ type block = {
   (*raw: jsonm;*)
 } [@@deriving show, eq]
 
-(*  https://www.w3.org/TR/activitystreams-vocabulary/#dfn-like *)
+(**  https://www.w3.org/TR/activitystreams-vocabulary/#dfn-like *)
 type like = {
   id       : uri;
   actor    : uri;
@@ -274,12 +274,13 @@ type core_event = core_obj event
 type obj = [ core_obj | core_event ]
 [@@deriving show, eq]
 
+(** https://www.rfc-editor.org/rfc/rfc7033 *)
 module Webfinger = struct
 
   type ty = [
-    | `ActivityJson_ (* we may phase this out completely as Mike pointed out https://www.w3.org/TR/activitypub/#retrieving-objects *)
+    | `ActivityJson_ (** we may phase this out completely as Mike pointed out https://www.w3.org/TR/activitypub/#retrieving-objects *)
     | `ActivityJsonLd
-    | `Atom (* RFC4287 *)
+    | `Atom (** RFC4287 *)
     | `Html
     | `Json
   ]
@@ -289,7 +290,7 @@ module Webfinger = struct
     | Self             of ty * uri
     | ProfilePage      of ty * uri
     | Alternate        of ty * uri
-    | OStatusSubscribe of string (* https://www.rfc-editor.org/rfc/rfc6415#section-3.1.1.1 should contain unescaped {} *)
+    | OStatusSubscribe of string (** https://www.rfc-editor.org/rfc/rfc6415#section-3.1.1.1 should contain unescaped {} *)
   [@@deriving show, eq]
 
   type query_result = {

+ 2 - 2
chkr/cgi.ml

@@ -39,7 +39,7 @@ let webfinger _uuid qs =
            |> Shell.webfinger with
     | Error e ->
       Logr.debug (fun m -> m "%s.%s %s" "cgi" "webfinger" e);
-      Ok (`Bad_request, [Http.H.ct_plain], fun oc -> e |> output_string oc)
+      Ok (`Bad_request, [Http.H.ct_plain], e |> Cgi.Response.body)
     | Ok q ->
       match
         q.links |> As2_vocab.Types.Webfinger.self_link,
@@ -98,7 +98,7 @@ G6aFKaqQfOXKCyWoUiVknQJAXrlgySFci/2ueKlIE1QqIiLSZ8V8OlpFLRnb1pzI
     (match id |> Uri.of_string |> Shell.actor ~key with
      | Error e ->
        Logr.debug (fun m -> m "%s.%s %s" "cgi" "actor" e);
-       Ok (`Bad_request, [Http.H.ct_plain], fun oc -> e |> output_string oc)
+       Ok (`Bad_request, [Http.H.ct_plain], e |> Cgi.Response.body)
      | Ok q ->
        Ok (`OK, [Http.H.ct_jlda], fun oc ->
            let context = As2_vocab.Constants.ActivityStreams.und in

+ 4 - 1
doc/wb/themes/current/posts.js

@@ -160,7 +160,10 @@ const shaded    = "shaded";
 // https://stackoverflow.com/a/69934481/349514
 const smooth = { block: 'start', behavior: 'smooth'};
 window.onpageshow = (event) => {
-  const hi = document.getElementById(location.hash.replace(/.*#/,""));
+  const h0 = location.hash.replace(/.*#/,"");
+  if(h0 == "")
+    return;
+  const hi = document.getElementById(h0);
   if(hi == null)
     return;
   if(/^#[0-9]+$/.test(location.hash)) {

+ 34 - 21
lib/ap.ml

@@ -650,13 +650,15 @@ let snd_reject
     (fun _ -> Logr.info (fun m -> m "%s.%s Reject %a due to fallthrough to %a" "Ap" "snd_reject" Uri.pp id Uri.pp siac.inbox))
     siac.inbox
 
+(** re-used for following as well (there using block, too) *)
 module Followers = struct
+  (** follower tri-state *)
   module State = struct
+    (** Tri-state *)
     type t =
       | Pending
       | Accepted
       | Blocked
-      (** follower tri-state *)
 
     let of_string = function
       | "pending"  -> Some Pending
@@ -676,14 +678,14 @@ module Followers = struct
       then not r
       else r
 
-    type t' = t * Ptime.t * Uri.t * string option * Rfc7565.t option * Uri.t option
     (** Rich follower state info:
-     *
-     * state, timestamp, actor id, name, rfc7565, inbox
+
+        state, timestamp, actor id, name, rfc7565, inbox
     *)
+    type t' = t * Ptime.t * Uri.t * string option * Rfc7565.t option * Uri.t option
 
     let ibox (_,_,ibox,_,_,_ : t') : Uri.t = ibox
-    (* input to fold_left *)
+    (** input to fold_left *)
     let ibox' f a (k,v) = f a (k,v |> ibox)
 
     let of_actor tnow st (siac : As2_vocab.Types.person) : t' =
@@ -779,6 +781,7 @@ module Followers = struct
     assert (id |> Uri.user |> Option.is_none);
     Mapcdb.update_string (id |> Uri.to_string) (v |> State.encode |> Csexp.to_string) cdb
 
+  (** remove from cdb *)
   let remove ?(cdb = cdb) id =
     assert (id |> Uri.user |> Option.is_none);
     Mapcdb.remove_string (id |> Uri.to_string) cdb
@@ -789,8 +792,9 @@ module Followers = struct
     |> find ~cdb
     |> State.is_accepted
 
+  (** https://www.rfc-editor.org/rfc/rfc4287#section-4.1.1 *)
   module Atom = struct
-    (* create all from oldest to newest and return newest file name. *)
+    (** create all from oldest to newest and return newest file name. *)
     let of_cdb
         ?(cdb = cdb)
         ?(predicate = State.predicate ~invert:false)
@@ -901,6 +905,7 @@ module Followers = struct
     let make = Make.make [rule]
   end
 
+  (** https://www.w3.org/TR/activitypub/#followers *)
   module Json = struct
     let to_page ~is_last (i : int) (fs : Uri.t list) : Uri.t As2_vocab.Types.collection_page =
       let p i =
@@ -926,18 +931,18 @@ module Followers = struct
         total_items= None;
       }
 
+    (** write one page of an https://www.w3.org/TR/activitystreams-vocabulary/#dfn-orderedcollection *)
     let to_page_json ~base _prefix ~is_last (i : int) (ids : Uri.t list) =
       to_page ~is_last i ids
       |> As2_vocab.Encode.(collection_page ~base (uri ~base))
 
-    (**
-     * dehydrate into https://www.w3.org/TR/activitystreams-vocabulary/#dfn-orderedcollection
-     * and https://www.w3.org/TR/activitystreams-vocabulary/#dfn-orderedcollectionpage
-     * dst afterwards contains an
-     * index.jsa
-     * index-0.jsa
-     * ...
-     * index-n.jsa
+    (** dehydrate into https://www.w3.org/TR/activitystreams-vocabulary/#dfn-orderedcollection
+        and https://www.w3.org/TR/activitystreams-vocabulary/#dfn-orderedcollectionpage
+        dst afterwards contains an
+        index.jsa
+        index-0.jsa
+        ...
+        index-n.jsa
     *)
     let flush_page_json ~base ~oc prefix ~is_last (tot,pa,lst,_) =
       let fn j = j |> Printf.sprintf "%d.jsa" in
@@ -962,19 +967,19 @@ module Followers = struct
          |> As2_vocab.Encode.(collection ~base (uri ~base))
          |> Ezjsonm.value_to_channel ~minify:false oc)
 
+    (** paging logic *)
     let fold2pages pagesize flush_page (tot,pa,lst,i) id =
       Logr.debug (fun m -> m "%s.%s %a" "Ap.Followers" "fold2pages" Uri.pp id );
       if i >= pagesize
       then (
         flush_page ~is_last:false (tot,pa,lst,i);
-        (tot+1,pa+1,id :: [],0)
+        (tot |> succ,pa |> succ,id :: [],0)
       ) else
-        (tot+1,pa,id :: lst,i+1)
+        (tot |> succ,pa,id :: lst,i |> succ)
+
+    (** dehydrate the cdb (e.g. followers list) into the current directory
 
-    (**
-     * dehydrate the cdb (e.g. followers list) into the current directory
-     *
-     * uses fold2pages & flush_page
+        uses fold2pages & flush_page_json
     *)
     let coll_of_cdb
         ~base
@@ -983,7 +988,6 @@ module Followers = struct
         ?(predicate = State.predicate ~invert:false)
         prefix cdb =
       assert (0 < pagesize && pagesize < 10_001);
-      let _ = predicate in
       (* Logr.debug (fun m -> m "%s.%s %d %a" "Ap.Followers" "cdb2coll" pagesize Uri.pp base ); *)
       let base = Http.reso ~base (Uri.make ~path:prefix ()) in
       let* res = fold_left (fun a (k,(s,_,_,_,_,_)) ->
@@ -1098,6 +1102,7 @@ module Followers = struct
     |> send ~key side_ok siac.inbox
 end
 
+(** Logic for https://www.w3.org/TR/activitypub/#following *)
 module Following = struct
   let n = "subscribed_to"
   let cdb = Mapcdb.Cdb ("app/var/db/" ^ n ^ ".cdb")
@@ -1106,9 +1111,11 @@ module Following = struct
   let remove ?(cdb = cdb) = Followers.remove ~cdb
   let update ?(cdb = cdb) = Followers.update ~cdb
 
+  (** lists whom I subscribed to *)
   module Subscribed_to = struct
     let dir = apub ^ n ^ "/"
 
+    (** Mostly delegates to Followers.Atom.of_cdb  *)
     module Atom = struct
       let target = dir ^ "index.xml"
 
@@ -1130,6 +1137,7 @@ module Following = struct
       }
     end
 
+    (** Mostly delegates to Followers.Json.coll_of_cdb *)
     module Json = struct
       let target = dir ^ "index.jsa"
 
@@ -1153,9 +1161,11 @@ module Following = struct
     |> find ~cdb
     |> Followers.State.is_accepted
 
+  (** lists whom I block *)
   module Blocked = struct
     let dir = apub ^ "blocked" ^ "/"
 
+    (** Mostly delegates to Followers.Atom.of_cdb  *)
     module Atom = struct
       let target = dir ^ "index.xml"
 
@@ -1178,6 +1188,7 @@ module Following = struct
       }
     end
 
+    (** Mostly delegates to Followers.Json.coll_of_cdb *)
     module Json = struct
       let target = dir ^ "index.jsa"
 
@@ -1420,6 +1431,7 @@ module Note = struct
      summary_map = if sensitive then summary_map else [];
      url = [n.id] }
 
+  (** https://www.w3.org/TR/activitypub/#create-activity-outbox *)
   module Create = struct
     let make (obj : As2_vocab.Types.note) : As2_vocab.Types.note As2_vocab.Types.create =
       let frag = match obj.id |> Uri.fragment with
@@ -1445,6 +1457,7 @@ module Note = struct
       |> As2_vocab.Encode.(create ~base ~context (note ~base))
   end
 
+  (** Rather use a tombstone? https://www.w3.org/TR/activitypub/#delete-activity-outbox *)
   module Delete = struct
     let make (obj : As2_vocab.Types.note) : As2_vocab.Types.note As2_vocab.Types.delete =
       let frag = match obj.id |> Uri.fragment with

+ 4 - 2
lib/cgi.ml

@@ -216,6 +216,7 @@ module Request = struct
   let base r =
     r |> srvr |> base' r.script_name
 
+  (** absolute request-uri, without /cgi-bin/ in case *)
   let abs r : Uri.t =
     let u = r |> srvr in
     let u = (r.script_name |> script_url) ^ r.path_info |> Uri.with_path u in
@@ -226,7 +227,7 @@ module Request = struct
   (** fetch http header values and map from lowercase plus the special name (request-target) *)
   let header_get (r : t) = function
     | "(request-target)" ->  Printf.sprintf "%s %s"
-                               (r.request_method |> String.Ascii.lowercase) 
+                               (r.request_method |> String.Ascii.lowercase)
                                (r |> path_and_query |> Uri.to_string)
                              |> Option.some
     | k ->
@@ -240,9 +241,10 @@ module Request = struct
 end
 
 module Response = struct
+  (** return type of the Request handlers. *)
   type t = Cohttp.Code.status_code * (string * string) list * (out_channel -> unit)
 
-  (* for ease of railway processing we use this strange type *)
+  (** for ease of railway processing we use this strange type *)
   type t' = (t, t) result
 
   let body ?(ee = "") b oc =

+ 3 - 3
lib/http.ml

@@ -157,8 +157,8 @@ module H = struct
 end
 
 module R = Cgi.Response
-(* See also https://github.com/aantron/dream/blob/master/src/pure/status.ml *)
-(* RFC1945 demands absolute uris https://www.rfc-editor.org/rfc/rfc1945#section-10.11 *)
+(** See also https://github.com/aantron/dream/blob/master/src/pure/status.ml
+    RFC1945 demands absolute uris https://www.rfc-editor.org/rfc/rfc1945#section-10.11 *)
 let s302 ?(header = []) url = Error (`Found, [ H.ct_plain; H.location url ] @ header, R.nobody)
 let s400' = (`Bad_request,  [ H.ct_plain ], R.nobody)
 let s400  = Error s400'
@@ -193,7 +193,7 @@ let err500 ?(error = s500') ?(level = Logs.Error) msg e =
 
 (** Send a clob as is and 200 Ok *)
 let clob_send _ ct clob =
-  Ok (`OK, [H.content_type ct], fun oc -> output_string oc clob)
+  Ok (`OK, [H.content_type ct], clob |> Cgi.Response.body)
 
 (*
  * https://datatracker.ietf.org/doc/html/draft-cavage-http-signatures-12

+ 31 - 29
lib/iweb.ml

@@ -477,15 +477,15 @@ let uid_redir x : (Auth.uid * Cgi.Request.t, Cgi.Response.t) result =
       Ok (Auth.dummy, r))
     else r302 Passwd.path
 
-(** HTTP endpoint for Profile documents. *)
+(** HTTP endpoint for Profile documents and (un)follow/(un)block. *)
 module Actor = struct
   let path = "/activitypub/actor.xml"
 
   (** HTTP get handler.
-   *
-   * Prefers id (url) but falls back to webfinger (rfc7565) and comes back.
-   *
-   * Returns RDF (xml) with xsl transformation to be view in the browser. *)
+
+      Prefers id (url) but falls back to webfinger (rfc7565) and comes back.
+
+      Returns RDF (xml) with xsl transformation to be view in the browser. *)
   let get ~base uuid (token, (Auth.Uid _uid, (r : Cgi.Request.t))) =
     match Ap.PubKeyPem.(private_of_pem pk_pem) with
     | Error e ->
@@ -507,7 +507,7 @@ module Actor = struct
              match rfc7565 |> String.trim |> Rfc7565.of_string with
              | Error e ->
                Logr.warn (fun m -> m "%s.%s %s" "Iweb.Actor" "get" e);
-               Error (`Bad_request, [Http.H.ct_plain], fun oc -> e |> output_string oc)
+               Error (`Bad_request, [Http.H.ct_plain], Cgi.Response.body e)
                |> Lwt.return
              | Ok o ->
                let wk = o |> Webfinger.well_known_uri in
@@ -591,7 +591,6 @@ module Actor = struct
         | _ -> `Noop
       )
 
-  (** *)
   let post
       ~(base : unit -> Uri.t)
       ?(que = Job.qn)
@@ -656,13 +655,13 @@ module Actor = struct
       ()
     in
     (* do it! *)
-    let _ = match cmd with
-      | `Noop        -> ()
-      | `Subscribe   -> do_subscribe ()
-      | `Block       -> do_block ()
-      | `Unsubscribe -> do_unsubscribe ()
-      | `Unblock     -> do_unblock ()
-    in
+    (match cmd with
+     | `Noop        -> ()
+     | `Subscribe   -> do_subscribe ()
+     | `Block       -> do_block ()
+     | `Unsubscribe -> do_unsubscribe ()
+     | `Unblock     -> do_unblock ()
+    );
     let loc = req |> Cgi.Request.abs in
     let loc = Uri.add_query_param' loc ("id", (todo_id |> Uri.to_string)) in
     Logr.debug (fun m -> m "%s.%s %a 302 back to %a" "Iweb.Actor" "post" Uuidm.pp uuid Uri.pp loc);
@@ -818,7 +817,7 @@ module Http_ = struct
                    |> Option.value ~default:Http.Mime.text_plain
                    |> Http.H.content_type in
           let%lwt b = b |> Cohttp_lwt.Body.to_string in
-          Ok (`OK, [ct], fun oc -> b |> output_string oc)
+          Ok (`OK, [ct], Cgi.Response.body b)
           |> Lwt.return
         | s ->
           let s = s |> Cohttp.Code.string_of_status in
@@ -830,8 +829,8 @@ end
 module Note = struct
   let path = "/note"
 
-  (*
-   curl -L https://example.com/seppo.cgi/note?id=https://digitalcourage.social/users/mro/statuses/111601127682690078
+  (**
+     curl -L https://example.com/seppo.cgi/note?id=https://digitalcourage.social/users/mro/statuses/111601127682690078
   *)
   let get uuid (token, (Auth.Uid _uid, (r : Cgi.Request.t))) : Cgi.Response.t' =
     let que = Ap.Note.ibc_dir in
@@ -844,11 +843,11 @@ module Note = struct
             (fun h ->
                Logr.debug (fun m -> m "%s.%s %s" "Iweb.Note" "get" h);
                try
-                 let h = Scanf.sscanf h "%[a-zA-Z0-9_-]" (fun a -> a) in
-                 Ok (`OK, [Http.H.ct_jlda], fun oc ->
-                     Printf.sprintf "%s%snote-%s.json" que "new/" h
+                 Ok (`OK, [Http.H.ct_jlda],
+                     Scanf.sscanf h "%[a-zA-Z0-9_-]" (fun a -> a)
+                     |> Printf.sprintf "%s%snote-%s.json" que "new/"
                      |> File.to_string
-                     |> output_string oc)
+                     |> Cgi.Response.body)
                  |> Option.some
                with _ -> None) with
     | Some v -> v
@@ -935,6 +934,7 @@ module Profile = struct
           |> to_channel ~xsl:"configform.xsl" oc))
 end
 
+(** HTTP endpoint for a post or note, a single small message. *)
 module Post = struct
   let path = "/post"
   module F = Html.Form
@@ -1057,7 +1057,7 @@ module Post = struct
     | "tags",        v -> {i with tag    = v |> String.split_on_char ' '}
     | "image",       v -> {i with img    = ou v}
     | "description", v -> {i with dsc    = os v}
-    | k,v -> 
+    | k,v ->
       Logr.warn (fun m -> m "%s.%s Ignored get parameter: %s='%s'" "Iweb" "sift_bookmarklet_get" k v);
       i
 
@@ -1098,7 +1098,7 @@ module Post = struct
   let i_ret : F.input = ("returnurl",      "hidden",   [])
   let i_img : F.input = ("lf_image",       "hidden",   [])
 
-  (* only parameter is 'post'
+  (** only parameter is 'post' for the message text to start with.
    * https://code.mro.name/github/Shaarli-Vanilla/src/master/index.php#L427
    * https://code.mro.name/github/Shaarli-Vanilla/src/029f75f180f79cd581786baf1b37e810da1adfc3/index.php#L1548
   *)
@@ -1166,7 +1166,7 @@ module Post = struct
         |> xhtmlform ~clz "Add" "linkform" [i_id; i_dat;i_url;i_tit;i_dsc;i_tag;i_pri;i_sav;i_can;i_tok;i_ret;i_img;] []
         |> to_channel ~xsl:"linkform.xsl" oc))
 
-  (* https://code.mro.name/github/Shaarli-Vanilla/src/master/index.php#L1479 *)
+  (** https://code.mro.name/github/Shaarli-Vanilla/src/master/index.php#L1479 *)
   let post ~base uuid _ (_tok, (frm, (Auth.Uid uid, (req : Cgi.Request.t)))) =
     Logr.debug (fun m -> m "%s.%s %a %s" "Iweb.Post" "post" Uuidm.pp uuid req.query_string);
     let base = base () in
@@ -1222,12 +1222,14 @@ module Post = struct
             let id = id |> uri2id_rel ~base in
             Logr.debug (fun m -> m "%s.%s delete the previous entry %a %a" "Iweb.Post" "post" Uri.pp id Uri.pp r.id);
             let r = Result.bind
-                (Storage.delete id)
+                (id
+                 |> Main.Note.Delete.delete
+                 >>= Main.Note.Delete.notify_subscribers ~due:now ~base)
                 (fun old ->
                    let in_reply_to : Rfc4287.Inreplyto.t list = [Rfc4287.Inreplyto.make old.id] in
                    let updated = now |> Rfc3339.of_ptime ~tz in
                    Ok {r with updated; in_reply_to}
-                ) |> Result.map_error (Http.err500 "ouch") in
+                ) |> Result.map_error (Http.err500 "Iweb.Post.post recreate") in
             r
           | _ ->
             Ok r
@@ -1264,7 +1266,7 @@ module Session = struct
     | None -> (* no ban penalty but 404 nevertheless. *)
       Http.s404
     | Some (Auth.Uid v) ->
-      Ok (`OK, [Http.H.ct_plain], (fun oc -> output_string oc v))
+      Ok (`OK, [Http.H.ct_plain], Cgi.Response.body v)
 end
 
 (* send a potential new to-be-notified to their home server to subscribe back.
@@ -1330,7 +1332,7 @@ module Webfing = struct
     |> s302 ~qs
     |> Http.s302
 
-  (* resolve 3rd party webfinger addresses and redirect to the actor fetch endpoint *)
+  (** resolve 3rd party webfinger addresses and redirect to the actor fetch endpoint *)
   let get uuid (r : Cgi.Request.t) =
     Logr.debug (fun m -> m "%s.%s %a" "Iweb.Webfing" "get" Uuidm.pp uuid);
     let ur = r |> Cgi.Request.path_and_query in
@@ -1340,7 +1342,7 @@ module Webfing = struct
           |> Rfc7565.of_string with
     | Error e ->
       Logr.warn (fun m -> m "%s.%s %s" "Iweb.Webfing" "get" e);
-      Error (`Bad_request, [Http.H.ct_plain], fun oc -> e |> output_string oc)
+      Error (`Bad_request, [Http.H.ct_plain], Cgi.Response.body e)
       |> Lwt.return
     | Ok o ->
       let wk = o |> Webfinger.well_known_uri in

+ 3 - 2
lib/job.ml

@@ -37,7 +37,8 @@ let run  = "run/"
 let tmp  = "tmp/"
 let wait = "wait/"
 
-(** exponentially growing delay. 0 is zero. Has https://encore.dev/blog/retries#jitter ?*)
+(** exponentially growing delay.
+    0 is zero. Has https://encore.dev/blog/retries#jitter ?*)
 let do_wait ?(now = Ptime_clock.now ()) ?(jitter = (Random.float 0.1) -. 0.05) i =
   assert (jitter >= -0.05);
   assert (jitter <= 0.05);
@@ -70,7 +71,7 @@ let compute_nonce byt =
 let compute_fn due n nonce =
   Printf.sprintf "%s.%d.%s.s" due n nonce
 
-(* similar Queue.add *)
+(** similar Queue.add *)
 let enqueue ?(due = Ptime_clock.now ()) q' n byt =
   Logr.debug (fun m -> m "%s.%s %s" "Job" "enqueue" (due |> rfc3339));
   let due = due |> rfc3339 in

+ 0 - 0
lib/main.ml


Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio