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

[Web hooks] Ability to wait for pre-hook response #4948

Closed
pdonias opened this issue Apr 23, 2020 · 1 comment · Fixed by #5420
Closed

[Web hooks] Ability to wait for pre-hook response #4948

pdonias opened this issue Apr 23, 2020 · 1 comment · Fixed by #5420

Comments

@pdonias
Copy link
Member

pdonias commented Apr 23, 2020

See xoa-support#2390

Whether or not the hook awaits should be configurable.
Timeout if it never gets a response.

@pdonias pdonias self-assigned this Apr 23, 2020
@pdonias pdonias changed the title [Hooks] Ability to wait for pre-hook response [Web hooks] Ability to wait for pre-hook response Apr 23, 2020
@julien-f
Copy link
Member

  1. adding a new boolean setting:
    method: {
    description: 'The method to be bound to',
    enum: Object.keys(apiMethods).sort(),
    title: 'Method',
    type: 'string',
    },
    type: {
    description:
    'Right before the API call *or* right after the action has been completed',
    enum: ['pre', 'post', 'pre/post'],
    title: 'Type',
    type: 'string',
    },
    url: {
    description: 'The full URL you wish the request to be sent to',
    // It would be more convenient to configure 1 URL for multiple
    // triggers but the UI implementation is not ideal for such a deep
    // configuration schema: https://i.imgur.com/CpvAwPM.png
    title: 'URL',
    type: 'string',
    },
  2. only returns promise if waitHookResponse:
    this._makeRequest(url, type, data).catch(error => {
    log.error('web hook failed', {
    error,
    webHook: { ...data, url, type },
    })
    })
    )
  3. replace by await emitAsync(xo, 'xo:preCall', data):
    xo.emit('xo:preCall', data)
  4. maybe we should do the same for postCall

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants