|
@@ -672,7 +672,7 @@ module Actor = struct
|
|
(let*% pk = Ap.PubKeyPem.(private_of_pem pk_pem)
|
|
(let*% pk = Ap.PubKeyPem.(private_of_pem pk_pem)
|
|
|> Result.map_error (fun e ->
|
|
|> Result.map_error (fun e ->
|
|
Logr.warn (fun m -> m "%s.%s %s" "Iweb.Actor.Icon" "get" e);
|
|
Logr.warn (fun m -> m "%s.%s %s" "Iweb.Actor.Icon" "get" e);
|
|
- Http.s500' )
|
|
|
|
|
|
+ Http.s500')
|
|
in
|
|
in
|
|
let date = Ptime_clock.now () in
|
|
let date = Ptime_clock.now () in
|
|
let base = base () in
|
|
let base = base () in
|
|
@@ -1364,27 +1364,28 @@ end
|
|
module Notifyme = struct
|
|
module Notifyme = struct
|
|
let get ~base uuid _tnow (r : Cgi.Request.t) =
|
|
let get ~base uuid _tnow (r : Cgi.Request.t) =
|
|
assert ("http://ostatus.org/schema/1.0/subscribe" = As2_vocab.Constants.Webfinger.ostatus_rel);
|
|
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
|
|
end
|
|
|
|
|
|
module Search = struct
|
|
module Search = struct
|