diff options
Diffstat (limited to 'bin/main.ml')
-rw-r--r-- | bin/main.ml | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/bin/main.ml b/bin/main.ml index dcd24aa..67c9786 100644 --- a/bin/main.ml +++ b/bin/main.ml @@ -21,7 +21,7 @@ let (fake_post_2 : Post.t) = let webfinger = {| { - "subject": "acct:blackhole@galaxy.mccd.space", + "subject": "acct:wormhole@galaxy.mccd.space", "links": [ { @@ -43,7 +43,7 @@ let actor = "id": "https://galaxy.mccd.space/actor", "type": "Person", - "preferredUsername": "blackhole", + "preferredUsername": "wormhole", "inbox": "https://galaxy.mccd.space/inbox", "publicKey": { @@ -86,8 +86,20 @@ let () = let message_object = Yojson.Safe.from_string body |> Post.mastodon_post_of_yojson in - message_object |> Post.yojson_of_mastodon_post - |> Yojson.Safe.to_string |> Dream.log "Added post %s"; - message_object |> Post.post_of_mastodon_post |> Post.add; - Dream.json "{}"); + let%lwt actor = + User.get_user (Post.mastodon_actor message_object) + in + match actor with + | Error e -> + Dream.log "User not found %s" (Printexc.to_string e); + let code = Some 400 in + Dream.json ?code "User not found" + | Ok actor -> + Dream.log "User found"; + message_object + |> Post.post_of_mastodon_post (User.name actor) + |> Post.add; + message_object |> Post.yojson_of_mastodon_post + |> Yojson.Safe.to_string |> Dream.log "Added post %s"; + Dream.json "{}"); ] |