2017-12-18 01:56:03 +01:00
|
|
|
from django.http import HttpRequest, HttpResponse
|
2020-01-14 22:06:24 +01:00
|
|
|
|
|
|
|
from zerver.decorator import api_key_only_webhook_view, has_request_variables
|
2017-12-18 01:56:03 +01:00
|
|
|
from zerver.lib.response import json_success
|
2018-03-13 23:43:02 +01:00
|
|
|
from zerver.lib.webhooks.common import check_send_webhook_message
|
2017-12-18 01:56:03 +01:00
|
|
|
from zerver.models import UserProfile
|
|
|
|
|
2020-01-14 22:06:24 +01:00
|
|
|
|
2018-11-21 03:45:43 +01:00
|
|
|
@api_key_only_webhook_view('Dropbox', notify_bot_owner_on_invalid_json=False)
|
2017-12-18 01:56:03 +01:00
|
|
|
@has_request_variables
|
2018-11-21 03:45:43 +01:00
|
|
|
def api_dropbox_webhook(request: HttpRequest, user_profile: UserProfile) -> HttpResponse:
|
2019-08-12 05:44:35 +02:00
|
|
|
if request.method == 'POST':
|
2018-03-13 23:43:02 +01:00
|
|
|
topic = 'Dropbox'
|
|
|
|
check_send_webhook_message(request, user_profile, topic,
|
|
|
|
"File has been updated on Dropbox!")
|
2017-12-18 01:56:03 +01:00
|
|
|
return json_success()
|
2019-08-12 05:44:35 +02:00
|
|
|
else:
|
|
|
|
return HttpResponse(request.GET['challenge'])
|