Skip to content

[IMP] webhook_outgoing: send outgoing webhooks #13

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

Open
wants to merge 1 commit into
base: 16.0
Choose a base branch
from

Conversation

hoangtrann
Copy link

No description provided.

@hoangtrann hoangtrann force-pushed the 16.0_add-webhook-modules branch from 28220c0 to 208010b Compare July 26, 2024 10:41
@hoangtrann hoangtrann changed the title [ADD] webhook_(base,incoming): receive and send webhooks [WIP] webhook_(base,incoming): receive and send webhooks Jul 26, 2024
@rvalyi
Copy link
Member

rvalyi commented Jul 26, 2024

Great! Using queue job also seems interesting. I didn't dig deeply into the review yet though, but I might use it and help.

For reference here is the webhook code In Odoo 17.0+ CE (so not available on Odoo 16.0)
https://github.com/odoo/odoo/blob/master/addons/base_automation/models/base_automation.py#L98

(usage can be seen here https://medium.com/@karan.bk/simplify-integration-with-odoo-17-using-webhooks-4ec56c46fcb3)
This is not a lot of code; eventually there are some ideas to get, eventually some sort of compatibility can be achieved.

EDIT: to achieve some kind of compatibility, from a quick overview:

cc @pedrobaeza @sebastienbeau @hparfr @sbidoul @lmignon @simahawk @etobella

@rvalyi
Copy link
Member

rvalyi commented Jul 26, 2024

there is also possibly some overlap with https://github.com/OCA/web-api/blob/14.0/webservice/models/webservice_backend.py from the https://github.com/OCA/web-api/tree/14.0 OCA project. In any case, quick and dirty web hooks with no code is certainly something important to have for simple and quick automation.

@rvalyi
Copy link
Member

rvalyi commented Jul 26, 2024

it can also be installed as an option, but eventually this server_action_logging module might help.

@rvalyi
Copy link
Member

rvalyi commented Jul 29, 2024

BTW, @gurneyalex pointed that the security of the native Odoo v17 web hooks is probably not so good: https://x.com/gurneyalex/status/1817900552329560150 ...

So good if this extra module could bring some real security... Is it safe now https://github.com/OCA/webhook/pull/13/files#diff-ca6b9e897fddbb1f998aefd239a9630cef55fbdcd6de7a2b20043e2faff24b29R28 ?

Eventually, we might use base_rest_auth_api_key https://github.com/OCA/rest-framework/tree/16.0/base_rest_auth_api_key may be ?

@ivs-cetmix
Copy link
Member

@hoangtrann @rvalyi looks like `codecov/project' action is still running. It will consume tons of minutes

@ivs-cetmix
Copy link
Member

also @sbidoul please have a look at the codecove job here

@hoangtrann hoangtrann changed the title [WIP] webhook_(base,incoming): receive and send webhooks [IMP] webhook_(base,incoming): receive and send webhooks Aug 6, 2024
@hoangtrann hoangtrann force-pushed the 16.0_add-webhook-modules branch from 208010b to 5d832a1 Compare August 6, 2024 12:36
@hoangtrann
Copy link
Author

@ivs-cetmix force push to trigger actions seem to solve the issue

Copy link
Member

@ivs-cetmix ivs-cetmix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you once again for your contribution. Some thoughts here:

  • Probably the first module should be named something like webhook_outgoing for better matching the module designation. Same for the module name and description
  • Maybe it would be better to have 2 different PR's per module. You can add dependencies in the second PR using test-requirements.txt. This will make reviews and merging modules faster
  • Test coverage is something that is a must so tests should be added in order to proceed further
  • Same with documentation. However this is something we can also assist with

"license": "LGPL-3",
"website": "https://github.com/OCA/webhook",
"depends": [
"base",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need this dependency because "base_automation" already depends on "base".


state = fields.Selection(
selection_add=[("custom_webhook", "Custom Webhook")],
ondelete={"custom_webhook": "cascade"},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not an issue, just curios: how does this work in selection fields?

"author": "Hoang Tran,Odoo Community Association (OCA)",
"license": "LGPL-3",
"website": "https://github.com/OCA/webhook",
"depends": ["base", "base_automation", "webhook_base", "queue_job"],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"webhook_base" already depends on "base_automation" so no need to add "base" and "base_automation" here

@hoangtrann hoangtrann force-pushed the 16.0_add-webhook-modules branch from 5d832a1 to a03cb3d Compare August 26, 2024 20:26
@hoangtrann hoangtrann changed the title [IMP] webhook_(base,incoming): receive and send webhooks [IMP] webhook_outgoing: send outgoing webhooks Aug 26, 2024
@hoangtrann
Copy link
Author

thanks @ivs-cetmix @rvalyi for your feedback, I've updated the PR to only include the webhook_outgoing for sending out webhook requests.

I've made changes accordingly as well:

  • Merge with ir.actions.server, all fields are brought to this model
  • I'd like to keep webhook.logging for now to log information that we can relate directly to the webhook

I'm going to update the tests as well as creating another PR for incoming webhook

@hoangtrann hoangtrann force-pushed the 16.0_add-webhook-modules branch from a03cb3d to 59c9c13 Compare September 17, 2024 17:51
@agent-z28
Copy link

@hoangtrann lets get it merged ! it's really great.

Copy link

@lmignon lmignon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this addons. Can you add tests plz? Unittest are required to ensure code quality and maintainability.

@hoangtrann hoangtrann force-pushed the 16.0_add-webhook-modules branch from 59c9c13 to 801e35e Compare January 11, 2025 15:00
@hoangtrann hoangtrann force-pushed the 16.0_add-webhook-modules branch from 801e35e to 086853a Compare January 11, 2025 15:44
@hoangtrann
Copy link
Author

@lmignon I've added tests, sorry that it takes a while though

@hoangtrann
Copy link
Author

ping @ivs-cetmix @rvalyi as well for review

@hoangtrann
Copy link
Author

@OCA/tools-maintainers appreciate some reviews here

@rvalyi
Copy link
Member

rvalyi commented Mar 21, 2025

EDIT: hum, this PR is now only for the outgoing webhooks, so there is no such overlap issue here as I initially mentioned below here...

@simahawk @etobella @LoisRForgeFlow @lmignon @pedrobaeza @ivs-cetmix how do you guys see these modules here fit together with https://github.com/OCA/web-api (specially the endpoint and webservice API), seems there is some overlap for a webhook server. This proposal here is however closer to the Odoo native webhook thing that comes at v17+.

Ideally we don't duplicate efforts. But I didn't investigate too much if the webhook server here would still make sense or if convergence/compatibility is somewhat possible...

@ivs-cetmix
Copy link
Member

@simahawk @etobella @LoisRForgeFlow @lmignon @pedrobaeza @ivs-cetmix how do you guys see these modules here fit together with https://github.com/OCA/web-api (specially the endpoint and webservice API), seems there is some overlap for a webhook server. This proposal here is however closer to the Odoo native webhook thing that comes at v17+.

Ideally we don't duplicate efforts. But I didn't investigate too much if the webhook server here would still make sense or if convergence/compatibility is somewhat possible...

I would partially agree with you, as the endpoint module does the job for us as an incoming web hook.
I think it would be more reasonable to put efforts towards improving the existing modules rather than creating a semi-copies of them in different repos.
One of the options could be to build a webhook repo modules as a wraparound over the web-api ones.
@hoangtrann

@rvalyi
Copy link
Member

rvalyi commented Mar 21, 2025

@ivs-cetmix I'm sorry I just found out that the scope of this PR changed and as for now only the webhook_outgoing module is proposed for review. So my previous comment was not pertinent anymore (I added an EDIT line).

@hoangtrann
Copy link
Author

Yup I've separated this PR and made another one for incoming webhooks for ease of review. The major features this bring are render payload using Jinja template and execute using queue job. This allows user to quickly build an integration to send custom Slack notification for example.

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

Successfully merging this pull request may close these issues.

5 participants