Unverified Commit bbef3ead authored by Alan Sikora's avatar Alan Sikora Committed by gitbook-bot
Browse files

GitBook: [master] 29 pages modified

parent 670c06b8
......@@ -229,18 +229,24 @@
* [Subscriptions](api/schema-definition/subscriptions.md)
* [Message](api/schema-definition/the-message-object.md)
* [Schema Definition v2 \(Draft\)](api/schema-definition-v2/README.md)
* [User](api/schema-definition-v2/user.md)
* [Room](api/schema-definition-v2/room.md)
* [Subscriptions](api/schema-definition-v2/subscriptions.md)
* [Event](api/schema-definition-v2/event/README.md)
* [EventContext](api/schema-definition-v2/event/event-context.md)
* [EventTypeDescriptor](api/schema-definition-v2/event/event-type-descriptor.md)
* [EventMessageTypeDescriptor](api/schema-definition-v2/event/eventmessagetypedescriptor.md)
* [EventDataDefinition](api/schema-definition-v2/event/event-data-definition/README.md)
* [IEventDataEmpty](api/schema-definition-v2/event/event-data-definition/i-event-data-empty.md)
* [IEventDataRoom](api/schema-definition-v2/event/event-data-definition/ieventdataroom.md)
* [IEventDataMessage](api/schema-definition-v2/event/event-data-definition/i-event-data-message.md)
* [IEventDataUpdate](api/schema-definition-v2/event/event-data-definition/i-event-data-update.md)
* [Events](api/schema-definition-v2/events/README.md)
* [EventContext](api/schema-definition-v2/events/eventcontext.md)
* [IEvent](api/schema-definition-v2/events/event/README.md)
* [EventContext](api/schema-definition-v2/events/event/event-context.md)
* [EventTypeDescriptor](api/schema-definition-v2/events/event/event-type-descriptor.md)
* [EventMessageTypeDescriptor](api/schema-definition-v2/events/event/eventmessagetypedescriptor.md)
* [EventDataDefinition](api/schema-definition-v2/events/event/event-data-definition/README.md)
* [IEventDataEmpty](api/schema-definition-v2/events/event/event-data-definition/i-event-data-empty.md)
* [IEventDataUpdate](api/schema-definition-v2/events/event/event-data-definition/i-event-data-update.md)
* [IRoomEvent](api/schema-definition-v2/events/iroomevent/README.md)
* [RoomEventTypeDescriptor](api/schema-definition-v2/events/iroomevent/roomeventtypedescriptor.md)
* [RoomEventDataDefinition](api/schema-definition-v2/events/iroomevent/room-event-data-definition/README.md)
* [IRoomEventDataRoom](api/schema-definition-v2/events/iroomevent/room-event-data-definition/i-room-event-data-room.md)
* [IRoomEventDataMessage](api/schema-definition-v2/events/iroomevent/room-event-data-definition/i-room-event-data-message.md)
* [IFederationInfo](api/schema-definition-v2/ifederationinfo.md)
* [IMessage](api/schema-definition-v2/imessage.md)
* [IRoom](api/schema-definition-v2/room.md)
* [IUser](api/schema-definition-v2/user.md)
* [Realtime API](api/realtime-api/README.md)
* [Method Calls](api/realtime-api/method-calls/README.md)
* [Archive Rooms](api/realtime-api/method-calls/archive-rooms.md)
......
# Events
Events are the core of our system now, everything goes through the events, which are unique and federable.
......@@ -5,15 +5,15 @@ description: >-
events.
---
# Event
# IEvent
### Interface Definition
```typescript
interface IEvent<T extends EDataDefinition> {
_id: string;
_cid?: string;
_pids: Array<string>;
clid?: string;
pids: Array<string>;
v: number;
ts: Date;
src: string;
......@@ -21,25 +21,28 @@ interface IEvent<T extends EDataDefinition> {
cid: string;
t: EventTypeDescriptor;
dHash: string;
o: T;
d: T;
isLeaf: boolean;
_deletedAt?: Date;
isLeaf?: boolean;
deletedAt?: Date;
}
```
Properties description:
* `_id`: The event id, which is a SHA256 hash of the `src`, `ct`, `cid`, `_pids`, `t`, `ts`, `dHash`
* `_cid`: 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](event-context.md)
* `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](event-type-descriptor.md)
* `dHash`: The hash of some or all of the properties on `d`, depending on the event type
* `d`: The event's data, the payload, details in [EDataDefinition](event-data-definition/)
* `_updatedAt`: When this event was updated
| 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](../eventcontext.md) |
| 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](event-type-descriptor.md) |
| 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](event-data-definition/), this can change when and event is updated using [IEventDataUpdate](event-data-definition/i-event-data-update.md) |
| 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":
......@@ -48,7 +51,7 @@ Example of types "room" and "msg":
room_events: [
{
"_id": "8aa776ae767c37254c6a85f914a6151d3bb558ff0a9d639f13f0fe5f11af92db",
"_pids": [],
"pids": [],
"v": 2,
"ts": ISODate("2020-06-11T19:46:40.192Z"),
"src": "peerc.allskar.com",
......@@ -56,15 +59,17 @@ Example of types "room" and "msg":
"cid": "a7c5MQFQGe4XKMyEo",
"t": "room",
"dHash": "469d7080b26464d8e684dc72c409dd669676ff0e6bbdd4b6f3392c4cb1fd780d",
"d": {
"o": {
...data
},
"_updatedAt": ISODate("2020-06-11T19:46:42.392Z")
"d": {
...data
}
},
{
"_id": "f53baadb1090c2b4f9d445d030902e142065b5e177a50799c2cc6b1d2a75800e",
"_cid": "D2Hznvc4jt7YRSaQy",
"_pids": [
"clid": "D2Hznvc4jt7YRSaQy",
"pids": [
"8aa776ae767c37254c6a85f914a6151d3bb558ff0a9d639f13f0fe5f11af92db"
],
"v": 2,
......@@ -74,10 +79,12 @@ Example of types "room" and "msg":
"cid": "a7c5MQFQGe4XKMyEo",
"t": "msg",
"dHash": "793dd0f58f7f9b243ecb35fed189260633058e0ee1468813148b4e8b33567a2e",
"d": {
"o": {
...data
},
"_updatedAt": ISODate("2020-06-11T19:46:44.394Z")
"d": {
...data
}
}
]
}
......
---
description: This holds all the possible payloads for events
---
# EventDataDefinition
This is a merge of all possible event payloads, like [IEventDataEmpty](i-event-data-empty.md) and [IEventDataUpdate](i-event-data-update.md), it also comprehends secondary payloads, like those present in [RoomEventDataDefinition](../../iroomevent/room-event-data-definition/).
---
description: >-
The event type descriptor is what determines the type of that event, which it
will define how to handle each event correctly.
---
# EventTypeDescriptor
The EventTypeDescriptor is an enum:
```typescript
export enum EventTypeDescriptor {
PING = 'ping'
}
```
| Descriptor | Why does it exist? |
| :--- | :--- |
| PING | The ping event is used to determine whether or not the server is alive. Still not being used, but it will be very important when federation is up using the new event system. |
......@@ -22,3 +22,5 @@ export enum EventMessageTypeDescriptor {
| MESSAGE\_PINNED | A message that was pinned to a channel |
| DISCUSSION\_CREATED | When a discussion is created, this message type is assigned |
---
description: All the possible context types
---
# EventContext
The event context holds all the possible context types, currently we only have the `room` context, and it is defined as an ENUM, as seem below.
```typescript
export enum EventContext {
ROOM = 'room',
}
```
---
description: >-
The event is a specialization of the IEvent interface, specific for
room-related events.
---
# IRoomEvent
### Interface Definition
```typescript
export interface IRoomEvent {
ct: EventContext.ROOM;
t: RoomEventTypeDescriptor;
d: EventRoomDataDefinition;
}
```
| Property | Description |
| :--- | :--- |
| ct | This is the context type, hardcoded to `EventContext.ROOM` \([EventContext](../eventcontext.md)\), because this is the room specialized event. |
| t | The type of the event, in this case, one of the possibilities described on [RoomEventTypeDescriptor](roomeventtypedescriptor.md) |
| d | The payload of the event, one of the [RoomEventDataDefinition](room-event-data-definition/) |
---
description: >-
This holds all the possible payloads for the events related to the room
context
---
# RoomEventDataDefinition
Check this item's child sections to learn more about all the possible payloads.
......@@ -2,7 +2,7 @@
description: This is the interface definition for message event's data
---
# IEventDataMessage
# IRoomEventDataMessage
This payload holds the necessary message properties, the definition is:
......@@ -28,8 +28,8 @@ export interface IEventDataMessage {
| Property | What is it? |
| :--- | :--- |
| t | The type descriptor of the message, more in [EventMessageTypeDescriptor](../eventmessagetypedescriptor.md) |
| u | This holds the user which emitted this message, you can see the definition in [IUser](../../user.md) |
| t | The type descriptor of the message, more in [EventMessageTypeDescriptor](../../event/eventmessagetypedescriptor.md) |
| u | This holds the user which emitted this message, you can see the definition in [IUser](../../../user.md) |
| msg | The actual message, the text |
| mentions | \[OPTIONAL\] Holds the user mentions related to this message |
| channels | \[OPTIONAL\] Holds the channel mentions related to this message |
......
......@@ -2,7 +2,7 @@
description: This is the interface definition for room event's data
---
# IEventDataRoom
# IRoomEventDataRoom
The definition is:
......@@ -14,5 +14,5 @@ export interface IEventDataRoom {
| Property | What is it? |
| :--- | :--- |
| room | Holds an [IRoom](../../room.md) interface, which is related to the legacy [Room](../../../schema-definition/the-room-object.md) definition. |
| room | Holds an [IRoom](../../../room.md) interface, which is related to the legacy [Room](../../../../schema-definition/the-room-object.md) definition. |
---
description: >-
The event type descriptor is what determines the type of that event, which it
will define how to handle each event correctly.
The room event type descriptor is what determines the type of a room context
event.
---
# EventTypeDescriptor
# RoomEventTypeDescriptor
The EventTypeDescriptor is an enum:
The RoomEventTypeDescriptor is an enum:
```typescript
export enum EventTypeDescriptor {
// Rooms
export enum RoomEventTypeDescriptor {
ROOM = 'room',
DELETE_ROOM = 'droom',
PRUNE_ROOM_MESSAGES = 'prune',
MESSAGE = 'msg',
EDIT_MESSAGE = 'emsg',
DELETE_MESSAGE = 'dmsg',
......@@ -21,9 +21,9 @@ export enum EventTypeDescriptor {
| Descriptor | Why does it exist? |
| :--- | :--- |
| ROOM | This is the beginning of the history of a room, the genesis of that context \(and context id\). The payload can be seen [IEventDataRoom](event-data-definition/ieventdataroom.md) |
| DELETE\_ROOM | When a room is deleted, an event of this type is generated. This event has no payload, so it uses [IEventDataEmpty](event-data-definition/i-event-data-empty.md) |
| MESSAGE | Every sent message generates an event of type MESSAGE, check more of the payload in [IEventDataMessage](event-data-definition/i-event-data-message.md) |
| EDIT\_MESSAGE | When the message's text is edited, or a reaction is added, or any other kind of update happens, this event is generated. It uses the same payload as the MESSAGE event, but wrapped like [IEventDataUpdate](event-data-definition/i-event-data-update.md)&lt;[IEventDataMessage](event-data-definition/i-event-data-message.md)&gt; |
| DELETE\_MESSAGE | When a message is deleted, an event of this type is generated. This event has no payload, so it uses [IEventDataEmpty](event-data-definition/i-event-data-empty.md) |
| ROOM | This is the beginning of the history of a room, the genesis of that context \(and context id\). The payload can be seen [IEventDataRoom](room-event-data-definition/i-room-event-data-room.md) |
| DELETE\_ROOM | When a room is deleted, an event of this type is generated. This event has no payload, so it uses [IEventDataEmpty](../event/event-data-definition/i-event-data-empty.md) |
| MESSAGE | Every sent message generates an event of type MESSAGE, check more of the payload in [IEventDataMessage](room-event-data-definition/i-room-event-data-message.md) |
| EDIT\_MESSAGE | When the message's text is edited, or a reaction is added, or any other kind of update happens, this event is generated. It uses the same payload as the MESSAGE event, but wrapped like [IEventDataUpdate](../event/event-data-definition/i-event-data-update.md)&lt;[IEventDataMessage](room-event-data-definition/i-room-event-data-message.md)&gt; |
| DELETE\_MESSAGE | When a message is deleted, an event of this type is generated. This event has no payload, so it uses [IEventDataEmpty](../event/event-data-definition/i-event-data-empty.md) |
......@@ -4,7 +4,7 @@ description: >-
the current event system state.
---
# Room
# IRoom
### Interface Definition
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment