mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 13:03:29 +00:00
Add Dropbox webhook integration.
This is just a basic Dropbox webhook integration. It just notifies a user when something has changed, it does not specify what changed. Doing so would require storing data, as Dropbox API was created mainly for file managers, not integrations like this. Closes #5672
This commit is contained in:
BIN
static/images/integrations/dropbox/001.png
Normal file
BIN
static/images/integrations/dropbox/001.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 30 KiB |
BIN
static/images/integrations/dropbox/002.png
Normal file
BIN
static/images/integrations/dropbox/002.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
1
static/images/integrations/logos/dropbox.svg
Normal file
1
static/images/integrations/logos/dropbox.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 235.45 200"><defs><style>.cls-1{fill:#0061ff;}</style></defs><title>DropboxGlyph</title><polygon class="cls-1" points="58.86 0 0 37.5 58.86 75 117.73 37.5 58.86 0"/><polygon class="cls-1" points="176.59 0 117.73 37.5 176.59 75 235.45 37.5 176.59 0"/><polygon class="cls-1" points="0 112.5 58.86 150 117.73 112.5 58.86 75 0 112.5"/><polygon class="cls-1" points="176.59 75 117.73 112.5 176.59 150 235.45 112.5 176.59 75"/><polygon class="cls-1" points="58.86 162.5 117.73 200 176.59 162.5 117.73 125 58.86 162.5"/></svg>
|
||||||
|
After Width: | Height: | Size: 605 B |
@@ -284,6 +284,7 @@ WEBHOOK_INTEGRATIONS = [
|
|||||||
display_name='Desk.com',
|
display_name='Desk.com',
|
||||||
stream_name='desk'
|
stream_name='desk'
|
||||||
),
|
),
|
||||||
|
WebhookIntegration('dropbox', ['productivity'], display_name='Dropbox'),
|
||||||
WebhookIntegration('freshdesk', ['customer-support']),
|
WebhookIntegration('freshdesk', ['customer-support']),
|
||||||
GithubIntegration(
|
GithubIntegration(
|
||||||
'github',
|
'github',
|
||||||
|
|||||||
0
zerver/webhooks/dropbox/__init__.py
Normal file
0
zerver/webhooks/dropbox/__init__.py
Normal file
17
zerver/webhooks/dropbox/doc.md
Normal file
17
zerver/webhooks/dropbox/doc.md
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{!create-stream.md!}
|
||||||
|
|
||||||
|
{!create-bot-construct-url.md!}
|
||||||
|
|
||||||
|
{!append-topic.md!}
|
||||||
|
|
||||||
|
Next, log into your account on [Dropbox](https://www.dropbox.com), go
|
||||||
|
[there](https://www.dropbox.com/developers/apps) and click **Create app**.
|
||||||
|
Follow the steps, and in **Webhooks** section add the webhook address you created above.
|
||||||
|
Click **Add** button. The status of the webhook should say **Enabled**.
|
||||||
|
In **Generated access token** section click **Generate** button.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
{!congrats.md!}
|
||||||
|
|
||||||
|

|
||||||
12
zerver/webhooks/dropbox/fixtures/file_updated.json
Normal file
12
zerver/webhooks/dropbox/fixtures/file_updated.json
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"list_folder": {
|
||||||
|
"accounts": [
|
||||||
|
"dbid:AAH4f99T0taONIb-OurWxbNQ6ywGRopQngc"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"delta": {
|
||||||
|
"users": [
|
||||||
|
12345678
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
28
zerver/webhooks/dropbox/tests.py
Normal file
28
zerver/webhooks/dropbox/tests.py
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from typing import Text
|
||||||
|
|
||||||
|
from zerver.lib.test_classes import WebhookTestCase
|
||||||
|
|
||||||
|
class DropboxHookTests(WebhookTestCase):
|
||||||
|
STREAM_NAME = 'test'
|
||||||
|
URL_TEMPLATE = "/api/v1/external/dropbox?&api_key={api_key}"
|
||||||
|
FIXTURE_DIR_NAME = 'dropbox'
|
||||||
|
|
||||||
|
def test_file_updated(self) -> None:
|
||||||
|
expected_subject = u"Dropbox"
|
||||||
|
expected_message = u"File has been updated on Dropbox!"
|
||||||
|
|
||||||
|
self.send_and_test_stream_message('file_updated', expected_subject, expected_message,
|
||||||
|
content_type="application/x-www-form-urlencoded")
|
||||||
|
|
||||||
|
def get_body(self, fixture_name: Text) -> Text:
|
||||||
|
return self.fixture_data("dropbox", fixture_name, file_type="json")
|
||||||
|
|
||||||
|
def test_verification_request(self) -> None:
|
||||||
|
self.subscribe(self.test_user, self.STREAM_NAME)
|
||||||
|
get_params = {'stream_name': self.STREAM_NAME,
|
||||||
|
'challenge': '9B2SVL4orbt5DxLMqJHI6pOTipTqingt2YFMIO0g06E',
|
||||||
|
'api_key': self.test_user.api_key}
|
||||||
|
result = self.client_get(self.url, get_params)
|
||||||
|
|
||||||
|
self.assert_in_response('9B2SVL4orbt5DxLMqJHI6pOTipTqingt2YFMIO0g06E', result)
|
||||||
18
zerver/webhooks/dropbox/view.py
Normal file
18
zerver/webhooks/dropbox/view.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
from typing import Text
|
||||||
|
from django.http import HttpRequest, HttpResponse
|
||||||
|
from zerver.lib.actions import check_send_stream_message
|
||||||
|
from zerver.lib.response import json_success
|
||||||
|
from zerver.decorator import REQ, has_request_variables, api_key_only_webhook_view
|
||||||
|
from zerver.models import UserProfile
|
||||||
|
|
||||||
|
@api_key_only_webhook_view('Dropbox')
|
||||||
|
@has_request_variables
|
||||||
|
def api_dropbox_webhook(request: HttpRequest, user_profile: UserProfile,
|
||||||
|
stream: Text=REQ(default='test'),
|
||||||
|
topic: Text=REQ(default='Dropbox')) -> HttpResponse:
|
||||||
|
if request.method == 'GET':
|
||||||
|
return HttpResponse(request.GET['challenge'])
|
||||||
|
elif request.method == 'POST':
|
||||||
|
check_send_stream_message(user_profile, request.client,
|
||||||
|
stream, topic, "File has been updated on Dropbox!")
|
||||||
|
return json_success()
|
||||||
Reference in New Issue
Block a user