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

Overhaul & Extend Webhooks #10461

Closed
3 of 4 tasks
kirrg001 opened this issue Feb 6, 2019 · 1 comment
Closed
3 of 4 tasks

Overhaul & Extend Webhooks #10461

kirrg001 opened this issue Feb 6, 2019 · 1 comment
Assignees
Labels
server / core Issues relating to the server or core of Ghost

Comments

@kirrg001
Copy link
Contributor

kirrg001 commented Feb 6, 2019

Alongside the API v2 and new auth mechanisms we'll be extend our webhooks feature.

Payload

We are currently using the following format:

e.g.

subscribers: [subscriber-model]

We would like to change this format, because we want to make it simpler to consume and we would like to expose changed fields. Furthermore the old format was not API compliant. We have simply introduced a new webhooks field schema, which we should not, because it means we have to A) maintain two formats and B) we could potentially expose fields which are removed on the API level.

The new payload needs to run through the target configured API version (output serialization) to ensure the same field output than the target API version.

resource: {
  current: attributes,
  previous: attributes
}

resource.attributes will only list the fields, which have changed.

IMPORTANT: We won't break the existing events. We will support both formats for a while. We will maybe drop the old format in v3.

New Webhooks

  • Posts

    • post.added
    • post.deleted
    • post.edited
    • post.published
    • post.published.edited
    • post.unpublished
    • post.scheduled
    • post.unscheduled
    • post.rescheduled
  • Pages

    • page.added
    • page.deleted
    • page.edited
    • page.published
    • page.published.edited
    • page.unpublished
    • page.scheduled
    • page.unscheduled
    • page.rescheduled
  • Tags

    • tag.added
    • tag.edited
    • tag.deleted
    • post.tag.``attached
    • post.tag.``detached
    • page.tag.attached
    • page.tag.detached

Security

Coming soon...


Tasks

  • refactor webhook service to use API serializers
  • re-work payload format including current & previous attrs
  • add new webhooks
  • add security concept

Please don't rely on the new available implementation in master till we announce the feature.

@kirrg001 kirrg001 added server / core Issues relating to the server or core of Ghost optimisation labels Feb 6, 2019
@kirrg001 kirrg001 self-assigned this Feb 6, 2019
kirrg001 added a commit that referenced this issue Feb 7, 2019
refs #10461

- helpful if you need to ask if the model was changed
- Bookshelf does not support this feature yet
- bookshelf/bookshelf#1943
kirrg001 added a commit that referenced this issue Feb 7, 2019
kirrg001 added a commit that referenced this issue Feb 7, 2019
refs #10461

- the model layer (only post & user) fetches the model after update
- i assume it was added to ensure a response with all fields
- quick fixing it for now to ensure API layer can access ".wasChanged" to be able to decide if a request modified a resource or not

@note: Bookshelf does not physically update a resource if nothing has changed.
kirrg001 added a commit to kirrg001/Ghost that referenced this issue Feb 7, 2019
refs TryGhost#10461

- do not break the existing webhooks by keeping both payload formats for subscribers events
- refactored webhooks service to run models through target API version
- added new events described in the target issue reference
- this refactoring & enhancement is undocumented, further breaking changes will happen because we are actively working on: TryGhost#10438
kirrg001 added a commit that referenced this issue Feb 7, 2019
refs #10461

- do not break the existing webhooks by keeping both payload formats for subscribers events
- refactored webhooks service to run models through target API version
- added new events described in the target issue reference
- this refactoring & enhancement is undocumented, further breaking changes will happen because we are actively working on: #10438
kevinansfield added a commit to TryGhost/Admin that referenced this issue Feb 26, 2019
refs TryGhost/Ghost#10461
- added new webhook events to the event selection dropdown with grouping
@kevinansfield
Copy link
Contributor

Closing in favour of specific issues for any future enhancements 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
server / core Issues relating to the server or core of Ghost
Projects
None yet
Development

No branches or pull requests

2 participants