Skip to content

Commit

Permalink
Merge pull request #3933 from rtfd/humitos/integrations/resync
Browse files Browse the repository at this point in the history
Resync webhooks from Admin
  • Loading branch information
humitos authored Apr 10, 2018
2 parents 4dc9e94 + 65ee5da commit 31661ad
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions readthedocs/oauth/services/bitbucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,12 @@ def update_webhook(self, project, integration):
project,
)
return (True, resp)

# Bitbucket returns 404 when the webhook doesn't exist. In this
# case, we call ``setup_webhook`` to re-configure it from scratch
if resp.status_code == 404:
return self.setup_webhook(project)

# Catch exceptions with request or deserializing JSON
except (KeyError, RequestException, ValueError):
log.exception(
Expand Down
6 changes: 6 additions & 0 deletions readthedocs/oauth/services/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,12 @@ def update_webhook(self, project, integration):
project,
)
return (True, resp)

# GitHub returns 404 when the webhook doesn't exist. In this case,
# we call ``setup_webhook`` to re-configure it from scratch
if resp.status_code == 404:
return self.setup_webhook(project)

# Catch exceptions with request or deserializing JSON
except (RequestException, ValueError):
log.exception(
Expand Down
6 changes: 6 additions & 0 deletions readthedocs/oauth/services/gitlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,12 @@ def update_webhook(self, project, integration):
log.info(
'GitLab webhook update successful for project: %s', project)
return (True, resp)

# GitLab returns 404 when the webhook doesn't exist. In this case,
# we call ``setup_webhook`` to re-configure it from scratch
if resp.status_code == 404:
return self.setup_webhook(project)

# Catch exceptions with request or deserializing JSON
except (RequestException, ValueError):
log.exception(
Expand Down

0 comments on commit 31661ad

Please sign in to comment.