-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Notify users about the usage of deprecated webhooks
Each time a deprecated webhook is hit, a notification is created (without duplicating it) to be sent.
- Loading branch information
Showing
7 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
import logging | ||
|
||
from django.db.models import Q | ||
|
||
from readthedocs.projects.models import Project | ||
from readthedocs.projects.notifications import DeprecatedWebhookEndpointNotification | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
|
||
def notify_deprecated_endpoint(function): | ||
""" | ||
Decorator to notify owners that the endpoint is DEPRECATED. | ||
""" | ||
def wrap(request, *args, project_id_or_slug=None, **kwargs): | ||
try: | ||
project = Project.objects.get( | ||
Q(pk=project_id_or_slug) | Q(slug=project_id_or_slug), | ||
) | ||
except (Project.DoesNotExist, ValueError): | ||
log.info('Project not found: slug=%s', project_id_or_slug) | ||
|
||
# Send one notification to each owner of the project | ||
for user in project.users.all(): | ||
notification = DeprecatedWebhookEndpointNotification( | ||
project, | ||
request, | ||
user, | ||
) | ||
notification.send() | ||
return function(request, *args, project_id_or_slug, **kwargs) | ||
|
||
return wrap |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
readthedocs/templates/projects/notifications/deprecated_webhook_endpoint_email.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<p>Just a heads up, your project {{ project.name }} has configured a <em>DEPRECATED</em> webhook to trigger new builds and should be upgraded. Projects hitting these deprecated webhook will stop building on Jan 1, 2019. Please, update it soon!</p> | ||
|
||
<p>To update the webhook your project is hitting, you need to go to the project's settings under your VCS service (GitHub, Bitbucket or GitLab) and remove the Read the Docs webhook from there.</p> | ||
|
||
<p>Once you have done that, you need to go to your <a href="{% url "projects_integrations" project.slug %}">project's Integrations</a> under Read the Docs project's Admin, click integration and then in "Resync webhook" button.</p> | ||
|
||
<p>Thanks!</p> |
1 change: 1 addition & 0 deletions
1
readthedocs/templates/projects/notifications/deprecated_webhook_endpoint_site.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Your project {{ project.name }} has configured a <em>DEPRECATED</em> webhook to trigger new builds and should be upgraded. Projects hitting these deprecated webhooks will stop building on Jan 1, 2019. <a href="{% url "projects_integrations" project.slug %}">Please, update it soon!</a> |