package activitypub

  1. Overview
  2. Docs

Interface of activitypub objects + convenient functions.

Object types

type id = Rdf.Term.term

An id is an RDF term.

val gen_id : Iri.t -> Rdf.Term.term * Iri.t

Generate a new id, by appending to a given base IRI. For a same base IRI, Ids are guaranteed to be generated in increasing order when compared alphanumerically. The function returns both the id and the corresponding IRI, for conveniency.

A Link's interface.

class type object_ = object ... end

An Object's interface.

class type document = object ... end

A Document's interface.

class type image = object ... end

An Image's interface.

class type collection = object ... end

A Collection's interface.

class type collection_page = object ... end

A CollectionPage's interface.

class type ordered_collection = object ... end

An OrderedCollection's interface.

class type ordered_collection_page = object ... end

An OrderedCollectionPage's interface.

class type actor = object ... end

An Actor's interface.

class type activity = object ... end

An Activity's interface.

module AS = Rdf.Activitypub

Activity types

type activity_type = [
  1. | `Accept
  2. | `Add
  3. | `Announce
  4. | `Arrive
  5. | `Block
  6. | `Create
  7. | `Delete
  8. | `Dislike
  9. | `Flag
  10. | `Follow
  11. | `Ignore
  12. | `Invite
  13. | `Join
  14. | `Leave
  15. | `Like
  16. | `Listen
  17. | `Move
  18. | `Offer
  19. | `Question
  20. | `Read
  21. | `Reject
  22. | `Remove
  23. | `TentativeAccept
  24. | `TentativeReject
  25. | `Travel
  26. | `Undo
  27. | `Update
  28. | `View
]
val activity_types : (activity_type * Iri.t) list
val activity_type_of_iri : Iri.t -> activity_type option
val iri_of_activity_type : activity_type -> Iri.t

Actor types

type actor_type = [
  1. | `Application
  2. | `Group
  3. | `Organization
  4. | `Person
  5. | `Service
]
val actor_types : (actor_type * Iri.t) list
val actor_type_of_iri : Iri.t -> actor_type option
val iri_of_actor_type : actor_type -> Iri.t

Convenient functions

val iri_of_lo : [ `L of link | `O of object_ ] -> Iri.t

iri_of_lo (`L link) returns link#href. iri_of_lo (`O obj) returns obj#iri.

val iri_of_liri : [ `I of Iri.t | `L of link ] -> Iri.t

iri_of_liri (`L link) returns link#href. iri_of_liri (`I iri) returns iri.

val iri_of_li : [ `I of image | `L of link ] -> Iri.t

iri_of_li (`L link) returns link#href. iri_of_li (`I image) returns the iri associated to image#id, or else the first iri of image#url.

val actor_name : ?lang:Smap.key -> < name : string option ; name_map : string Smap.t ; preferred_username : string option.. > -> string

actor_name a returns name of actor is present, or preferred_username if present, or "". Whe a lang argument is given, lookup for the name in then name language map of a.

val object_content : ?lang:Smap.key -> object_ -> string

object_content o returns content string of o if present, or "". If a lang argument is given, lookup in the content map of o.

Activity trees

This is a recursive representation of activities, since activities can refer to activities, themselves referring to other activities and so on.

It is sometimes useful to be able to pattern-match on activities on different depths.

type activity_obj = [
  1. | `None
  2. | `Activity of activity_tree
  3. | `Actor of actor_type * object_
  4. | `Object of object_
  5. | `Loop of id
]
and activity_tree = activity_type * activity * activity_obj
val activity_tree : < object_ : object_ option ; type_ : Iri.t.. > as 'a -> (activity_type * 'a * activity_obj) option

Build an activity_tree from the given object and its internal graph. No dereferencing is performed to build the tree.

OCaml

Innovation. Community. Security.