description |
---|
The event is the former message, but way more flexible, allowing us to use it for different goals. Currently, we only use it for messages and some room events. |
interface IEvent<T extends EDataDefinition> {
_id: string;
clid?: string;
pids: Array<string>;
v: number;
ts: Date;
src: string;
ct: EventContext;
cid: string;
t: EventTypeDescriptor;
dHash: string;
o: T;
d: T;
isLeaf?: boolean;
deletedAt?: Date;
}
Property | Description |
---|---|
_id | The event id, which is a SHA256 hash of the src , ct , cid , _pids , t , ts and dHash |
clid | This is the "id generated by the client", on V1 our clients generate the _id of the message, so this needs to be here for backward compatibility |
pids | The ids of the previous events |
v | The version of the schema |
src | The source of this event, which server, this will be used to federate events later on |
ct | This is part of the context, holds the type of the context (for example, "room"), more in EventContext |
cid | This is also part of the context, holds the of the context (like the room id) |
t | The type of the event, details in EventTypeDescriptor |
dHash | The hash of some or all of the properties on d , depending on the event type |
o | The event's data when it was created, this never changes and it is used to calcute the hash when a integrity verification is realized |
d | The event's data, the payload, details in EventDataDefinition, this can change when and event is updated using IEventDataUpdate |
isLeaf | This will on appear when it is set to true and determines wheter or not this is the latest item of a chain, the leaf of the tree. More than one event may have the isLeaf flagged as true in the same context |
deletedAt | The date that this event was deleted |
Example of types "room" and "msg":
{
room_events: [
{
"_id": "8aa776ae767c37254c6a85f914a6151d3bb558ff0a9d639f13f0fe5f11af92db",
"pids": [],
"v": 2,
"ts": ISODate("2020-06-11T19:46:40.192Z"),
"src": "peerc.allskar.com",
"ct": "room",
"cid": "a7c5MQFQGe4XKMyEo",
"t": "room",
"dHash": "469d7080b26464d8e684dc72c409dd669676ff0e6bbdd4b6f3392c4cb1fd780d",
"o": {
...data
},
"d": {
...data
}
},
{
"_id": "f53baadb1090c2b4f9d445d030902e142065b5e177a50799c2cc6b1d2a75800e",
"clid": "D2Hznvc4jt7YRSaQy",
"pids": [
"8aa776ae767c37254c6a85f914a6151d3bb558ff0a9d639f13f0fe5f11af92db"
],
"v": 2,
"ts": ISODate("2020-06-11T19:46:42.385Z"),
"src": "localhost",
"ct": "room",
"cid": "a7c5MQFQGe4XKMyEo",
"t": "msg",
"dHash": "793dd0f58f7f9b243ecb35fed189260633058e0ee1468813148b4e8b33567a2e",
"o": {
...data
},
"d": {
...data
}
}
]
}