diff --git a/changelog.md b/changelog.md index 9a48559a19..05cec819c9 100644 --- a/changelog.md +++ b/changelog.md @@ -9,7 +9,7 @@ All notable changes to this project will be documented in this file. - Added documentation on using Hubot to integrate with useful services not yet integrated with Zulip directly (e.g. Google Hangouts). - Added new management command to test sending email from Zulip. -- Added Pingdom integration. +- Added Pingdom and Yo integrations. - Refactored the Zulip puppet modules to be more modular. - Refactored the Tornado event system, fixing old memory leaks. - Implemented running queue processors multithreaded in development, diff --git a/static/images/integrations/logos/yo-app.png b/static/images/integrations/logos/yo-app.png new file mode 100644 index 0000000000..30a12b0691 Binary files /dev/null and b/static/images/integrations/logos/yo-app.png differ diff --git a/static/images/integrations/yo-app/001.png b/static/images/integrations/yo-app/001.png new file mode 100644 index 0000000000..166f67c49b Binary files /dev/null and b/static/images/integrations/yo-app/001.png differ diff --git a/static/images/integrations/yo-app/002.png b/static/images/integrations/yo-app/002.png new file mode 100644 index 0000000000..1fb5d90b01 Binary files /dev/null and b/static/images/integrations/yo-app/002.png differ diff --git a/templates/zerver/integrations.html b/templates/zerver/integrations.html index 6eb2eb75f1..5a269b56f3 100644 --- a/templates/zerver/integrations.html +++ b/templates/zerver/integrations.html @@ -224,6 +224,12 @@ Twitter +
+ Yo App
+
+ See your Yo App notifications in Zulip!
+ +Set up a bot for the integration. You'll need the bot's API key + to construct a URL for Yo App Callback.
+ +You will receive your notifications as a private message between you and the bot.
+ ++ Create URL using your bot's API key and the email address + associated with your Zulip account: + https://zulip.example.com/api/v1/external/yo?email=awesome@zulip.example.com&api_key=abcdefgh ++ +
Copy the url created and go to yoapi.justyo.co
+Sign in using your username and password and go to Edit Profile.
+ +
+
+ Paste the URL in Callback field and click on Update.
+ +Congratulations! You're done!
When someone sends your username a Yo,
+ you'll receive a notification as a private message from the bot
+ like this:
+
+ Multiple users can use the same Yo bot; each user should use + their own Zulip account email in the webhook URL.
+First, create the stream you'd like to use for Zendesk notifications,
and subscribe all interested parties to this stream. We recommend the
diff --git a/zerver/test_hooks.py b/zerver/test_hooks.py
index f19e4de157..8a567ff2dd 100644
--- a/zerver/test_hooks.py
+++ b/zerver/test_hooks.py
@@ -932,3 +932,24 @@ class PingdomHookTests(AuthedTestCase):
def _send_post_request_with_params(self, json):
return self.client.post(self._url, json, stream_name=self.STREAM_NAME, content_type="application/json")
+
+class YoHookTests(AuthedTestCase):
+ def test_yo_message(self):
+ """
+ Yo App sends notification whenever user receives a new Yo from another user.
+ """
+ bot_email = "hamlet@zulip.com"
+ api_key = self.get_api_key(bot_email)
+ body = ""
+
+ email = "cordelia@zulip.com"
+ sender = "IAGO"
+ ip = "127.0.0.1"
+ url = "/api/v1/external/yo?email=%s&api_key=%s&username=%s&user_ip=%s" % (email, api_key, sender, ip)
+
+ self.client.get(url,
+ body,
+ content_type="application/x-www-form-urlencoded")
+
+ msg = Message.objects.filter().order_by('-id')[0]
+ self.assertEqual(msg.content, (u"Yo from IAGO"))
diff --git a/zerver/views/webhooks/yo.py b/zerver/views/webhooks/yo.py
new file mode 100644
index 0000000000..243998d78a
--- /dev/null
+++ b/zerver/views/webhooks/yo.py
@@ -0,0 +1,18 @@
+# Webhooks for external integrations.
+from __future__ import absolute_import
+from zerver.models import get_client
+from zerver.lib.actions import check_send_message
+from zerver.lib.response import json_success
+from zerver.decorator import REQ, has_request_variables, api_key_only_webhook_view
+
+import ujson
+
+@api_key_only_webhook_view
+@has_request_variables
+def api_yo_app_webhook(request, user_profile, email=REQ(default=None),
+ username=REQ(default='Yo Bot'), topic=REQ(default='None'),
+ user_ip=REQ(default='None')):
+
+ body = ('Yo from %s') % (username,)
+ check_send_message(user_profile, get_client('ZulipYoWebhook'), 'private', [email], topic, body)
+ return json_success()
diff --git a/zproject/urls.py b/zproject/urls.py
index f6131ab096..7323ab3dfa 100644
--- a/zproject/urls.py
+++ b/zproject/urls.py
@@ -162,6 +162,7 @@ urlpatterns += patterns('zerver.views',
url(r'^api/v1/external/pagerduty$', 'webhooks.pagerduty.api_pagerduty_webhook'),
url(r'^api/v1/external/travis$', 'webhooks.travis.api_travis_webhook'),
url(r'^api/v1/external/pingdom$', 'webhooks.pingdom.api_pingdom_webhook'),
+ url(r'^api/v1/external/yo$', 'webhooks.yo.api_yo_app_webhook'),
url(r'^user_uploads/(?P