diff options
Diffstat (limited to '')
-rw-r--r-- | lib/post.ml | 28 | ||||
-rw-r--r-- | lib/user.ml | 14 |
2 files changed, 20 insertions, 22 deletions
diff --git a/lib/post.ml b/lib/post.ml index 5c3d494..dbca936 100644 --- a/lib/post.ml +++ b/lib/post.ml @@ -48,7 +48,11 @@ type mastodon_tag = { } [@@deriving yojson] [@@yojson.allow_extra_fields] -type mastodon_object = { tag : mastodon_tag list; url : string } +type mastodon_object = { + tag : mastodon_tag list; + url : string; + content : string; +} [@@deriving yojson] [@@yojson.allow_extra_fields] type mastodon_post = { @@ -61,7 +65,7 @@ type mastodon_post = { let mastodon_actor post = post.actor let post_of_mastodon_post actor_name = function - | { published; obj = { tag; url }; _ } -> + | { published; obj = { tag; url; content }; _ } -> let tags = List.filter_map (fun { name; kind; _ } -> @@ -70,18 +74,14 @@ let post_of_mastodon_post actor_name = function if kind = "Hashtag" then Some name else None) tag in - { link = url; summary = published; tags; published; author = actor_name } + { + link = url; + summary = content; + tags; + published; + author = actor_name; + author_link = url; + } let get_tld (link : string) = Uri.of_string link |> Uri.host_with_default ~default:"" - -let db = ref [] - -let add (entry : t) = - db := entry :: !db; - print_endline (entry.link ^ " added to db"); - print_endline ("New db size: " ^ string_of_int (List.length !db)) - -let get_all () = - print_endline ("db size: " ^ string_of_int (List.length !db)); - !db diff --git a/lib/user.ml b/lib/user.ml index f0ac7cf..ba802c0 100644 --- a/lib/user.ml +++ b/lib/user.ml @@ -17,14 +17,12 @@ let activity_header = Some (Header.of_list [ ("Accept", "application/activity+json") ]) let get_user actor_url = - try%lwt - let%lwt _, body = - Client.get ?headers:activity_header (Uri.of_string actor_url) - in - body |> Cohttp_lwt.Body.to_string >|= fun body -> - let body = Yojson.Safe.from_string body |> t_of_yojson in - Ok body - with exn -> Lwt.return (Error exn) + let%lwt _, body = + Client.get ?headers:activity_header (Uri.of_string actor_url) + in + body |> Cohttp_lwt.Body.to_string >|= fun body -> + let body = Yojson.Safe.from_string body |> t_of_yojson in + body let get_public_pem user = user.public_key.public_key_pem |> Cstruct.of_string |