aboutsummaryrefslogtreecommitdiff
path: root/lib/activitypub/constants.ml
blob: 04883352c0a4204beabfd89d9ef9d3a63a09e69e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
open Containers

module ContentType = struct
  let ld_json_activity_streams = "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\""

  let xrd_xml = "application/xrd+xml"
  let ld_json = "application/ld+json"
  let activity_json = "application/activity+json"
  let plain_json = "application/json"
  let html = "text/html"
  let any = "*/*"

  let content_types = [
    ld_json_activity_streams, `JSON;
    ld_json, `JSON;
    activity_json, `JSON;
    plain_json, `JSON;
    html, `HTML;
    any, `HTML;
  ]

  let of_string content_type =
    List.find_opt
      (fun (str, _) ->
         String.prefix ~pre:str content_type) content_types
    |> Option.map snd


end

module Webfinger = struct
  let json_rd = "application/jrd+json"

  let self_rel = "self"
  let ostatus_rel = "http://ostatus.org/schema/1.0/subscribe"
  let profile_page = "http://webfinger.net/rel/profile-page"
end

module ActivityStreams = struct

  let public = "https://www.w3.org/ns/activitystreams#Public"

  let context : string * Yojson.Safe.t =
    "@context", `List [
      `String "https://www.w3.org/ns/activitystreams";
      `String "https://w3id.org/security/v1"
    ]

end