{"action":"created","comment":{"url":"https://api.github.com/repos/zulip/zulip/pulls/comments/92600502","pull_request_review_id":13118631,"id":92600502,"diff_hunk":"@@ -0,0 +1,41 @@\n+# Webhooks for external integrations.\n+from __future__ import absolute_import\n+import re\n+\n+from django.http import HttpRequest, HttpResponse\n+from django.utils.translation import ugettext as _\n+\n+from zerver.lib.actions import check_send_message\n+from zerver.lib.response import json_success, json_error\n+from zerver.decorator import REQ, has_request_variables, api_key_only_webhook_view\n+from zerver.models import UserProfile, Client\n+\n+from typing import Text, Dict, Any\n+\n+@api_key_only_webhook_view(\"AppFollow\")\n+@has_request_variables\n+def api_appfollow_webhook(request, user_profile, client, stream=REQ(default=\"appfollow\"),\n+                          payload=REQ(argument_type=\"body\")):\n+    # type: (HttpRequest, UserProfile, Client, Text, Dict[str, Any]) -> HttpResponse\n+    try:\n+        message = payload[\"text\"]\n+    except KeyError:\n+        return json_error(_(\"Missing 'text' argument in JSON\"))\n+    app_name = re.search('\\A(.+)', message).group(0)\n+\n+    check_send_message(user_profile, client, \"stream\", [stream], app_name, convert_markdown(message))\n+    return json_success()\n+\n+def convert_markdown(text):","path":"zerver/views/webhooks/appfollow.py","position":29,"original_position":29,"commit_id":"bf88f10ea3d1e5818504f8e6c780892f0c32ca05","original_commit_id":"9637ff7afedfca23e74e78356df425a47c636c04","user":{"login":"sampritipanda","id":1736001,"avatar_url":"https://avatars.githubusercontent.com/u/1736001?v=3","gravatar_id":"","url":"https://api.github.com/users/sampritipanda","html_url":"https://github.com/sampritipanda","followers_url":"https://api.github.com/users/sampritipanda/followers","following_url":"https://api.github.com/users/sampritipanda/following{/other_user}","gists_url":"https://api.github.com/users/sampritipanda/gists{/gist_id}","starred_url":"https://api.github.com/users/sampritipanda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sampritipanda/subscriptions","organizations_url":"https://api.github.com/users/sampritipanda/orgs","repos_url":"https://api.github.com/users/sampritipanda/repos","events_url":"https://api.github.com/users/sampritipanda/events{/privacy}","received_events_url":"https://api.github.com/users/sampritipanda/received_events","type":"User","site_admin":false},"body":"Yes, that get's converted to `***text***`. I chose not to deal with that because it was highly unlikely for something like that to come from appfollow, and the regexps will much more complicated if I had to add something like: don't allow * after * and similar.","created_at":"2016-12-15T12:34:13Z","updated_at":"2016-12-15T12:34:13Z","html_url":"https://github.com/zulip/zulip/pull/2686#discussion_r92600502","pull_request_url":"https://api.github.com/repos/zulip/zulip/pulls/2686","_links":{"self":{"href":"https://api.github.com/repos/zulip/zulip/pulls/comments/92600502"},"html":{"href":"https://github.com/zulip/zulip/pull/2686#discussion_r92600502"},"pull_request":{"href":"https://api.github.com/repos/zulip/zulip/pulls/2686"}}},"pull_request":{"url":"https://api.github.com/repos/zulip/zulip/pulls/2686","id":97766503,"html_url":"https://github.com/zulip/zulip/pull/2686","diff_url":"https://github.com/zulip/zulip/pull/2686.diff","patch_url":"https://github.com/zulip/zulip/pull/2686.patch","issue_url":"https://api.github.com/repos/zulip/zulip/issues/2686","number":2686,"state":"open","locked":false,"title":"integrations: Add webhook code, API endpoint, tests and documentation for AppFollow","user":{"login":"sampritipanda","id":1736001,"avatar_url":"https://avatars.githubusercontent.com/u/1736001?v=3","gravatar_id":"","url":"https://api.github.com/users/sampritipanda","html_url":"https://github.com/sampritipanda","followers_url":"https://api.github.com/users/sampritipanda/followers","following_url":"https://api.github.com/users/sampritipanda/following{/other_user}","gists_url":"https://api.github.com/users/sampritipanda/gists{/gist_id}","starred_url":"https://api.github.com/users/sampritipanda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sampritipanda/subscriptions","organizations_url":"https://api.github.com/users/sampritipanda/orgs","repos_url":"https://api.github.com/users/sampritipanda/repos","events_url":"https://api.github.com/users/sampritipanda/events{/privacy}","received_events_url":"https://api.github.com/users/sampritipanda/received_events","type":"User","site_admin":false},"body":"* AppFollow unfortunately only allows sending new reviews to a custom webhook URL, the rankings/keyword updates are only for Slack webhooks.\r\n* I had to implement a markdown converter because AppFollow sends us messages which are formatted for Slack, so the bold, italic and strikethrough syntax is different to Zulip's.\r\n\r\nSample Message:\r\n![image](https://cloud.githubusercontent.com/assets/1736001/21145628/f526f854-c174-11e6-88bc-e2551b47b53a.png)\r\n","created_at":"2016-12-13T14:57:00Z","updated_at":"2016-12-15T12:34:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1120d0f00ae10a6389a5880db5663fe75b2fbed2","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/zulip/zulip/pulls/2686/commits","review_comments_url":"https://api.github.com/repos/zulip/zulip/pulls/2686/comments","review_comment_url":"https://api.github.com/repos/zulip/zulip/pulls/comments{/number}","comments_url":"https://api.github.com/repos/zulip/zulip/issues/2686/comments","statuses_url":"https://api.github.com/repos/zulip/zulip/statuses/bf88f10ea3d1e5818504f8e6c780892f0c32ca05","head":{"label":"sampritipanda:appfollow_integration","ref":"appfollow_integration","sha":"bf88f10ea3d1e5818504f8e6c780892f0c32ca05","user":{"login":"sampritipanda","id":1736001,"avatar_url":"https://avatars.githubusercontent.com/u/1736001?v=3","gravatar_id":"","url":"https://api.github.com/users/sampritipanda","html_url":"https://github.com/sampritipanda","followers_url":"https://api.github.com/users/sampritipanda/followers","following_url":"https://api.github.com/users/sampritipanda/following{/other_user}","gists_url":"https://api.github.com/users/sampritipanda/gists{/gist_id}","starred_url":"https://api.github.com/users/sampritipanda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sampritipanda/subscriptions","organizations_url":"https://api.github.com/users/sampritipanda/orgs","repos_url":"https://api.github.com/users/sampritipanda/repos","events_url":"https://api.github.com/users/sampritipanda/events{/privacy}","received_events_url":"https://api.github.com/users/sampritipanda/received_events","type":"User","site_admin":false},"repo":{"id":75212938,"name":"zulip","full_name":"sampritipanda/zulip","owner":{"login":"sampritipanda","id":1736001,"avatar_url":"https://avatars.githubusercontent.com/u/1736001?v=3","gravatar_id":"","url":"https://api.github.com/users/sampritipanda","html_url":"https://github.com/sampritipanda","followers_url":"https://api.github.com/users/sampritipanda/followers","following_url":"https://api.github.com/users/sampritipanda/following{/other_user}","gists_url":"https://api.github.com/users/sampritipanda/gists{/gist_id}","starred_url":"https://api.github.com/users/sampritipanda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sampritipanda/subscriptions","organizations_url":"https://api.github.com/users/sampritipanda/orgs","repos_url":"https://api.github.com/users/sampritipanda/repos","events_url":"https://api.github.com/users/sampritipanda/events{/privacy}","received_events_url":"https://api.github.com/users/sampritipanda/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sampritipanda/zulip","description":"Zulip server - powerful open source group chat","fork":true,"url":"https://api.github.com/repos/sampritipanda/zulip","forks_url":"https://api.github.com/repos/sampritipanda/zulip/forks","keys_url":"https://api.github.com/repos/sampritipanda/zulip/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sampritipanda/zulip/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sampritipanda/zulip/teams","hooks_url":"https://api.github.com/repos/sampritipanda/zulip/hooks","issue_events_url":"https://api.github.com/repos/sampritipanda/zulip/issues/events{/number}","events_url":"https://api.github.com/repos/sampritipanda/zulip/events","assignees_url":"https://api.github.com/repos/sampritipanda/zulip/assignees{/user}","branches_url":"https://api.github.com/repos/sampritipanda/zulip/branches{/branch}","tags_url":"https://api.github.com/repos/sampritipanda/zulip/tags","blobs_url":"https://api.github.com/repos/sampritipanda/zulip/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sampritipanda/zulip/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sampritipanda/zulip/git/refs{/sha}","trees_url":"https://api.github.com/repos/sampritipanda/zulip/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sampritipanda/zulip/statuses/{sha}","languages_url":"https://api.github.com/repos/sampritipanda/zulip/languages","stargazers_url":"https://api.github.com/repos/sampritipanda/zulip/stargazers","contributors_url":"https://api.github.com/repos/sampritipanda/zulip/contributors","subscribers_url":"https://api.github.com/repos/sampritipanda/zulip/subscribers","subscription_url":"https://api.github.com/repos/sampritipanda/zulip/subscription","commits_url":"https://api.github.com/repos/sampritipanda/zulip/commits{/sha}","git_commits_url":"https://api.github.com/repos/sampritipanda/zulip/git/commits{/sha}","comments_url":"https://api.github.com/repos/sampritipanda/zulip/comments{/number}","issue_comment_url":"https://api.github.com/repos/sampritipanda/zulip/issues/comments{/number}","contents_url":"https://api.github.com/repos/sampritipanda/zulip/contents/{+path}","compare_url":"https://api.github.com/repos/sampritipanda/zulip/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sampritipanda/zulip/merges","archive_url":"https://api.github.com/repos/sampritipanda/zulip/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sampritipanda/zulip/downloads","issues_url":"https://api.github.com/repos/sampritipanda/zulip/issues{/number}","pulls_url":"https://api.github.com/repos/sampritipanda/zulip/pulls{/number}","milestones_url":"https://api.github.com/repos/sampritipanda/zulip/milestones{/number}","notifications_url":"https://api.github.com/repos/sampritipanda/zulip/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sampritipanda/zulip/labels{/name}","releases_url":"https://api.github.com/repos/sampritipanda/zulip/releases{/id}","deployments_url":"https://api.github.com/repos/sampritipanda/zulip/deployments","created_at":"2016-11-30T17:59:53Z","updated_at":"2016-11-30T18:00:00Z","pushed_at":"2016-12-15T10:36:22Z","git_url":"git://github.com/sampritipanda/zulip.git","ssh_url":"git@github.com:sampritipanda/zulip.git","clone_url":"https://github.com/sampritipanda/zulip.git","svn_url":"https://github.com/sampritipanda/zulip","homepage":"","size":123960,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"zulip:master","ref":"master","sha":"efccefc38602d275d680f0f0390b975396f148e3","user":{"login":"zulip","id":4921959,"avatar_url":"https://avatars.githubusercontent.com/u/4921959?v=3","gravatar_id":"","url":"https://api.github.com/users/zulip","html_url":"https://github.com/zulip","followers_url":"https://api.github.com/users/zulip/followers","following_url":"https://api.github.com/users/zulip/following{/other_user}","gists_url":"https://api.github.com/users/zulip/gists{/gist_id}","starred_url":"https://api.github.com/users/zulip/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zulip/subscriptions","organizations_url":"https://api.github.com/users/zulip/orgs","repos_url":"https://api.github.com/users/zulip/repos","events_url":"https://api.github.com/users/zulip/events{/privacy}","received_events_url":"https://api.github.com/users/zulip/received_events","type":"Organization","site_admin":false},"repo":{"id":43160685,"name":"zulip","full_name":"zulip/zulip","owner":{"login":"zulip","id":4921959,"avatar_url":"https://avatars.githubusercontent.com/u/4921959?v=3","gravatar_id":"","url":"https://api.github.com/users/zulip","html_url":"https://github.com/zulip","followers_url":"https://api.github.com/users/zulip/followers","following_url":"https://api.github.com/users/zulip/following{/other_user}","gists_url":"https://api.github.com/users/zulip/gists{/gist_id}","starred_url":"https://api.github.com/users/zulip/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zulip/subscriptions","organizations_url":"https://api.github.com/users/zulip/orgs","repos_url":"https://api.github.com/users/zulip/repos","events_url":"https://api.github.com/users/zulip/events{/privacy}","received_events_url":"https://api.github.com/users/zulip/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/zulip/zulip","description":"Zulip server - powerful open source group chat","fork":false,"url":"https://api.github.com/repos/zulip/zulip","forks_url":"https://api.github.com/repos/zulip/zulip/forks","keys_url":"https://api.github.com/repos/zulip/zulip/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zulip/zulip/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zulip/zulip/teams","hooks_url":"https://api.github.com/repos/zulip/zulip/hooks","issue_events_url":"https://api.github.com/repos/zulip/zulip/issues/events{/number}","events_url":"https://api.github.com/repos/zulip/zulip/events","assignees_url":"https://api.github.com/repos/zulip/zulip/assignees{/user}","branches_url":"https://api.github.com/repos/zulip/zulip/branches{/branch}","tags_url":"https://api.github.com/repos/zulip/zulip/tags","blobs_url":"https://api.github.com/repos/zulip/zulip/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zulip/zulip/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zulip/zulip/git/refs{/sha}","trees_url":"https://api.github.com/repos/zulip/zulip/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zulip/zulip/statuses/{sha}","languages_url":"https://api.github.com/repos/zulip/zulip/languages","stargazers_url":"https://api.github.com/repos/zulip/zulip/stargazers","contributors_url":"https://api.github.com/repos/zulip/zulip/contributors","subscribers_url":"https://api.github.com/repos/zulip/zulip/subscribers","subscription_url":"https://api.github.com/repos/zulip/zulip/subscription","commits_url":"https://api.github.com/repos/zulip/zulip/commits{/sha}","git_commits_url":"https://api.github.com/repos/zulip/zulip/git/commits{/sha}","comments_url":"https://api.github.com/repos/zulip/zulip/comments{/number}","issue_comment_url":"https://api.github.com/repos/zulip/zulip/issues/comments{/number}","contents_url":"https://api.github.com/repos/zulip/zulip/contents/{+path}","compare_url":"https://api.github.com/repos/zulip/zulip/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zulip/zulip/merges","archive_url":"https://api.github.com/repos/zulip/zulip/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zulip/zulip/downloads","issues_url":"https://api.github.com/repos/zulip/zulip/issues{/number}","pulls_url":"https://api.github.com/repos/zulip/zulip/pulls{/number}","milestones_url":"https://api.github.com/repos/zulip/zulip/milestones{/number}","notifications_url":"https://api.github.com/repos/zulip/zulip/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zulip/zulip/labels{/name}","releases_url":"https://api.github.com/repos/zulip/zulip/releases{/id}","deployments_url":"https://api.github.com/repos/zulip/zulip/deployments","created_at":"2015-09-25T16:37:25Z","updated_at":"2016-12-15T07:50:28Z","pushed_at":"2016-12-15T12:30:55Z","git_url":"git://github.com/zulip/zulip.git","ssh_url":"git@github.com:zulip/zulip.git","clone_url":"https://github.com/zulip/zulip.git","svn_url":"https://github.com/zulip/zulip","homepage":"","size":124238,"stargazers_count":4335,"watchers_count":4335,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":925,"mirror_url":null,"open_issues_count":612,"forks":925,"open_issues":612,"watchers":4335,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/zulip/zulip/pulls/2686"},"html":{"href":"https://github.com/zulip/zulip/pull/2686"},"issue":{"href":"https://api.github.com/repos/zulip/zulip/issues/2686"},"comments":{"href":"https://api.github.com/repos/zulip/zulip/issues/2686/comments"},"review_comments":{"href":"https://api.github.com/repos/zulip/zulip/pulls/2686/comments"},"review_comment":{"href":"https://api.github.com/repos/zulip/zulip/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/zulip/zulip/pulls/2686/commits"},"statuses":{"href":"https://api.github.com/repos/zulip/zulip/statuses/bf88f10ea3d1e5818504f8e6c780892f0c32ca05"}}}}
{"actor":{"display_login":"sampritipanda"}}