Skip to content
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

feat(servicehooks): Update servicehook URLs #14093

Merged
merged 1 commit into from
Jul 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 4 additions & 14 deletions src/sentry/tasks/servicehooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,19 @@
from sentry.models import ServiceHook
from sentry.tasks.base import instrumented_task
from sentry.utils import json
from sentry.utils.http import absolute_uri


def get_payload_v0(event):
group = event.group
project = group.project

project_url_base = absolute_uri(u'/{}/{}'.format(
project.organization.slug,
project.slug,
))

group_context = serialize(group)
group_context['url'] = u'{}/issues/{}/'.format(
project_url_base,
group.id,
)
group_context['url'] = group.get_absolute_url()

event_context = serialize(event)
event_context['url'] = u'{}/issues/{}/events/{}/'.format(
project_url_base,
group.id,
event.id,
event_context['url'] = u'{}events/{}/'.format(
group.get_absolute_url(),
event.event_id,
)
data = {
'project': {
Expand Down
15 changes: 15 additions & 0 deletions tests/sentry/tasks/test_servicehooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,18 @@ def test_event_created_sends_service_hook(self, safe_urlopen):
'X-ServiceHook-GUID',
'X-ServiceHook-Signature',
))

def test_v0_payload(self):
event = self.create_event(project=self.project)

process_service_hook(self.hook.id, event)
body = get_payload_v0(event)
assert body['group']['url'] == 'http://testserver/organizations/{}/issues/{}/'.format(
self.organization.slug,
event.group.id,
)
assert body['event']['url'] == 'http://testserver/organizations/{}/issues/{}/events/{}/'.format(
self.organization.slug,
event.group.id,
event.event_id,
)