matrix-org / matrix-hookshot

A bridge between Matrix and multiple project management services, such as GitHub, GitLab and JIRA.
https://matrix-org.github.io/matrix-hookshot/
Apache License 2.0
283 stars 68 forks source link

Add ability to respond to webhooks. #838

Closed Half-Shot closed 10 months ago

Half-Shot commented 10 months ago

Fixes #837

This adds two new features to the generic webhook connection type:

Twi1ightSparkle commented 10 months ago

Hookshot is posting the message twice to Matrix when Wait for webhook function to complete before responding is checked. But looks to be sending the correct data back.

Testing what webhook settings duplicates messages ![Screenshot 2023-11-09 at 3 36 06 PM](https://github.com/matrix-org/matrix-hookshot/assets/19155609/5caad62c-6848-4c71-8cb3-b8ad9d93b55e)
const responseBody = `
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<notificationsResponse xmlns="http://soap.sforce.com/2005/09/outbound">
<Ack>true</Ack>
</notificationsResponse>
</soapenv:Body>
</soapenv:Envelope>
`.trim();

result = {
    empty: false,
    msgtype: 'm.text',
    plain: message,
    version: 'v2',
    webhookResponse: {
        body: responseBody,
        contentType: 'application/xml',
        statusCode: 418,
    }
};

Screenshot 2023-11-08 at 5 41 52 PM


Also, Wait for webhook function to complete before responding unchecks itself when you close and re-open the webhook in the configurator.


Waiting for my contact to do an actual test with Salesforce.

Twi1ightSparkle commented 10 months ago

Actually, once you have enabled Wait for webhook function to complete before responding., you can't turn it off again. It appears to just not read waitForComplete": true from the "uk.half-shot.matrix-hookshot.generic.hook", state event when opening the webhook

Twi1ightSparkle commented 10 months ago

Has now been tested with Salesforce, and Sf is happy 🎉