From 9a60220c3752fe2936c89eac104b9f7ffb24442e Mon Sep 17 00:00:00 2001 From: Tomasz Kolek Date: Sat, 31 Dec 2016 15:57:50 +0100 Subject: [PATCH] Refactor jira integration. Remove events that don't exist. Move handling issue events to separate function. Make formatting strings using format function. Change camelCase variable name convetion to using underscores. Make unknown events error more clear. Add issue_event_type_name param to all fixtures. --- zerver/fixtures/jira/jira_commented.json | 1 + .../fixtures/jira/jira_commented_markup.json | 1 + zerver/fixtures/jira/jira_created.json | 1 + .../fixtures/jira/jira_created_assignee.json | 156 ++++++++- zerver/fixtures/jira/jira_deleted.json | 1 + .../fixtures/jira/jira_postfunction_hook.json | 167 ---------- .../jira/jira_postfunction_resolved.json | 167 ---------- .../jira/jira_postfunction_started.json | 162 ---------- zerver/fixtures/jira/jira_reassigned.json | 1 + zerver/fixtures/jira/jira_reopened.json | 297 ------------------ zerver/fixtures/jira/jira_resolved.json | 223 ------------- zerver/fixtures/jira/jira_unknown.json | 1 + .../fixtures/jira/jira_updated_priority.json | 1 + .../jira/jira_watch_mention_updated.json | 221 ------------- zerver/tests/webhooks/test_jira.py | 61 +--- zerver/views/webhooks/jira.py | 210 ++++++++----- 16 files changed, 287 insertions(+), 1384 deletions(-) delete mode 100644 zerver/fixtures/jira/jira_postfunction_hook.json delete mode 100644 zerver/fixtures/jira/jira_postfunction_resolved.json delete mode 100644 zerver/fixtures/jira/jira_postfunction_started.json delete mode 100644 zerver/fixtures/jira/jira_reopened.json delete mode 100644 zerver/fixtures/jira/jira_resolved.json delete mode 100644 zerver/fixtures/jira/jira_watch_mention_updated.json diff --git a/zerver/fixtures/jira/jira_commented.json b/zerver/fixtures/jira/jira_commented.json index 9e5fa82733..96b8739895 100644 --- a/zerver/fixtures/jira/jira_commented.json +++ b/zerver/fixtures/jira/jira_commented.json @@ -1,5 +1,6 @@ { "webhookEvent": "jira:issue_updated", + "issue_event_type_name":"issue_commented", "timestamp": 1364403934253, "user": { "self": "http://lfranchi.com:8080/rest/api/2/user?username=lfranchi", diff --git a/zerver/fixtures/jira/jira_commented_markup.json b/zerver/fixtures/jira/jira_commented_markup.json index b5bc23950a..74742d6604 100644 --- a/zerver/fixtures/jira/jira_commented_markup.json +++ b/zerver/fixtures/jira/jira_commented_markup.json @@ -1,5 +1,6 @@ { "webhookEvent": "jira:issue_updated", + "issue_event_type_name":"issue_commented", "user": { "self": "https://zulipp.atlassian.net/rest/api/2/user?username=leo", "name": "leo", diff --git a/zerver/fixtures/jira/jira_created.json b/zerver/fixtures/jira/jira_created.json index 9c7e9b1898..d48d6d29d0 100644 --- a/zerver/fixtures/jira/jira_created.json +++ b/zerver/fixtures/jira/jira_created.json @@ -1,5 +1,6 @@ { "webhookEvent": "jira:issue_created", + "issue_event_type_name":"issue_created", "timestamp": 1364403238369, "user": { "self": "http://lfranchi.com:8080/rest/api/2/user?username=lfranchi", diff --git a/zerver/fixtures/jira/jira_created_assignee.json b/zerver/fixtures/jira/jira_created_assignee.json index aafbf23682..3a42911e19 100644 --- a/zerver/fixtures/jira/jira_created_assignee.json +++ b/zerver/fixtures/jira/jira_created_assignee.json @@ -1 +1,155 @@ -{"webhookEvent":"jira:issue_created","user":{"self":"https://zulipp.atlassian.net/rest/api/2/user?username=leo","name":"leo","emailAddress":"leo@zulip.com","avatarUrls":{"16x16":"https://zulipp.atlassian.net/secure/useravatar?size=xsmall&avatarId=10122","24x24":"https://zulipp.atlassian.net/secure/useravatar?size=small&avatarId=10122","32x32":"https://zulipp.atlassian.net/secure/useravatar?size=medium&avatarId=10122","48x48":"https://zulipp.atlassian.net/secure/useravatar?avatarId=10122"},"displayName":"Leonardo Franchi [Administrator]","active":true},"issue":{"id":"10003","self":"https://zulipp.atlassian.net/rest/api/2/issue/10003","key":"TEST-4","fields":{"summary":"Test Created Assignee","progress":{"progress":0,"total":0},"timetracking":{},"issuetype":{"self":"https://zulipp.atlassian.net/rest/api/2/issuetype/2","id":"2","description":"A new feature of the product, which has yet to be developed.","iconUrl":"https://zulipp.atlassian.net/images/icons/issuetypes/newfeature.png","name":"New Feature","subtask":false},"timespent":null,"reporter":{"self":"https://zulipp.atlassian.net/rest/api/2/user?username=leo","name":"leo","emailAddress":"leo@zulip.com","avatarUrls":{"16x16":"https://zulipp.atlassian.net/secure/useravatar?size=xsmall&avatarId=10122","24x24":"https://zulipp.atlassian.net/secure/useravatar?size=small&avatarId=10122","32x32":"https://zulipp.atlassian.net/secure/useravatar?size=medium&avatarId=10122","48x48":"https://zulipp.atlassian.net/secure/useravatar?avatarId=10122"},"displayName":"Leonardo Franchi [Administrator]","active":true},"created":"2013-09-06T11:20:24.101-0400","updated":"2013-09-06T11:20:24.101-0400","priority":{"self":"https://zulipp.atlassian.net/rest/api/2/priority/3","iconUrl":"https://zulipp.atlassian.net/images/icons/priorities/major.png","name":"Major","id":"3"},"description":"This is the description, so descriptive it is","customfield_10001":null,"customfield_10002":null,"customfield_10003":null,"issuelinks":[],"customfield_10000":null,"subtasks":[],"customfield_10008":null,"customfield_10007":null,"status":{"self":"https://zulipp.atlassian.net/rest/api/2/status/10001","description":"","iconUrl":"https://zulipp.atlassian.net/images/icons/statuses/open.png","name":"To Do","id":"10001"},"customfield_10006":"4","labels":[],"workratio":-1,"project":{"self":"https://zulipp.atlassian.net/rest/api/2/project/10000","id":"10000","key":"TEST","name":"TestProject","avatarUrls":{"16x16":"https://zulipp.atlassian.net/secure/projectavatar?size=xsmall&pid=10000&avatarId=10011","24x24":"https://zulipp.atlassian.net/secure/projectavatar?size=small&pid=10000&avatarId=10011","32x32":"https://zulipp.atlassian.net/secure/projectavatar?size=medium&pid=10000&avatarId=10011","48x48":"https://zulipp.atlassian.net/secure/projectavatar?pid=10000&avatarId=10011"}},"environment":null,"customfield_10014":null,"customfield_10015":null,"lastViewed":null,"aggregateprogress":{"progress":0,"total":0},"customfield_10012":null,"components":[],"customfield_10013":null,"comment":{"startAt":0,"maxResults":0,"total":0,"comments":[]},"timeoriginalestimate":null,"customfield_10017":null,"customfield_10016":null,"customfield_10019":null,"customfield_10018":null,"votes":{"self":"https://zulipp.atlassian.net/rest/api/2/issue/TEST-4/votes","votes":0,"hasVoted":false},"fixVersions":[],"resolution":null,"resolutiondate":null,"aggregatetimeoriginalestimate":null,"duedate":null,"customfield_10020":null,"customfield_10021":"Not Started","watches":{"self":"https://zulipp.atlassian.net/rest/api/2/issue/TEST-4/watchers","watchCount":0,"isWatching":false},"worklog":{"startAt":0,"maxResults":20,"total":0,"worklogs":[]},"assignee":{"self":"https://zulipp.atlassian.net/rest/api/2/user?username=leo","name":"leo","emailAddress":"leo@zulip.com","avatarUrls":{"16x16":"https://zulipp.atlassian.net/secure/useravatar?size=xsmall&avatarId=10122","24x24":"https://zulipp.atlassian.net/secure/useravatar?size=small&avatarId=10122","32x32":"https://zulipp.atlassian.net/secure/useravatar?size=medium&avatarId=10122","48x48":"https://zulipp.atlassian.net/secure/useravatar?avatarId=10122"},"displayName":"Leonardo Franchi [Administrator]","active":true},"attachment":[],"aggregatetimeestimate":null,"versions":[],"timeestimate":null,"aggregatetimespent":null}},"timestamp":1378480824183} +{ + "webhookEvent": "jira:issue_created", + "issue_event_type_name":"issue_created", + "user": { + "self": "https://zulipp.atlassian.net/rest/api/2/user?username=leo", + "name": "leo", + "emailAddress": "leo@zulip.com", + "avatarUrls": { + "16x16": "https://zulipp.atlassian.net/secure/useravatar?size=xsmall&avatarId=10122", + "24x24": "https://zulipp.atlassian.net/secure/useravatar?size=small&avatarId=10122", + "32x32": "https://zulipp.atlassian.net/secure/useravatar?size=medium&avatarId=10122", + "48x48": "https://zulipp.atlassian.net/secure/useravatar?avatarId=10122" + }, + "displayName": "Leonardo Franchi [Administrator]", + "active": true + }, + "issue": { + "id": "10003", + "self": "https://zulipp.atlassian.net/rest/api/2/issue/10003", + "key": "TEST-4", + "fields": { + "summary": "Test Created Assignee", + "progress": { + "progress": 0, + "total": 0 + }, + "timetracking": {}, + "issuetype": { + "self": "https://zulipp.atlassian.net/rest/api/2/issuetype/2", + "id": "2", + "description": "A new feature of the product, which has yet to be developed.", + "iconUrl": "https://zulipp.atlassian.net/images/icons/issuetypes/newfeature.png", + "name": "New Feature", + "subtask": false + }, + "timespent": null, + "reporter": { + "self": "https://zulipp.atlassian.net/rest/api/2/user?username=leo", + "name": "leo", + "emailAddress": "leo@zulip.com", + "avatarUrls": { + "16x16": "https://zulipp.atlassian.net/secure/useravatar?size=xsmall&avatarId=10122", + "24x24": "https://zulipp.atlassian.net/secure/useravatar?size=small&avatarId=10122", + "32x32": "https://zulipp.atlassian.net/secure/useravatar?size=medium&avatarId=10122", + "48x48": "https://zulipp.atlassian.net/secure/useravatar?avatarId=10122" + }, + "displayName": "Leonardo Franchi [Administrator]", + "active": true + }, + "created": "2013-09-06T11:20:24.101-0400", + "updated": "2013-09-06T11:20:24.101-0400", + "priority": { + "self": "https://zulipp.atlassian.net/rest/api/2/priority/3", + "iconUrl": "https://zulipp.atlassian.net/images/icons/priorities/major.png", + "name": "Major", + "id": "3" + }, + "description": "This is the description, so descriptive it is", + "customfield_10001": null, + "customfield_10002": null, + "customfield_10003": null, + "issuelinks": [], + "customfield_10000": null, + "subtasks": [], + "customfield_10008": null, + "customfield_10007": null, + "status": { + "self": "https://zulipp.atlassian.net/rest/api/2/status/10001", + "description": "", + "iconUrl": "https://zulipp.atlassian.net/images/icons/statuses/open.png", + "name": "To Do", + "id": "10001" + }, + "customfield_10006": "4", + "labels": [], + "workratio": -1, + "project": { + "self": "https://zulipp.atlassian.net/rest/api/2/project/10000", + "id": "10000", + "key": "TEST", + "name": "TestProject", + "avatarUrls": { + "16x16": "https://zulipp.atlassian.net/secure/projectavatar?size=xsmall&pid=10000&avatarId=10011", + "24x24": "https://zulipp.atlassian.net/secure/projectavatar?size=small&pid=10000&avatarId=10011", + "32x32": "https://zulipp.atlassian.net/secure/projectavatar?size=medium&pid=10000&avatarId=10011", + "48x48": "https://zulipp.atlassian.net/secure/projectavatar?pid=10000&avatarId=10011" + } + }, + "environment": null, + "customfield_10014": null, + "customfield_10015": null, + "lastViewed": null, + "aggregateprogress": { + "progress": 0, + "total": 0 + }, + "customfield_10012": null, + "components": [], + "customfield_10013": null, + "comment": { + "startAt": 0, + "maxResults": 0, + "total": 0, + "comments": [] + }, + "timeoriginalestimate": null, + "customfield_10017": null, + "customfield_10016": null, + "customfield_10019": null, + "customfield_10018": null, + "votes": { + "self": "https://zulipp.atlassian.net/rest/api/2/issue/TEST-4/votes", + "votes": 0, + "hasVoted": false + }, + "fixVersions": [], + "resolution": null, + "resolutiondate": null, + "aggregatetimeoriginalestimate": null, + "duedate": null, + "customfield_10020": null, + "customfield_10021": "Not Started", + "watches": { + "self": "https://zulipp.atlassian.net/rest/api/2/issue/TEST-4/watchers", + "watchCount": 0, + "isWatching": false + }, + "worklog": { + "startAt": 0, + "maxResults": 20, + "total": 0, + "worklogs": [] + }, + "assignee": { + "self": "https://zulipp.atlassian.net/rest/api/2/user?username=leo", + "name": "leo", + "emailAddress": "leo@zulip.com", + "avatarUrls": { + "16x16": "https://zulipp.atlassian.net/secure/useravatar?size=xsmall&avatarId=10122", + "24x24": "https://zulipp.atlassian.net/secure/useravatar?size=small&avatarId=10122", + "32x32": "https://zulipp.atlassian.net/secure/useravatar?size=medium&avatarId=10122", + "48x48": "https://zulipp.atlassian.net/secure/useravatar?avatarId=10122" + }, + "displayName": "Leonardo Franchi [Administrator]", + "active": true + }, + "attachment": [], + "aggregatetimeestimate": null, + "versions": [], + "timeestimate": null, + "aggregatetimespent": null + } + }, + "timestamp": 1378480824183 +} diff --git a/zerver/fixtures/jira/jira_deleted.json b/zerver/fixtures/jira/jira_deleted.json index 42479c64fc..d8292aa49e 100644 --- a/zerver/fixtures/jira/jira_deleted.json +++ b/zerver/fixtures/jira/jira_deleted.json @@ -1,5 +1,6 @@ { "webhookEvent": "jira:issue_deleted", + "issue_event_type_name":"issue_deleted", "timestamp": 1364403969102, "user": { "self": "http://lfranchi.com:8080/rest/api/2/user?username=lfranchi", diff --git a/zerver/fixtures/jira/jira_postfunction_hook.json b/zerver/fixtures/jira/jira_postfunction_hook.json deleted file mode 100644 index be64920954..0000000000 --- a/zerver/fixtures/jira/jira_postfunction_hook.json +++ /dev/null @@ -1,167 +0,0 @@ -{ - "transition": { - "workflowId": 10200, - "workflowName": "TestProj Workflow", - "transitionId": 3, - "transitionName": "Reopen Issue", - "from_status": "Resolved", - "to_status": "Reopened" - }, - "comment": "", - "user": { - "self": "https://lfranchi-test.atlassian.net/rest/api/2/user?username=leo", - "name": "leo", - "emailAddress": "othello@zulip.com", - "avatarUrls": { - "16x16": "https://lfranchi-test.atlassian.net/secure/useravatar?size=xsmall&avatarId=10122", - "24x24": "https://lfranchi-test.atlassian.net/secure/useravatar?size=small&avatarId=10122", - "32x32": "https://lfranchi-test.atlassian.net/secure/useravatar?size=medium&avatarId=10122", - "48x48": "https://lfranchi-test.atlassian.net/secure/useravatar?avatarId=10122" - }, - "displayName": "Leo Franchi [Administrator]", - "active": true - }, - "issue": { - "id": "10200", - "self": "https://lfranchi-test.atlassian.net/rest/api/2/issue/10200", - "key": "TEST-5", - "fields": { - "summary": "PostTest", - "progress": { - "progress": 0, - "total": 0 - }, - "timetracking": {}, - "issuetype": { - "self": "https://lfranchi-test.atlassian.net/rest/api/2/issuetype/1", - "id": "1", - "description": "A problem which impairs or prevents the functions of the product.", - "iconUrl": "https://lfranchi-test.atlassian.net/images/icons/issuetypes/bug.png", - "name": "Bug", - "subtask": false - }, - "timespent": null, - "reporter": { - "self": "https://lfranchi-test.atlassian.net/rest/api/2/user?username=leo", - "name": "leo", - "emailAddress": "othello@zulip.com", - "avatarUrls": { - "16x16": "https://lfranchi-test.atlassian.net/secure/useravatar?size=xsmall&avatarId=10122", - "24x24": "https://lfranchi-test.atlassian.net/secure/useravatar?size=small&avatarId=10122", - "32x32": "https://lfranchi-test.atlassian.net/secure/useravatar?size=medium&avatarId=10122", - "48x48": "https://lfranchi-test.atlassian.net/secure/useravatar?avatarId=10122" - }, - "displayName": "Leo Franchi [Administrator]", - "active": true - }, - "created": "2013-05-23T11:04:49.965-0400", - "updated": "2013-05-23T11:07:13.541-0400", - "priority": { - "self": "https://lfranchi-test.atlassian.net/rest/api/2/priority/3", - "iconUrl": "https://lfranchi-test.atlassian.net/images/icons/priorities/major.png", - "name": "Major", - "id": "3" - }, - "description": null, - "customfield_10001": null, - "customfield_10002": null, - "customfield_10003": null, - "issuelinks": [], - "customfield_10000": "1_*:*_1_*:*_19188_*|*_5_*:*_2_*:*_86333_*|*_4_*:*_2_*:*_9853", - "subtasks": [], - "customfield_10008": null, - "customfield_10007": null, - "status": { - "self": "https://lfranchi-test.atlassian.net/rest/api/2/status/5", - "description": "A resolution has been taken, and it is awaiting verification by reporter. From here issues are either reopened, or are closed.", - "iconUrl": "https://lfranchi-test.atlassian.net/images/icons/statuses/resolved.png", - "name": "Resolved", - "id": "5" - }, - "customfield_10006": "5", - "labels": [], - "workratio": -1, - "project": { - "self": "https://lfranchi-test.atlassian.net/rest/api/2/project/TEST", - "id": "10000", - "key": "TEST", - "name": "TestProj", - "avatarUrls": { - "16x16": "https://lfranchi-test.atlassian.net/secure/projectavatar?size=xsmall&pid=10000&avatarId=10011", - "24x24": "https://lfranchi-test.atlassian.net/secure/projectavatar?size=small&pid=10000&avatarId=10011", - "32x32": "https://lfranchi-test.atlassian.net/secure/projectavatar?size=medium&pid=10000&avatarId=10011", - "48x48": "https://lfranchi-test.atlassian.net/secure/projectavatar?pid=10000&avatarId=10011" - } - }, - "environment": null, - "customfield_10014": null, - "customfield_10015": null, - "lastViewed": "2013-05-23T11:07:38.760-0400", - "aggregateprogress": { - "progress": 0, - "total": 0 - }, - "customfield_10012": null, - "components": [], - "customfield_10013": null, - "comment": { - "startAt": 0, - "maxResults": 0, - "total": 0, - "comments": [] - }, - "timeoriginalestimate": null, - "customfield_10017": null, - "customfield_10016": null, - "customfield_10019": null, - "customfield_10018": null, - "votes": { - "self": "https://lfranchi-test.atlassian.net/rest/api/2/issue/TEST-5/votes", - "votes": 0, - "hasVoted": false - }, - "fixVersions": [], - "resolution": { - "self": "https://lfranchi-test.atlassian.net/rest/api/2/resolution/1", - "id": "1", - "description": "A fix for this issue is checked into the tree and tested.", - "name": "Fixed" - }, - "resolutiondate": "2013-05-23T11:07:13.474-0400", - "aggregatetimeoriginalestimate": null, - "duedate": null, - "customfield_10020": null, - "customfield_10021": "Not Started", - "watches": { - "self": "https://lfranchi-test.atlassian.net/rest/api/2/issue/TEST-5/watchers", - "watchCount": 1, - "isWatching": true - }, - "worklog": { - "startAt": 0, - "maxResults": 0, - "total": 0, - "worklogs": [] - }, - "assignee": { - "self": "https://lfranchi-test.atlassian.net/rest/api/2/user?username=leo", - "name": "leo", - "emailAddress": "othello@zulip.com", - "avatarUrls": { - "16x16": "https://lfranchi-test.atlassian.net/secure/useravatar?size=xsmall&avatarId=10122", - "24x24": "https://lfranchi-test.atlassian.net/secure/useravatar?size=small&avatarId=10122", - "32x32": "https://lfranchi-test.atlassian.net/secure/useravatar?size=medium&avatarId=10122", - "48x48": "https://lfranchi-test.atlassian.net/secure/useravatar?avatarId=10122" - }, - "displayName": "Leo Franchi [Administrator]", - "active": true - }, - "attachment": [], - "aggregatetimeestimate": null, - "versions": [], - "timeestimate": null, - "aggregatetimespent": null - } - }, - "timestamp": 1369321658777 -} diff --git a/zerver/fixtures/jira/jira_postfunction_resolved.json b/zerver/fixtures/jira/jira_postfunction_resolved.json deleted file mode 100644 index e5dfe0c84a..0000000000 --- a/zerver/fixtures/jira/jira_postfunction_resolved.json +++ /dev/null @@ -1,167 +0,0 @@ -{ - "transition": { - "workflowId": 10202, - "workflowName": "TestProj Workflow", - "transitionId": 5, - "transitionName": "Resolve Issue", - "from_status": "Open", - "to_status": "Resolved" - }, - "comment": "", - "user": { - "self": "https://lfranchi-test.atlassian.net/rest/api/2/user?username=leo", - "name": "leo", - "emailAddress": "othello@zulip.com", - "avatarUrls": { - "16x16": "https://lfranchi-test.atlassian.net/secure/useravatar?size=xsmall&avatarId=10122", - "24x24": "https://lfranchi-test.atlassian.net/secure/useravatar?size=small&avatarId=10122", - "32x32": "https://lfranchi-test.atlassian.net/secure/useravatar?size=medium&avatarId=10122", - "48x48": "https://lfranchi-test.atlassian.net/secure/useravatar?avatarId=10122" - }, - "displayName": "Leo Franchi [Administrator]", - "active": true - }, - "issue": { - "id": "10202", - "self": "https://lfranchi-test.atlassian.net/rest/api/2/issue/10202", - "key": "TEST-7", - "fields": { - "summary": "Gluttony of Post Functions", - "progress": { - "progress": 0, - "total": 0 - }, - "timetracking": {}, - "issuetype": { - "self": "https://lfranchi-test.atlassian.net/rest/api/2/issuetype/1", - "id": "1", - "description": "A problem which impairs or prevents the functions of the product.", - "iconUrl": "https://lfranchi-test.atlassian.net/images/icons/issuetypes/bug.png", - "name": "Bug", - "subtask": false - }, - "timespent": null, - "reporter": { - "self": "https://lfranchi-test.atlassian.net/rest/api/2/user?username=leo", - "name": "leo", - "emailAddress": "othello@zulip.com", - "avatarUrls": { - "16x16": "https://lfranchi-test.atlassian.net/secure/useravatar?size=xsmall&avatarId=10122", - "24x24": "https://lfranchi-test.atlassian.net/secure/useravatar?size=small&avatarId=10122", - "32x32": "https://lfranchi-test.atlassian.net/secure/useravatar?size=medium&avatarId=10122", - "48x48": "https://lfranchi-test.atlassian.net/secure/useravatar?avatarId=10122" - }, - "displayName": "Leo Franchi [Administrator]", - "active": true - }, - "created": "2013-05-23T13:43:44.587-0400", - "updated": "2013-05-23T13:45:46.701-0400", - "priority": { - "self": "https://lfranchi-test.atlassian.net/rest/api/2/priority/2", - "iconUrl": "https://lfranchi-test.atlassian.net/images/icons/priorities/critical.png", - "name": "Critical", - "id": "2" - }, - "description": "Never ending", - "customfield_10001": null, - "customfield_10002": null, - "customfield_10003": null, - "issuelinks": [], - "customfield_10000": "3_*:*_1_*:*_54855_*|*_1_*:*_2_*:*_67260", - "subtasks": [], - "customfield_10008": null, - "customfield_10007": null, - "status": { - "self": "https://lfranchi-test.atlassian.net/rest/api/2/status/1", - "description": "The issue is open and ready for the assignee to start work on it.", - "iconUrl": "https://lfranchi-test.atlassian.net/images/icons/statuses/open.png", - "name": "Open", - "id": "1" - }, - "customfield_10006": "7", - "labels": [], - "workratio": -1, - "project": { - "self": "https://lfranchi-test.atlassian.net/rest/api/2/project/TEST", - "id": "10000", - "key": "TEST", - "name": "TestProj", - "avatarUrls": { - "16x16": "https://lfranchi-test.atlassian.net/secure/projectavatar?size=xsmall&pid=10000&avatarId=10011", - "24x24": "https://lfranchi-test.atlassian.net/secure/projectavatar?size=small&pid=10000&avatarId=10011", - "32x32": "https://lfranchi-test.atlassian.net/secure/projectavatar?size=medium&pid=10000&avatarId=10011", - "48x48": "https://lfranchi-test.atlassian.net/secure/projectavatar?pid=10000&avatarId=10011" - } - }, - "environment": null, - "customfield_10014": null, - "customfield_10015": null, - "lastViewed": "2013-05-23T13:45:58.574-0400", - "aggregateprogress": { - "progress": 0, - "total": 0 - }, - "customfield_10012": null, - "components": [], - "customfield_10013": null, - "comment": { - "startAt": 0, - "maxResults": 0, - "total": 0, - "comments": [] - }, - "timeoriginalestimate": null, - "customfield_10017": null, - "customfield_10016": null, - "customfield_10019": null, - "customfield_10018": null, - "votes": { - "self": "https://lfranchi-test.atlassian.net/rest/api/2/issue/TEST-7/votes", - "votes": 0, - "hasVoted": false - }, - "fixVersions": [], - "resolution": { - "self": "https://lfranchi-test.atlassian.net/rest/api/2/resolution/1", - "id": "1", - "description": "A fix for this issue is checked into the tree and tested.", - "name": "Fixed" - }, - "resolutiondate": "2013-05-23T13:45:58.582-0400", - "aggregatetimeoriginalestimate": null, - "duedate": null, - "customfield_10020": null, - "customfield_10021": "Not Started", - "watches": { - "self": "https://lfranchi-test.atlassian.net/rest/api/2/issue/TEST-7/watchers", - "watchCount": 1, - "isWatching": true - }, - "worklog": { - "startAt": 0, - "maxResults": 0, - "total": 0, - "worklogs": [] - }, - "assignee": { - "self": "https://lfranchi-test.atlassian.net/rest/api/2/user?username=leo", - "name": "leo", - "emailAddress": "othello@zulip.com", - "avatarUrls": { - "16x16": "https://lfranchi-test.atlassian.net/secure/useravatar?size=xsmall&avatarId=10122", - "24x24": "https://lfranchi-test.atlassian.net/secure/useravatar?size=small&avatarId=10122", - "32x32": "https://lfranchi-test.atlassian.net/secure/useravatar?size=medium&avatarId=10122", - "48x48": "https://lfranchi-test.atlassian.net/secure/useravatar?avatarId=10122" - }, - "displayName": "Leo Franchi [Administrator]", - "active": true - }, - "attachment": [], - "aggregatetimeestimate": null, - "versions": [], - "timeestimate": null, - "aggregatetimespent": null - } - }, - "timestamp": 1369331158595 -} diff --git a/zerver/fixtures/jira/jira_postfunction_started.json b/zerver/fixtures/jira/jira_postfunction_started.json deleted file mode 100644 index 33b371c89a..0000000000 --- a/zerver/fixtures/jira/jira_postfunction_started.json +++ /dev/null @@ -1,162 +0,0 @@ -{ - "transition": { - "workflowId": 10202, - "workflowName": "TestProj Workflow", - "transitionId": 4, - "transitionName": "Start Progress", - "from_status": "Open", - "to_status": "Underway" - }, - "comment": "", - "user": { - "self": "https://lfranchi-test.atlassian.net/rest/api/2/user?username=leo", - "name": "leo", - "emailAddress": "othello@zulip.com", - "avatarUrls": { - "16x16": "https://lfranchi-test.atlassian.net/secure/useravatar?size=xsmall&avatarId=10122", - "24x24": "https://lfranchi-test.atlassian.net/secure/useravatar?size=small&avatarId=10122", - "32x32": "https://lfranchi-test.atlassian.net/secure/useravatar?size=medium&avatarId=10122", - "48x48": "https://lfranchi-test.atlassian.net/secure/useravatar?avatarId=10122" - }, - "displayName": "Leo Franchi [Administrator]", - "active": true - }, - "issue": { - "id": "10202", - "self": "https://lfranchi-test.atlassian.net/rest/api/2/issue/10202", - "key": "TEST-7", - "fields": { - "summary": "Gluttony of Post Functions", - "progress": { - "progress": 0, - "total": 0 - }, - "timetracking": {}, - "issuetype": { - "self": "https://lfranchi-test.atlassian.net/rest/api/2/issuetype/1", - "id": "1", - "description": "A problem which impairs or prevents the functions of the product.", - "iconUrl": "https://lfranchi-test.atlassian.net/images/icons/issuetypes/bug.png", - "name": "Bug", - "subtask": false - }, - "timespent": null, - "reporter": { - "self": "https://lfranchi-test.atlassian.net/rest/api/2/user?username=leo", - "name": "leo", - "emailAddress": "othello@zulip.com", - "avatarUrls": { - "16x16": "https://lfranchi-test.atlassian.net/secure/useravatar?size=xsmall&avatarId=10122", - "24x24": "https://lfranchi-test.atlassian.net/secure/useravatar?size=small&avatarId=10122", - "32x32": "https://lfranchi-test.atlassian.net/secure/useravatar?size=medium&avatarId=10122", - "48x48": "https://lfranchi-test.atlassian.net/secure/useravatar?avatarId=10122" - }, - "displayName": "Leo Franchi [Administrator]", - "active": true - }, - "created": "2013-05-23T13:43:44.587-0400", - "updated": "2013-05-23T13:43:44.587-0400", - "priority": { - "self": "https://lfranchi-test.atlassian.net/rest/api/2/priority/2", - "iconUrl": "https://lfranchi-test.atlassian.net/images/icons/priorities/critical.png", - "name": "Critical", - "id": "2" - }, - "description": "Never ending", - "customfield_10001": null, - "customfield_10002": null, - "customfield_10003": null, - "issuelinks": [], - "customfield_10000": null, - "subtasks": [], - "customfield_10008": null, - "customfield_10007": null, - "status": { - "self": "https://lfranchi-test.atlassian.net/rest/api/2/status/1", - "description": "The issue is open and ready for the assignee to start work on it.", - "iconUrl": "https://lfranchi-test.atlassian.net/images/icons/statuses/open.png", - "name": "Open", - "id": "1" - }, - "customfield_10006": "7", - "labels": [], - "workratio": -1, - "project": { - "self": "https://lfranchi-test.atlassian.net/rest/api/2/project/TEST", - "id": "10000", - "key": "TEST", - "name": "TestProj", - "avatarUrls": { - "16x16": "https://lfranchi-test.atlassian.net/secure/projectavatar?size=xsmall&pid=10000&avatarId=10011", - "24x24": "https://lfranchi-test.atlassian.net/secure/projectavatar?size=small&pid=10000&avatarId=10011", - "32x32": "https://lfranchi-test.atlassian.net/secure/projectavatar?size=medium&pid=10000&avatarId=10011", - "48x48": "https://lfranchi-test.atlassian.net/secure/projectavatar?pid=10000&avatarId=10011" - } - }, - "environment": null, - "customfield_10014": null, - "customfield_10015": null, - "lastViewed": "2013-05-23T13:44:51.790-0400", - "aggregateprogress": { - "progress": 0, - "total": 0 - }, - "customfield_10012": null, - "components": [], - "customfield_10013": null, - "comment": { - "startAt": 0, - "maxResults": 0, - "total": 0, - "comments": [] - }, - "timeoriginalestimate": null, - "customfield_10017": null, - "customfield_10016": null, - "customfield_10019": null, - "customfield_10018": null, - "votes": { - "self": "https://lfranchi-test.atlassian.net/rest/api/2/issue/TEST-7/votes", - "votes": 0, - "hasVoted": false - }, - "fixVersions": [], - "resolution": null, - "resolutiondate": null, - "aggregatetimeoriginalestimate": null, - "duedate": null, - "customfield_10020": null, - "customfield_10021": "Not Started", - "watches": { - "self": "https://lfranchi-test.atlassian.net/rest/api/2/issue/TEST-7/watchers", - "watchCount": 1, - "isWatching": true - }, - "worklog": { - "startAt": 0, - "maxResults": 0, - "total": 0, - "worklogs": [] - }, - "assignee": { - "self": "https://lfranchi-test.atlassian.net/rest/api/2/user?username=leo", - "name": "leo", - "emailAddress": "othello@zulip.com", - "avatarUrls": { - "16x16": "https://lfranchi-test.atlassian.net/secure/useravatar?size=xsmall&avatarId=10122", - "24x24": "https://lfranchi-test.atlassian.net/secure/useravatar?size=small&avatarId=10122", - "32x32": "https://lfranchi-test.atlassian.net/secure/useravatar?size=medium&avatarId=10122", - "48x48": "https://lfranchi-test.atlassian.net/secure/useravatar?avatarId=10122" - }, - "displayName": "Leo Franchi [Administrator]", - "active": true - }, - "attachment": [], - "aggregatetimeestimate": null, - "versions": [], - "timeestimate": null, - "aggregatetimespent": null - } - }, - "timestamp": 1369331091797 -} diff --git a/zerver/fixtures/jira/jira_reassigned.json b/zerver/fixtures/jira/jira_reassigned.json index cde2352d17..ba1cdff3b3 100644 --- a/zerver/fixtures/jira/jira_reassigned.json +++ b/zerver/fixtures/jira/jira_reassigned.json @@ -1,5 +1,6 @@ { "webhookEvent": "jira:issue_updated", + "issue_event_type_name":"issue_generic", "timestamp": 1364403465325, "user": { "self": "http://lfranchi.com:8080/rest/api/2/user?username=lfranchi", diff --git a/zerver/fixtures/jira/jira_reopened.json b/zerver/fixtures/jira/jira_reopened.json deleted file mode 100644 index 52b9d7cc0a..0000000000 --- a/zerver/fixtures/jira/jira_reopened.json +++ /dev/null @@ -1,297 +0,0 @@ -{ - "webhookEvent": "jira:issue_updated", - "timestamp": 1364418345475, - "user": { - "self": "http://lfranchi.com:8080/rest/api/2/user?username=lfranchi", - "name": "lfranchi", - "emailAddress": "othello@zulip.com", - "avatarUrls": { - "16x16": "http://lfranchi.com:8080/secure/useravatar?size=small&avatarId=10122", - "48x48": "http://lfranchi.com:8080/secure/useravatar?avatarId=10122" - }, - "displayName": "Leo Franchi", - "active": true - }, - "issue": { - "id": "10102", - "self": "http://lfranchi.com:8080/rest/api/2/issue/10102", - "key": "BUG-7", - "fields": { - "summary": "More cowbell polease", - "progress": { - "progress": 0, - "total": 0 - }, - "timetracking": {}, - "issuetype": { - "self": "http://lfranchi.com:8080/rest/api/2/issuetype/1", - "id": "1", - "description": "A problem which impairs or prevents the functions of the product.", - "iconUrl": "http://lfranchi.com:8080/images/icons/bug.gif", - "name": "Bug", - "subtask": false - }, - "votes": { - "self": "http://lfranchi.com:8080/rest/api/2/issue/BUG-7/votes", - "votes": 0, - "hasVoted": false - }, - "resolution": null, - "fixVersions": [], - "resolutiondate": null, - "timespent": null, - "reporter": { - "self": "http://lfranchi.com:8080/rest/api/2/user?username=lfranchi", - "name": "lfranchi", - "emailAddress": "othello@zulip.com", - "avatarUrls": { - "16x16": "http://lfranchi.com:8080/secure/useravatar?size=small&avatarId=10122", - "48x48": "http://lfranchi.com:8080/secure/useravatar?avatarId=10122" - }, - "displayName": "Leo Franchi", - "active": true - }, - "aggregatetimeoriginalestimate": null, - "created": "2013-03-26T14:07:31.484+0000", - "updated": "2013-03-27T21:05:45.473+0000", - "description": "THis is a bug", - "priority": { - "self": "http://lfranchi.com:8080/rest/api/2/priority/1", - "iconUrl": "http://lfranchi.com:8080/images/icons/priority_blocker.gif", - "name": "Blocker", - "id": "1" - }, - "duedate": null, - "issuelinks": [], - "watches": { - "self": "http://lfranchi.com:8080/rest/api/2/issue/BUG-7/watchers", - "watchCount": 1, - "isWatching": true - }, - "worklog": { - "startAt": 0, - "maxResults": 0, - "total": 0, - "worklogs": [] - }, - "customfield_10000": null, - "subtasks": [], - "status": { - "self": "http://lfranchi.com:8080/rest/api/2/status/4", - "description": "This issue was once resolved, but the resolution was deemed incorrect. From here issues are either marked assigned or resolved.", - "iconUrl": "http://lfranchi.com:8080/images/icons/status_reopened.gif", - "name": "Reopened", - "id": "4" - }, - "labels": [], - "workratio": -1, - "assignee": { - "self": "http://lfranchi.com:8080/rest/api/2/user?username=lfranchi", - "name": "lfranchi", - "emailAddress": "othello@zulip.com", - "avatarUrls": { - "16x16": "http://lfranchi.com:8080/secure/useravatar?size=small&avatarId=10122", - "48x48": "http://lfranchi.com:8080/secure/useravatar?avatarId=10122" - }, - "displayName": "Leo Franchi", - "active": true - }, - "attachment": [], - "aggregatetimeestimate": null, - "project": { - "self": "http://lfranchi.com:8080/rest/api/2/project/BUG", - "id": "10000", - "key": "BUG", - "name": "buggery-test", - "avatarUrls": { - "16x16": "http://lfranchi.com:8080/secure/projectavatar?size=small&pid=10000&avatarId=10011", - "48x48": "http://lfranchi.com:8080/secure/projectavatar?pid=10000&avatarId=10011" - } - }, - "versions": [], - "environment": null, - "timeestimate": null, - "aggregateprogress": { - "progress": 0, - "total": 0 - }, - "lastViewed": "2013-03-27T21:05:45.443+0000", - "components": [], - "comment": { - "startAt": 0, - "maxResults": 4, - "total": 4, - "comments": [ - { - "self": "http://lfranchi.com:8080/rest/api/2/issue/10102/comment/10103", - "id": "10103", - "author": { - "self": "http://lfranchi.com:8080/rest/api/2/user?username=lfranchi", - "name": "lfranchi", - "emailAddress": "othello@zulip.com", - "avatarUrls": { - "16x16": "http://lfranchi.com:8080/secure/useravatar?size=small&avatarId=10122", - "48x48": "http://lfranchi.com:8080/secure/useravatar?avatarId=10122" - }, - "displayName": "Leo Franchi", - "active": true - }, - "body": "No more cowbell", - "updateAuthor": { - "self": "http://lfranchi.com:8080/rest/api/2/user?username=lfranchi", - "name": "lfranchi", - "emailAddress": "othello@zulip.com", - "avatarUrls": { - "16x16": "http://lfranchi.com:8080/secure/useravatar?size=small&avatarId=10122", - "48x48": "http://lfranchi.com:8080/secure/useravatar?avatarId=10122" - }, - "displayName": "Leo Franchi", - "active": true - }, - "created": "2013-03-26T14:18:02.614+0000", - "updated": "2013-03-26T14:18:02.614+0000" - }, - { - "self": "http://lfranchi.com:8080/rest/api/2/issue/10102/comment/10403", - "id": "10403", - "author": { - "self": "http://lfranchi.com:8080/rest/api/2/user?username=lfranchi", - "name": "lfranchi", - "emailAddress": "othello@zulip.com", - "avatarUrls": { - "16x16": "http://lfranchi.com:8080/secure/useravatar?size=small&avatarId=10122", - "48x48": "http://lfranchi.com:8080/secure/useravatar?avatarId=10122" - }, - "displayName": "Leo Franchi", - "active": true - }, - "body": "re-opened yeah", - "updateAuthor": { - "self": "http://lfranchi.com:8080/rest/api/2/user?username=lfranchi", - "name": "lfranchi", - "emailAddress": "othello@zulip.com", - "avatarUrls": { - "16x16": "http://lfranchi.com:8080/secure/useravatar?size=small&avatarId=10122", - "48x48": "http://lfranchi.com:8080/secure/useravatar?avatarId=10122" - }, - "displayName": "Leo Franchi", - "active": true - }, - "created": "2013-03-27T21:04:30.416+0000", - "updated": "2013-03-27T21:04:30.416+0000" - }, - { - "self": "http://lfranchi.com:8080/rest/api/2/issue/10102/comment/10404", - "id": "10404", - "author": { - "self": "http://lfranchi.com:8080/rest/api/2/user?username=lfranchi", - "name": "lfranchi", - "emailAddress": "othello@zulip.com", - "avatarUrls": { - "16x16": "http://lfranchi.com:8080/secure/useravatar?size=small&avatarId=10122", - "48x48": "http://lfranchi.com:8080/secure/useravatar?avatarId=10122" - }, - "displayName": "Leo Franchi", - "active": true - }, - "body": "closed yeah!", - "updateAuthor": { - "self": "http://lfranchi.com:8080/rest/api/2/user?username=lfranchi", - "name": "lfranchi", - "emailAddress": "othello@zulip.com", - "avatarUrls": { - "16x16": "http://lfranchi.com:8080/secure/useravatar?size=small&avatarId=10122", - "48x48": "http://lfranchi.com:8080/secure/useravatar?avatarId=10122" - }, - "displayName": "Leo Franchi", - "active": true - }, - "created": "2013-03-27T21:05:16.442+0000", - "updated": "2013-03-27T21:05:16.442+0000" - }, - { - "self": "http://lfranchi.com:8080/rest/api/2/issue/10102/comment/10405", - "id": "10405", - "author": { - "self": "http://lfranchi.com:8080/rest/api/2/user?username=lfranchi", - "name": "lfranchi", - "emailAddress": "othello@zulip.com", - "avatarUrls": { - "16x16": "http://lfranchi.com:8080/secure/useravatar?size=small&avatarId=10122", - "48x48": "http://lfranchi.com:8080/secure/useravatar?avatarId=10122" - }, - "displayName": "Leo Franchi", - "active": true - }, - "body": "Re-opened yeah!", - "updateAuthor": { - "self": "http://lfranchi.com:8080/rest/api/2/user?username=lfranchi", - "name": "lfranchi", - "emailAddress": "othello@zulip.com", - "avatarUrls": { - "16x16": "http://lfranchi.com:8080/secure/useravatar?size=small&avatarId=10122", - "48x48": "http://lfranchi.com:8080/secure/useravatar?avatarId=10122" - }, - "displayName": "Leo Franchi", - "active": true - }, - "created": "2013-03-27T21:05:45.471+0000", - "updated": "2013-03-27T21:05:45.471+0000" - } - ] - }, - "timeoriginalestimate": null, - "aggregatetimespent": null - } - }, - "changelog": { - "id": "10606", - "items": [ - { - "field": "resolution", - "fieldtype": "jira", - "from": "1", - "fromString": "Fixed", - "to": null, - "toString": null - }, - { - "field": "status", - "fieldtype": "jira", - "from": "5", - "fromString": "Resolved", - "to": "4", - "toString": "Reopened" - } - ] - }, - "comment": { - "self": "http://lfranchi.com:8080/rest/api/2/issue/10102/comment/10405", - "id": "10405", - "author": { - "self": "http://lfranchi.com:8080/rest/api/2/user?username=lfranchi", - "name": "lfranchi", - "emailAddress": "othello@zulip.com", - "avatarUrls": { - "16x16": "http://lfranchi.com:8080/secure/useravatar?size=small&avatarId=10122", - "48x48": "http://lfranchi.com:8080/secure/useravatar?avatarId=10122" - }, - "displayName": "Leo Franchi", - "active": true - }, - "body": "Re-opened yeah!", - "updateAuthor": { - "self": "http://lfranchi.com:8080/rest/api/2/user?username=lfranchi", - "name": "lfranchi", - "emailAddress": "othello@zulip.com", - "avatarUrls": { - "16x16": "http://lfranchi.com:8080/secure/useravatar?size=small&avatarId=10122", - "48x48": "http://lfranchi.com:8080/secure/useravatar?avatarId=10122" - }, - "displayName": "Leo Franchi", - "active": true - }, - "created": "2013-03-27T21:05:45.471+0000", - "updated": "2013-03-27T21:05:45.471+0000" - } -} diff --git a/zerver/fixtures/jira/jira_resolved.json b/zerver/fixtures/jira/jira_resolved.json deleted file mode 100644 index 0008106ba8..0000000000 --- a/zerver/fixtures/jira/jira_resolved.json +++ /dev/null @@ -1,223 +0,0 @@ -{ - "webhookEvent": "jira:issue_updated", - "timestamp": 1364404014529, - "user": { - "self": "http://lfranchi.com:8080/rest/api/2/user?username=lfranchi", - "name": "lfranchi", - "emailAddress": "othello@zulip.com", - "avatarUrls": { - "16x16": "http://lfranchi.com:8080/secure/useravatar?size=small&avatarId=10122", - "48x48": "http://lfranchi.com:8080/secure/useravatar?avatarId=10122" - }, - "displayName": "Leo Franchi", - "active": true - }, - "issue": { - "id": "10300", - "self": "http://lfranchi.com:8080/rest/api/2/issue/10300", - "key": "BUG-13", - "fields": { - "summary": "Refreshing the page loses the user's current position, which is not optimal", - "progress": { - "progress": 0, - "total": 0 - }, - "timetracking": {}, - "issuetype": { - "self": "http://lfranchi.com:8080/rest/api/2/issuetype/1", - "id": "1", - "description": "A problem which impairs or prevents the functions of the product.", - "iconUrl": "http://lfranchi.com:8080/images/icons/bug.gif", - "name": "Bug", - "subtask": false - }, - "votes": { - "self": "http://lfranchi.com:8080/rest/api/2/issue/BUG-13/votes", - "votes": 0, - "hasVoted": false - }, - "resolution": { - "self": "http://lfranchi.com:8080/rest/api/2/resolution/1", - "id": "1", - "description": "A fix for this issue is checked into the tree and tested.", - "name": "Fixed" - }, - "fixVersions": [], - "resolutiondate": "2013-03-27T17:06:54.477+0000", - "timespent": null, - "reporter": { - "self": "http://lfranchi.com:8080/rest/api/2/user?username=lfranchi", - "name": "lfranchi", - "emailAddress": "othello@zulip.com", - "avatarUrls": { - "16x16": "http://lfranchi.com:8080/secure/useravatar?size=small&avatarId=10122", - "48x48": "http://lfranchi.com:8080/secure/useravatar?avatarId=10122" - }, - "displayName": "Leo Franchi", - "active": true - }, - "aggregatetimeoriginalestimate": null, - "created": "2013-03-26T17:50:48.858+0000", - "updated": "2013-03-27T17:06:54.515+0000", - "description": "Definitely not optima.", - "priority": { - "self": "http://lfranchi.com:8080/rest/api/2/priority/3", - "iconUrl": "http://lfranchi.com:8080/images/icons/priority_major.gif", - "name": "Major", - "id": "3" - }, - "duedate": null, - "issuelinks": [], - "watches": { - "self": "http://lfranchi.com:8080/rest/api/2/issue/BUG-13/watchers", - "watchCount": 1, - "isWatching": true - }, - "worklog": { - "startAt": 0, - "maxResults": 0, - "total": 0, - "worklogs": [] - }, - "customfield_10000": null, - "subtasks": [], - "status": { - "self": "http://lfranchi.com:8080/rest/api/2/status/5", - "description": "A resolution has been taken, and it is awaiting verification by reporter. From here issues are either reopened, or are closed.", - "iconUrl": "http://lfranchi.com:8080/images/icons/status_resolved.gif", - "name": "Resolved", - "id": "5" - }, - "labels": [], - "workratio": -1, - "assignee": { - "self": "http://lfranchi.com:8080/rest/api/2/user?username=lfranchi", - "name": "lfranchi", - "emailAddress": "othello@zulip.com", - "avatarUrls": { - "16x16": "http://lfranchi.com:8080/secure/useravatar?size=small&avatarId=10122", - "48x48": "http://lfranchi.com:8080/secure/useravatar?avatarId=10122" - }, - "displayName": "Leo Franchi", - "active": true - }, - "attachment": [], - "aggregatetimeestimate": null, - "project": { - "self": "http://lfranchi.com:8080/rest/api/2/project/BUG", - "id": "10000", - "key": "BUG", - "name": "buggery-test", - "avatarUrls": { - "16x16": "http://lfranchi.com:8080/secure/projectavatar?size=small&pid=10000&avatarId=10011", - "48x48": "http://lfranchi.com:8080/secure/projectavatar?pid=10000&avatarId=10011" - } - }, - "versions": [], - "environment": null, - "timeestimate": null, - "aggregateprogress": { - "progress": 0, - "total": 0 - }, - "lastViewed": "2013-03-27T17:06:54.465+0000", - "components": [], - "comment": { - "startAt": 0, - "maxResults": 1, - "total": 1, - "comments": [ - { - "self": "http://lfranchi.com:8080/rest/api/2/issue/10300/comment/10401", - "id": "10401", - "author": { - "self": "http://lfranchi.com:8080/rest/api/2/user?username=lfranchi", - "name": "lfranchi", - "emailAddress": "othello@zulip.com", - "avatarUrls": { - "16x16": "http://lfranchi.com:8080/secure/useravatar?size=small&avatarId=10122", - "48x48": "http://lfranchi.com:8080/secure/useravatar?avatarId=10122" - }, - "displayName": "Leo Franchi", - "active": true - }, - "body": "Fixed it, finally!", - "updateAuthor": { - "self": "http://lfranchi.com:8080/rest/api/2/user?username=lfranchi", - "name": "lfranchi", - "emailAddress": "othello@zulip.com", - "avatarUrls": { - "16x16": "http://lfranchi.com:8080/secure/useravatar?size=small&avatarId=10122", - "48x48": "http://lfranchi.com:8080/secure/useravatar?avatarId=10122" - }, - "displayName": "Leo Franchi", - "active": true - }, - "created": "2013-03-27T17:06:54.513+0000", - "updated": "2013-03-27T17:06:54.513+0000" - } - ] - }, - "timeoriginalestimate": null, - "aggregatetimespent": null - } - }, - "changelog": { - "id": "10601", - "items": [ - { - "field": "status", - "fieldtype": "jira", - "from": "1", - "fromString": "Open", - "to": "5", - "toString": "Resolved" - }, - { - "field": "assignee", - "fieldtype": "jira", - "from": null, - "fromString": null, - "to": "lfranchi", - "toString": "Leo Franchi" - }, - { - "field": "resolution", - "fieldtype": "jira", - "from": null, - "fromString": null, - "to": "1", - "toString": "Fixed" - } - ] - }, - "comment": { - "self": "http://lfranchi.com:8080/rest/api/2/issue/10300/comment/10401", - "id": "10401", - "author": { - "self": "http://lfranchi.com:8080/rest/api/2/user?username=lfranchi", - "name": "lfranchi", - "emailAddress": "othello@zulip.com", - "avatarUrls": { - "16x16": "http://lfranchi.com:8080/secure/useravatar?size=small&avatarId=10122", - "48x48": "http://lfranchi.com:8080/secure/useravatar?avatarId=10122" - }, - "displayName": "Leo Franchi", - "active": true - }, - "body": "Fixed it, finally!", - "updateAuthor": { - "self": "http://lfranchi.com:8080/rest/api/2/user?username=lfranchi", - "name": "lfranchi", - "emailAddress": "othello@zulip.com", - "avatarUrls": { - "16x16": "http://lfranchi.com:8080/secure/useravatar?size=small&avatarId=10122", - "48x48": "http://lfranchi.com:8080/secure/useravatar?avatarId=10122" - }, - "displayName": "Leo Franchi", - "active": true - }, - "created": "2013-03-27T17:06:54.513+0000", - "updated": "2013-03-27T17:06:54.513+0000" - } -} diff --git a/zerver/fixtures/jira/jira_unknown.json b/zerver/fixtures/jira/jira_unknown.json index dc3cd83998..5058689aef 100644 --- a/zerver/fixtures/jira/jira_unknown.json +++ b/zerver/fixtures/jira/jira_unknown.json @@ -1,5 +1,6 @@ { "webhookEvent": "jira:issue_unknown", + "issue_event_type_name":"issue_unknown", "timestamp": 1364403934253, "user": { "self": "http://lfranchi.com:8080/rest/api/2/user?username=lfranchi", diff --git a/zerver/fixtures/jira/jira_updated_priority.json b/zerver/fixtures/jira/jira_updated_priority.json index 8263065d4a..ad4ef644cc 100644 --- a/zerver/fixtures/jira/jira_updated_priority.json +++ b/zerver/fixtures/jira/jira_updated_priority.json @@ -1,5 +1,6 @@ { "webhookEvent": "jira:issue_updated", + "issue_event_type_name":"issue_updated", "user": { "self": "https://zulipp.atlassian.net/rest/api/2/user?username=leo", "name": "leo", diff --git a/zerver/fixtures/jira/jira_watch_mention_updated.json b/zerver/fixtures/jira/jira_watch_mention_updated.json deleted file mode 100644 index eb2330562b..0000000000 --- a/zerver/fixtures/jira/jira_watch_mention_updated.json +++ /dev/null @@ -1,221 +0,0 @@ -{ - "webhookEvent": "jira:issue_updated", - "user": { - "self": "https://zulipp.atlassian.net/rest/api/2/user?username=leo", - "name": "leo", - "emailAddress": "othello@zulip.com", - "avatarUrls": { - "16x16": "https://zulipp.atlassian.net/secure/useravatar?size=xsmall&avatarId=10122", - "24x24": "https://zulipp.atlassian.net/secure/useravatar?size=small&avatarId=10122", - "32x32": "https://zulipp.atlassian.net/secure/useravatar?size=medium&avatarId=10122", - "48x48": "https://zulipp.atlassian.net/secure/useravatar?avatarId=10122" - }, - "displayName": "Leonardo Franchi [Administrator]", - "active": true - }, - "issue": { - "id": "10004", - "self": "https://zulipp.atlassian.net/rest/api/2/issue/10004", - "key": "TEST-5", - "fields": { - "summary": "Lunch Decision Needed", - "progress": { - "progress": 0, - "total": 0 - }, - "timetracking": {}, - "issuetype": { - "self": "https://zulipp.atlassian.net/rest/api/2/issuetype/2", - "id": "2", - "description": "A new feature of the product, which has yet to be developed.", - "iconUrl": "https://zulipp.atlassian.net/images/icons/issuetypes/newfeature.png", - "name": "New Feature", - "subtask": false - }, - "timespent": null, - "reporter": { - "self": "https://zulipp.atlassian.net/rest/api/2/user?username=leo", - "name": "leo", - "emailAddress": "othello@zulip.com", - "avatarUrls": { - "16x16": "https://zulipp.atlassian.net/secure/useravatar?size=xsmall&avatarId=10122", - "24x24": "https://zulipp.atlassian.net/secure/useravatar?size=small&avatarId=10122", - "32x32": "https://zulipp.atlassian.net/secure/useravatar?size=medium&avatarId=10122", - "48x48": "https://zulipp.atlassian.net/secure/useravatar?avatarId=10122" - }, - "displayName": "Leonardo Franchi [Administrator]", - "active": true - }, - "created": "2013-09-06T11:35:52.652-0400", - "updated": "2013-09-06T11:35:52.652-0400", - "priority": { - "self": "https://zulipp.atlassian.net/rest/api/2/priority/3", - "iconUrl": "https://zulipp.atlassian.net/images/icons/priorities/major.png", - "name": "Major", - "id": "3" - }, - "description": "Lets get tasty food", - "customfield_10001": null, - "customfield_10002": null, - "customfield_10003": null, - "issuelinks": [], - "customfield_10000": null, - "subtasks": [], - "customfield_10008": null, - "customfield_10007": null, - "status": { - "self": "https://zulipp.atlassian.net/rest/api/2/status/10001", - "description": "", - "iconUrl": "https://zulipp.atlassian.net/images/icons/statuses/open.png", - "name": "To Do", - "id": "10001" - }, - "customfield_10006": "5", - "labels": [], - "workratio": -1, - "project": { - "self": "https://zulipp.atlassian.net/rest/api/2/project/10000", - "id": "10000", - "key": "TEST", - "name": "TestProject", - "avatarUrls": { - "16x16": "https://zulipp.atlassian.net/secure/projectavatar?size=xsmall&pid=10000&avatarId=10011", - "24x24": "https://zulipp.atlassian.net/secure/projectavatar?size=small&pid=10000&avatarId=10011", - "32x32": "https://zulipp.atlassian.net/secure/projectavatar?size=medium&pid=10000&avatarId=10011", - "48x48": "https://zulipp.atlassian.net/secure/projectavatar?pid=10000&avatarId=10011" - } - }, - "environment": null, - "customfield_10014": null, - "customfield_10015": null, - "lastViewed": "2013-10-07T11:44:49.398-0400", - "aggregateprogress": { - "progress": 0, - "total": 0 - }, - "customfield_10012": null, - "components": [], - "customfield_10013": null, - "comment": { - "startAt": 0, - "maxResults": 1, - "total": 1, - "comments": [ - { - "self": "https://zulipp.atlassian.net/rest/api/2/issue/10004/comment/10008", - "id": "10008", - "author": { - "self": "https://zulipp.atlassian.net/rest/api/2/user?username=leo", - "name": "leo", - "emailAddress": "othello@zulip.com", - "avatarUrls": { - "16x16": "https://zulipp.atlassian.net/secure/useravatar?size=xsmall&avatarId=10122", - "24x24": "https://zulipp.atlassian.net/secure/useravatar?size=small&avatarId=10122", - "32x32": "https://zulipp.atlassian.net/secure/useravatar?size=medium&avatarId=10122", - "48x48": "https://zulipp.atlassian.net/secure/useravatar?avatarId=10122" - }, - "displayName": "Leonardo Franchi [Administrator]", - "active": true - }, - "body": "Making a comment, [~Othello] is watching this issue", - "updateAuthor": { - "self": "https://zulipp.atlassian.net/rest/api/2/user?username=leo", - "name": "leo", - "emailAddress": "othello@zulip.com", - "avatarUrls": { - "16x16": "https://zulipp.atlassian.net/secure/useravatar?size=xsmall&avatarId=10122", - "24x24": "https://zulipp.atlassian.net/secure/useravatar?size=small&avatarId=10122", - "32x32": "https://zulipp.atlassian.net/secure/useravatar?size=medium&avatarId=10122", - "48x48": "https://zulipp.atlassian.net/secure/useravatar?avatarId=10122" - }, - "displayName": "Leonardo Franchi [Administrator]", - "active": true - }, - "created": "2013-10-07T11:45:07.961-0400", - "updated": "2013-10-07T11:45:07.961-0400" - } - ] - }, - "timeoriginalestimate": null, - "customfield_10017": null, - "customfield_10016": null, - "customfield_10019": null, - "customfield_10018": null, - "votes": { - "self": "https://zulipp.atlassian.net/rest/api/2/issue/TEST-5/votes", - "votes": 0, - "hasVoted": false - }, - "fixVersions": [], - "resolution": null, - "resolutiondate": null, - "aggregatetimeoriginalestimate": null, - "duedate": null, - "customfield_10020": null, - "customfield_10021": "Not Started", - "watches": { - "self": "https://zulipp.atlassian.net/rest/api/2/issue/TEST-5/watchers", - "watchCount": 1, - "isWatching": true - }, - "worklog": { - "startAt": 0, - "maxResults": 20, - "total": 0, - "worklogs": [] - }, - "assignee": { - "self": "https://zulipp.atlassian.net/rest/api/2/user?username=leo", - "name": "leo", - "emailAddress": "othello@zulip.com", - "avatarUrls": { - "16x16": "https://zulipp.atlassian.net/secure/useravatar?size=xsmall&avatarId=10122", - "24x24": "https://zulipp.atlassian.net/secure/useravatar?size=small&avatarId=10122", - "32x32": "https://zulipp.atlassian.net/secure/useravatar?size=medium&avatarId=10122", - "48x48": "https://zulipp.atlassian.net/secure/useravatar?avatarId=10122" - }, - "displayName": "Leonardo Franchi [Administrator]", - "active": true - }, - "attachment": [], - "aggregatetimeestimate": null, - "versions": [], - "timeestimate": null, - "aggregatetimespent": null - } - }, - "comment": { - "self": "https://zulipp.atlassian.net/rest/api/2/issue/10004/comment/10008", - "id": "10008", - "author": { - "self": "https://zulipp.atlassian.net/rest/api/2/user?username=leo", - "name": "leo", - "emailAddress": "othello@zulip.com", - "avatarUrls": { - "16x16": "https://zulipp.atlassian.net/secure/useravatar?size=xsmall&avatarId=10122", - "24x24": "https://zulipp.atlassian.net/secure/useravatar?size=small&avatarId=10122", - "32x32": "https://zulipp.atlassian.net/secure/useravatar?size=medium&avatarId=10122", - "48x48": "https://zulipp.atlassian.net/secure/useravatar?avatarId=10122" - }, - "displayName": "Leonardo Franchi [Administrator]", - "active": true - }, - "body": "Making a comment, [~Othello] is watching this issue", - "updateAuthor": { - "self": "https://zulipp.atlassian.net/rest/api/2/user?username=leo", - "name": "leo", - "emailAddress": "othello@zulip.com", - "avatarUrls": { - "16x16": "https://zulipp.atlassian.net/secure/useravatar?size=xsmall&avatarId=10122", - "24x24": "https://zulipp.atlassian.net/secure/useravatar?size=small&avatarId=10122", - "32x32": "https://zulipp.atlassian.net/secure/useravatar?size=medium&avatarId=10122", - "48x48": "https://zulipp.atlassian.net/secure/useravatar?avatarId=10122" - }, - "displayName": "Leonardo Franchi [Administrator]", - "active": true - }, - "created": "2013-10-07T11:45:07.961-0400", - "updated": "2013-10-07T11:45:07.961-0400" - }, - "timestamp": 1381160707966 -} diff --git a/zerver/tests/webhooks/test_jira.py b/zerver/tests/webhooks/test_jira.py index 55520ad7f6..84ec9137ca 100644 --- a/zerver/tests/webhooks/test_jira.py +++ b/zerver/tests/webhooks/test_jira.py @@ -15,7 +15,7 @@ class JiraHookTests(WebhookTestCase): stream_name="jira", content_type="application/json") - self.assert_json_error(result, 'Unknown JIRA event type') + self.assert_json_error(result, "Got JIRA event type we don't support: jira:issue_unknown") def test_custom_stream(self): # type: () -> None @@ -78,65 +78,6 @@ Adding a comment. Oh, what a comment it is! """ self.send_and_test_stream_message('reassigned', expected_subject, expected_message) - def test_reopened(self): - # type: () -> None - expected_subject = "BUG-7: More cowbell polease" - expected_message = """Leo Franchi **updated** [BUG-7](http://lfranchi.com:8080/browse/BUG-7) (assigned to **Othello, the Moor of Venice**): - -* Changed resolution from **Fixed** to **None** -* Changed status from **Resolved** to **Reopened** - -Re-opened yeah! -""" - self.send_and_test_stream_message('reopened', expected_subject, expected_message) - - def test_resolved(self): - # type: () -> None - expected_subject = "BUG-13: Refreshing the page loses the user's current posi..." - expected_message = """Leo Franchi **updated** [BUG-13](http://lfranchi.com:8080/browse/BUG-13) (assigned to **Othello, the Moor of Venice**): - -* Changed status from **Open** to **Resolved** -* Changed assignee from **None** to **Othello, the Moor of Venice** -* Changed resolution from **None** to **Fixed** - -Fixed it, finally! -""" - self.send_and_test_stream_message('resolved', expected_subject, expected_message) - - def test_workflow_postfuncion(self): - # type: () -> None - expected_subject = "TEST-5: PostTest" - expected_message = """Leo Franchi [Administrator] **transitioned** [TEST-5](https://lfranchi-test.atlassian.net/browse/TEST-5) from Resolved to Reopened""" - self.send_and_test_stream_message('postfunction_hook', expected_subject, expected_message) - - def test_workflow_postfunction(self): - # type: () -> None - expected_subject = "TEST-5: PostTest" - expected_message = """Leo Franchi [Administrator] **transitioned** [TEST-5](https://lfranchi-test.atlassian.net/browse/TEST-5) from Resolved to Reopened""" - self.send_and_test_stream_message('postfunction_hook', expected_subject, expected_message) - - def test_workflow_postfunction_started(self): - # type: () -> None - expected_subject = "TEST-7: Gluttony of Post Functions" - expected_message = """Leo Franchi [Administrator] **transitioned** [TEST-7](https://lfranchi-test.atlassian.net/browse/TEST-7) from Open to Underway""" - self.send_and_test_stream_message('postfunction_started', expected_subject, expected_message) - - def test_workflow_postfunction_resolved(self): - # type: () -> None - expected_subject = "TEST-7: Gluttony of Post Functions" - expected_message = """Leo Franchi [Administrator] **transitioned** [TEST-7](https://lfranchi-test.atlassian.net/browse/TEST-7) from Open to Resolved""" - self.send_and_test_stream_message('postfunction_resolved', expected_subject, expected_message) - - def test_mention(self): - # type: () -> None - expected_subject = "TEST-5: Lunch Decision Needed" - expected_message = """Leonardo Franchi [Administrator] **updated** [TEST-5](https://zulipp.atlassian.net/browse/TEST-5) (assigned to **Othello, the Moor of Venice**): - - -Making a comment, **Othello, the Moor of Venice** is watching this issue -""" - self.send_and_test_stream_message('watch_mention_updated', expected_subject, expected_message) - def test_priority_updated(self): # type: () -> None expected_subject = "TEST-1: Fix That" diff --git a/zerver/views/webhooks/jira.py b/zerver/views/webhooks/jira.py index 35b57608db..776f370e04 100644 --- a/zerver/views/webhooks/jira.py +++ b/zerver/views/webhooks/jira.py @@ -1,6 +1,6 @@ # Webhooks for external integrations. from __future__ import absolute_import -from typing import Any, Optional, Text +from typing import Any, Optional, Text, Tuple from django.utils.translation import ugettext as _ from django.db.models import Q @@ -16,7 +16,6 @@ import logging import re import ujson - def guess_zulip_user_from_jira(jira_username, realm): # type: (str, Realm) -> Optional[UserProfile] try: @@ -77,106 +76,145 @@ def convert_jira_markup(content, realm): # Try to look up username user_profile = guess_zulip_user_from_jira(username, realm) if user_profile: - replacement = "**%s**" % (user_profile.full_name,) + replacement = "**{}**".format(user_profile.full_name) else: - replacement = "**%s**" % (username,) + replacement = "**{}**".format(username) - content = content.replace("[~%s]" % (username,), replacement) + content = content.replace("[~{}]".format(username,), replacement) return content +def get_in(payload, keys, default=''): + # type: (Dict[str, Any], List[str], str) -> Any + try: + for key in keys: + payload = payload[key] + except (AttributeError, KeyError, TypeError): + return default + return payload + +def get_issue_string(payload, issue_id=None): + # type: (Dict[str, Any], Text) -> Text + # Guess the URL as it is not specified in the payload + # We assume that there is a /browse/BUG-### page + # from the REST url of the issue itself + if issue_id is None: + issue_id = get_issue_id(payload) + + base_url = re.match("(.*)\/rest\/api/.*", get_in(payload, ['issue', 'self'])) + if base_url and len(base_url.groups()): + return "[{}]({}/browse/{})".format(issue_id, base_url.group(1), issue_id) + else: + return issue_id + +def get_assignee_mention(assignee_email): + # type: (Text) -> Text + if assignee_email != '': + try: + assignee_name = get_user_profile_by_email(assignee_email).full_name + except UserProfile.DoesNotExist: + assignee_name = assignee_email + return "**{}**".format(assignee_name) + return '' + +def get_issue_author(payload): + # type: (Dict[str, Any]) -> Text + return get_in(payload, ['user', 'displayName']) + +def get_issue_id(payload): + # type: (Dict[str, Any]) -> Text + return get_in(payload, ['issue', 'key']) + +def get_issue_title(payload): + # type: (Dict[str, Any]) -> Text + return get_in(payload, ['issue', 'fields', 'summary']) + +def get_issue_subject(payload): + # type: (Dict[str, Any]) -> Text + return "{}: {}".format(get_issue_id(payload), get_issue_title(payload)) + +def handle_updated_issue_event(payload, user_profile): + # Reassigned, commented, reopened, and resolved events are all bundled + # into this one 'updated' event type, so we try to extract the meaningful + # event that happened + # type: (Dict[str, Any], UserProfile) -> Text + issue_id = get_in(payload, ['issue', 'key']) + issue = get_issue_string(payload, issue_id) + + assignee_email = get_in(payload, ['issue', 'fields', 'assignee', 'emailAddress'], '') + assignee_mention = get_assignee_mention(assignee_email) + + if assignee_mention != '': + assignee_blurb = " (assigned to {})".format(assignee_mention) + else: + assignee_blurb = '' + + content = "{} **updated** {}{}:\n\n".format(get_issue_author(payload), issue, assignee_blurb) + changelog = get_in(payload, ['changelog']) + comment = get_in(payload, ['comment', 'body']) + + if changelog != '': + # Use the changelog to display the changes, whitelist types we accept + items = changelog.get('items') + for item in items: + field = item.get('field') + + if field == 'assignee' and assignee_mention != '': + target_field_string = assignee_mention + else: + # Convert a user's target to a @-mention if possible + target_field_string = "**{}**".format(item.get('toString')) + + from_field_string = item.get('fromString') + if target_field_string or from_field_string: + content += "* Changed {} from **{}** to {}\n".format(field, from_field_string, target_field_string) + + if comment != '': + comment = convert_jira_markup(comment, user_profile.realm) + content += "\n{}\n".format(comment) + return content + +def handle_created_issue_event(payload): + # type: (Dict[str, Any]) -> Text + return "{} **created** {} priority {}, assigned to **{}**:\n\n> {}".format( + get_issue_author(payload), + get_issue_string(payload), + get_in(payload, ['issue', 'fields', 'priority', 'name']), + get_in(payload, ['issue', 'fields', 'assignee', 'displayName'], 'no one'), + get_issue_title(payload) + ) + +def handle_deleted_issue_event(payload): + # type: (Dict[str, Any]) -> Text + return "{} **deleted** {}!".format(get_issue_author(payload), get_issue_string(payload)) + @api_key_only_webhook_view("JIRA") @has_request_variables def api_jira_webhook(request, user_profile, client, payload=REQ(argument_type='body'), stream=REQ(default='jira')): # type: (HttpRequest, UserProfile, Client, Dict[str, Any], Text) -> HttpResponse - def get_in(payload, keys, default=''): - # type: (Dict[str, Any], List[str], str) -> Any - try: - for key in keys: - payload = payload[key] - except (AttributeError, KeyError, TypeError): - return default - return payload event = payload.get('webhookEvent') - author = get_in(payload, ['user', 'displayName']) - issueId = get_in(payload, ['issue', 'key']) - # Guess the URL as it is not specified in the payload - # We assume that there is a /browse/BUG-### page - # from the REST url of the issue itself - baseUrl = re.match("(.*)\/rest\/api/.*", get_in(payload, ['issue', 'self'])) - if baseUrl and len(baseUrl.groups()): - issue = "[%s](%s/browse/%s)" % (issueId, baseUrl.group(1), issueId) - else: - issue = issueId - title = get_in(payload, ['issue', 'fields', 'summary']) - priority = get_in(payload, ['issue', 'fields', 'priority', 'name']) - assignee = get_in(payload, ['issue', 'fields', 'assignee', 'displayName'], 'no one') - assignee_email = get_in(payload, ['issue', 'fields', 'assignee', 'emailAddress'], '') - assignee_mention = '' - if assignee_email != '': - try: - assignee_profile = get_user_profile_by_email(assignee_email) - assignee_mention = "**%s**" % (assignee_profile.full_name,) - except UserProfile.DoesNotExist: - assignee_mention = "**%s**" % (assignee_email,) - - subject = "%s: %s" % (issueId, title) - if event == 'jira:issue_created': - content = "%s **created** %s priority %s, assigned to **%s**:\n\n> %s" % \ - (author, issue, priority, assignee, title) + subject = get_issue_subject(payload) + content = handle_created_issue_event(payload) elif event == 'jira:issue_deleted': - content = "%s **deleted** %s!" % \ - (author, issue) + subject = get_issue_subject(payload) + content = handle_deleted_issue_event(payload) elif event == 'jira:issue_updated': - # Reassigned, commented, reopened, and resolved events are all bundled - # into this one 'updated' event type, so we try to extract the meaningful - # event that happened - if assignee_mention != '': - assignee_blurb = " (assigned to %s)" % (assignee_mention,) - else: - assignee_blurb = '' - content = "%s **updated** %s%s:\n\n" % (author, issue, assignee_blurb) - changelog = get_in(payload, ['changelog']) - comment = get_in(payload, ['comment', 'body']) - - if changelog != '': - # Use the changelog to display the changes, whitelist types we accept - items = changelog.get('items') - for item in items: - field = item.get('field') - - # Convert a user's target to a @-mention if possible - targetFieldString = "**%s**" % (item.get('toString'),) - if field == 'assignee' and assignee_mention != '': - targetFieldString = assignee_mention - - fromFieldString = item.get('fromString') - if targetFieldString or fromFieldString: - content += "* Changed %s from **%s** to %s\n" % (field, fromFieldString, targetFieldString) - - if comment != '': - comment = convert_jira_markup(comment, user_profile.realm) - content += "\n%s\n" % (comment,) - elif event in ['jira:worklog_updated']: - # We ignore these event types - return json_success() - elif 'transition' in payload: - from_status = get_in(payload, ['transition', 'from_status']) - to_status = get_in(payload, ['transition', 'to_status']) - content = "%s **transitioned** %s from %s to %s" % (author, issue, from_status, to_status) + subject = get_issue_subject(payload) + content = handle_updated_issue_event(payload, user_profile) else: - # Unknown event type - if not settings.TEST_SUITE: - if event is None: - logging.warning("Got JIRA event with None event type: %s" % (payload,)) - else: - logging.warning("Got JIRA event type we don't understand: %s" % (event,)) - return json_error(_("Unknown JIRA event type")) + if event is None: + if not settings.TEST_SUITE: + message = "Got JIRA event with None event type: {}".format(payload) + logging.warning(message) + return json_error(_("Event is not given by JIRA")) + else: + if not settings.TEST_SUITE: + logging.warning("Got JIRA event type we don't support: {}".format(event)) + return json_error(_("Got JIRA event type we don't support: {}".format(event))) - check_send_message(user_profile, client, "stream", - [stream], subject, content) + check_send_message(user_profile, client, "stream", [stream], subject, content) return json_success()