package activitypub

  1. Overview
  2. Docs

Module Activitypub.ObjectSource

Objects pre-implementation and graph convenient functions.

Convenient functions to implement Types.object_s, including a virtual object_ class performing queries on its internal graph.

Errors

Sourcetype E.error +=
  1. | Could_not_parse_graph of Iri.t * Ldp.Ct.t * string
  2. | Http_error of Iri.t * Cohttp.Code.meth * string

Content-types and mime-types

Sourceval ct_json : Ldp.Ct.t

 application/json

Sourceval mime_json : Ldp.Ct.mime
Sourceval ct_jsonld : Ldp.Ct.t

 application/ld+json

Sourceval mime_jsonld : Ldp.Ct.mime
Sourceval ct_activity_json : Ldp.Ct.t

 application/activity+json

Sourceval mime_activity_json : Ldp.Ct.mime
Sourceval accept_rdf_cts : Ldp.Ct.t list

List of accepted content-types: json-ld, activity_json, json, turtle, xmlrdf.

JSON remote loader and parser

Sourceval jsonld_load_remote : ?loader:(Iri.Map.key -> (string, exn) result Lwt.t) -> string option -> Iri.Map.key -> (string, exn) result Lwt.t
Sourceval jsonld_string_to_graph : ?g:Rdf.Graph.graph -> Rdf_json_ld.T.options -> string -> (Rdf.Graph.graph * Iri.t option) Lwt.t
Sourceval jsonld_parser : ?jsonld_loader:(Iri.Map.key -> (string, exn) result Lwt.t) -> string option -> Rdf.Graph.graph -> Ldp.Ct.t -> string -> (Rdf.Graph.graph * Iri.t option, E.error) result Lwt.t
Sourceval parse_graph : ?jsonld_loader:(Iri.Map.key -> (string, exn) result Lwt.t) -> string option -> Iri.t -> Ldp.Ct.t -> string -> (Rdf.Graph.graph * Iri.t option, E.error) result Lwt.t
Sourcemodule G : sig ... end

A module with convenient function to query an object_'s graph.

Implementations of objects

Sourceval none_if_iri_only : Rdf.Term.term -> Rdf.Graph.graph option -> Rdf.Graph.graph option

Implementation of a link.

Sourceclass virtual object_ : ?g:Rdf.Graph.graph option -> Types.id -> object ... end

A pre-implementation of an Types.object_. Dereferencing and casting methods remain to be implemented.

Sourceval pp : 'a -> < pp : 'a -> unit -> 'b.. > -> 'b

pp ppf o pretty-prints the given object_ to ppf.

Convenient functions

Sourceval graph_roots : Rdf.Graph.graph -> Rdf.Term.term list

graph_roots g returns the list of root nodes, i.e. nodes which do not appear as object in edges of the graph. Some nodes are filtered out (blank nodes having a blank node as type, which are sent by Mastodon).

Sourceval activity_types : Iri.Set.t
Sourceval is_activity : Iri.Set.elt -> bool

is_activity typ returns whether typ corresponds to an activity type.

map_graph f g returns a new graph with all triples mapped with f. f is also applied to the graph name (an IRI) to get the name of the new graph (as an IRI).

Sourceval copy_addresses : src: < audience : [< `L of < href : Iri.t.. > | `O of < id : Rdf.Term.term.. > ] option ; bcc : [< `L of < href : Iri.t.. > | `O of < id : Rdf.Term.term.. > ] list ; bto : [< `L of < href : Iri.t.. > | `O of < id : Rdf.Term.term.. > ] list ; cc : [< `L of < href : Iri.t.. > | `O of < id : Rdf.Term.term.. > ] list ; to_ : [< `L of < href : Iri.t.. > | `O of < id : Rdf.Term.term.. > ] list.. > -> dst:Rdf.Graph.graph -> dstid:Rdf.Term.term -> bool

For each relation to_, bto, cc, bcc and audience of src, copy_addresses ~src ~dst ~dstid adds a triple in graph dst with dstid as subjet and the same predicates (to, cc, ...) and objects. Returns true if at least one address was copied in dst (but does not check if such a triple already existed).

Sourceval remove_addresses : Rdf.Graph.graph -> Rdf.Term.term -> unit

remove_addresses g sub removes all triples of g with subject sub and to, bto, cc, bcc or audience predicate.

id_of_link_or_object (`L link) returns Iri link#href. id_of_link_or_object (`O obj) returns obj#id.

Sourceval remove_bto_bcc : Rdf.Graph.graph -> unit

remove_bto_bcc g removes all triples having bto and bcc as predicate.