Interface GraffitiObjectBase

Objects are the atomic unit in Graffiti that can represent both data (e.g. a social media post or profile) and activities (e.g. a like or follow). Objects are created and modified by a single actor.

Most of an object's content is stored in its value property, which can be any JSON object. However, we recommend using properties from the Activity Vocabulary or properties that emerge in the Graffiti folksonomy to promote interoperability.

The name, actor, and source properties together uniquely describe the object's location and can be converted to a globally unique URI.

The channels and allowed properties enable the object's creator to shape the visibility of and access to their object.

The tombstone and lastModified properties are for caching and synchronization.

interface GraffitiObjectBase {
    value: {};
    channels: string[];
    allowed?: null | string[];
    actor: string;
    name: string;
    source: string;
    lastModified: number;
    tombstone: boolean;
}

Properties

value: {}

The object's content as freeform JSON. We recommend using properties from the Activity Vocabulary or properties that emerge in the Graffiti folksonomy to promote interoperability.

channels: string[]

An array of URIs the creator associates with the object. Objects can only be found by querying one of the object's channels using the Graffiti.discover method. This allows creators to express the intended audience of their object which helps to prevent context collapse even in the highly interoperable ecosystem that Graffiti envisions. For example, channel URIs may be:

  • A user's own actor URI. Putting an object in this channel is a way to broadcast the object to the user's followers, like posting a tweet.
  • The URI of a Graffiti post. Putting an object in this channel is a way to broadcast to anyone viewing the post, like commenting on a tweet.
  • A URI representing a topic. Putting an object in this channel is a way to broadcast to anyone interested in that topic, like posting in a subreddit.
allowed?: null | string[]

An optional array of actor URIs that the creator allows to access the object. If no allowed array is provided, the object can be accessed by anyone (so long as they also know the right channel to look in). An object can always be accessed by its creator, even if the allowed array is empty.

The allowed array is not revealed to users other than the creator, like a BCC email. A user may choose to add a to property to the object's value to indicate other recipients, however this is not enforced by Graffiti and may not accurately reflect the actual allowed array.

allowed can be combined with channels. For example, to send someone a direct message the sender should put their object in the channel of the recipient's actor URI to notify them of the message and also add the recipient's actor URI to the allowed array to prevent others from seeing the message.

actor: string

The URI of the actor that created the object. This actor also has the unique permission to modify or delete the object.

We borrow the term actor from the ActivityPub because like in ActivityPub there is not necessarily a one-to-one mapping between actors and people/users. Multiple people can share the same actor or one person can have multiple actors. Actors can also be bots.

In Graffiti, actors are always globally unique URIs which allows them to also function as channels.

name: string

A name for the object. This name is not globally unique but it is unique when combined with the actor and source. Often times it is not specified by the user and randomly generated during creation. If an object is created with the same name, actor, and source as an existing object, the existing object will be replaced with the new object.

source: string

The URI of the source that stores the object. In some decentralized implementations, it can represent the server or pod that a user has delegated to store their objects. In others it may represent the distributed storage network that the object is stored on.

lastModified: number

The time the object was last modified, measured in milliseconds since January 1, 1970. This is used for caching and synchronization. A number, rather than an ISO string or Date object, is used for easy comparison, sorting, and JSON Schema range queries.

It is possible to use this value to sort objects in a user's interface but in many cases it would be better to use a createdAt property in the object's value to indicate when the object was created rather than when it was modified.

tombstone: boolean

A boolean indicating whether the object has been deleted. Depending on implementation, objects stay available for some time after deletion to allow for synchronization.