Skip to content

Commit

Permalink
adding webhook and cleaning up html
Browse files Browse the repository at this point in the history
  • Loading branch information
chloeho7 committed Aug 7, 2023
1 parent df8fe8a commit a4ab669
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 19 deletions.
4 changes: 2 additions & 2 deletions src/sentry/integrations/notify_disable.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def notify_disable(
integration_name: str,
redis_key: str,
integration_slug: Union[str, None] = None,
webhook_url: Union[str, None] = None,
project: Union[str, None] = None,
):

Expand All @@ -56,8 +57,7 @@ def notify_disable(
context={
"integration_name": integration_name.title(),
"integration_link": integration_link,
"webhook_url": redis_key,
"dashboard_link": "hold",
"webhook_url": webhook_url if "sentry-app" in redis_key and webhook_url else "",
},
html_template="sentry/integrations/sentry-app-notify-disable.html"
if "sentry-app" in redis_key and integration_slug
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
<p>
Hi there,
</p><p>
We’ve received multiple request errors {{ dashboard_link }} from your webhook: {{ webhook_url }} for the custom {{ integration_name }} integration, and have unsubscribed the webhook from receiving events.
We’ve received multiple <a href={{integration_link}}dashboard/>request errors</a> from your webhook: <a href={{webhook_url}}>{{webhook_url}}</a> for the custom {{ integration_name }} integration, and have unsubscribed the webhook from receiving events.
</p><p>
To continue using your custom integration, please fix your webhook: {{ webhook_url }} and re-enable the webhook subscriptions <a href={{integration_link}}>here</a>.
To continue using your custom integration, please fix your webhook: <a href={{webhook_url}}>{{webhook_url}}</a> and re-enable the webhook subscriptions <a href={{integration_link}}>here</a>.
</p><p>
</p>
<p>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Hi there,

We’ve received multiple <a href={{integration_link}}dashboard/>request errors</a> from your webhook: <a href={{webhook_url}}>{{webhook_url}}</a> for the custom {{ integration_name }} integration,
and have unsubscribed the webhook from receiving events.

To continue using your custom integration, please fix your webhook: <a href={{webhook_url}}>{{webhook_url}}</a> and re-enable the webhook subscriptions <a href={{integration_link}}>here</a>.

If you need additional assistance, you can reach out to our support team at <a href=https://help.sentry.io/>help.sentry.io</a>.

Happy fixing,
Sentry

You are receiving this email because you’re listed as an organization Owner or Manager.
2 changes: 1 addition & 1 deletion src/sentry/utils/sentry_apps/webhooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def check_broken(sentryapp: SentryApp, org_id: str):
org = Organization.objects.get(id=org_id)
if features.has("organizations:disable-sentryapps-on-broken", org):
sentryapp._disable()
notify_disable(org, sentryapp.slug, redis_key)
notify_disable(org, sentryapp.name, redis_key, sentryapp.slug, sentryapp.webhook_url)
buffer.clear()

extra = {
Expand Down
20 changes: 6 additions & 14 deletions src/sentry/web/frontend/debug/debug_notify_disable.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,21 @@
from django.http import HttpRequest, HttpResponse
from django.views.generic import View

from sentry import integrations
from sentry.constants import SentryAppStatus
from sentry.integrations.notify_disable import get_provider_type, get_url
from sentry.models import Integration, Organization, SentryApp
from sentry.models import Organization, SentryApp

from .mail import MailPreview


class DebugNotifyDisableView(View):
def get(self, request: HttpRequest) -> HttpResponse:

self.integration = Integration.objects.create(
provider="slack",
name="Awesome Team",
external_id="TXXXXXXXZ",
metadata={
"access_token": "xoxb-xxxxxxxxx-xxxxxxxxxx-xxxxxxxxxxxx",
"installation_type": "born_as_bot",
},
)
provider = integrations.get(self.integration.provider)

self.organization = Organization(id=1, slug="organization", name="My Company")
self.sentry_app = SentryApp(
name="Test App",
events=["issue.resolved", "issue.ignored", "issue.assigned"],
status=SentryAppStatus.INTERNAL,
webhook_url="https://broken-example.com/webhook",
)

integration_name = self.sentry_app.name
Expand All @@ -36,12 +24,16 @@ def get(self, request: HttpRequest) -> HttpResponse:
get_provider_type(f"sentry-app-error:{self.sentry_app.uuid}"),
self.sentry_app.slug,
)
redis_key = f"sentry-app-error:{self.sentry_app.uuid}"

return MailPreview(
html_template="sentry/integrations/sentry-app-notify-disable.html",
text_template="sentry/integrations/sentry-app-notify-disable.txt",
context={
"integration_name": integration_name,
"integration_link": integration_link,
"webhook_url": self.sentry_app.webhook_url
if "sentry-app" in redis_key and self.sentry_app.webhook_url
else "",
},
).render(request)

0 comments on commit a4ab669

Please sign in to comment.