Skip to content

[rest] Align rest events with AFJ events #158

@TimoGlastra

Description

@TimoGlastra

The events being emitted in AFJ Rest are different from the event being emitted in AFJ itself. We should try to unify the events being emitted and just follow what is being emitted in AFJ.

This means that for all events being registered in server.ts we should look at the interface of the event and post that. One thing we should handle is that the event can contain object that need to be serialized to json before sending it. WE should check for each individual event, and if this is the case serialize the events ourselves.

So e.g. if we have a basic message state changed event that contains the basicMessageReocrd and the message keys under the payload we must call .toJSON() on both properties and add this to a new json object.

So currently the event looks like this (basic message taken as example):

POST <webhookUri>/basic-messages

{
 "id": "<basicMessageRecordId"
  // ... other properties
}

While we want it to be:

POST <webhookUri>

{
  "type": "string",
   "payload": {
      "message": <message-json>,
      "basicMessageRecord": <record-json>
    }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions