Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rest] Align rest events with AFJ events #158

Open
TimoGlastra opened this issue Sep 2, 2022 · 0 comments
Open

[rest] Align rest events with AFJ events #158

TimoGlastra opened this issue Sep 2, 2022 · 0 comments

Comments

@TimoGlastra
Copy link
Contributor

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>
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant