-
Notifications
You must be signed in to change notification settings - Fork 87
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
Webhooks #2624
base: master
Are you sure you want to change the base?
Conversation
@quaxsze some hell broke loose in the tests because udata/udata/core/user/views.py Line 63 in 9bc0f73
|
How did you pick the signals to plug in ? For example, don't we want to add the signals for resources addition and deletion ( |
|
||
|
||
@Dataset.on_delete.connect | ||
def on_dataset_delete(dataset): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we want to add the if not dataset.private
condition on dataset deletion ?
updates, _ = dataset._delta() | ||
if 'private' in updates and not dataset.private: | ||
dispatch('datagouvfr.dataset.created', dataset.to_json()) | ||
else: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused by the logic on dataset privacy here. If an update is made on a private dataset, we're going to dispatch the updated signal?
assert True | ||
|
||
def test_webhooks_task(self, rmock): | ||
'''NB: apparently celery task errors don't surface so we need to test them directly''' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this NB here, as we don't test task errors in this particular test? Maybe move it somewhere else?
|
||
|
||
@on_new_discussion.connect | ||
def on_new_discussion(discussion): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question on discussion events, don't we want to add the if not dataset.private
condition on dataset deletion ?
A naive approach at dispatching webhooks.
For now, only the dispatch logic is here, we still need to plug it to signals (dataset created...).Plugged-in signals:
Also, some linting changes: enforce single quotes through flake8, lint legacy files as I go through them.
This is designed to work with https://github.com/abulte/chatelet, but it's pretty generic in the end: send a
POST
request to a designated URL.