mirror of https://github.com/zulip/zulip.git
backend: Add request as parameter to json_success.
Adds request as a parameter to json_success as a refactor towards making `ignored_parameters_unsupported` functionality available for all API endpoints. Also, removes any data parameters that are an empty dict or a dict with the generic success response values.
This commit is contained in:
parent
6f7e53c517
commit
3be622ffa7
|
@ -410,7 +410,7 @@ def get_chart_data(
|
||||||
data["display_order"] = labels_sort_function(data)
|
data["display_order"] = labels_sort_function(data)
|
||||||
else:
|
else:
|
||||||
data["display_order"] = None
|
data["display_order"] = None
|
||||||
return json_success(data=data)
|
return json_success(request, data=data)
|
||||||
|
|
||||||
|
|
||||||
def sort_by_totals(value_arrays: Dict[str, List[int]]) -> List[str]:
|
def sort_by_totals(value_arrays: Dict[str, List[int]]) -> List[str]:
|
||||||
|
|
|
@ -198,7 +198,7 @@ def update_plan(
|
||||||
elif status == CustomerPlan.ENDED:
|
elif status == CustomerPlan.ENDED:
|
||||||
assert plan.is_free_trial()
|
assert plan.is_free_trial()
|
||||||
downgrade_now_without_creating_additional_invoices(user.realm)
|
downgrade_now_without_creating_additional_invoices(user.realm)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
if licenses is not None:
|
if licenses is not None:
|
||||||
if plan.automanage_licenses:
|
if plan.automanage_licenses:
|
||||||
|
@ -221,7 +221,7 @@ def update_plan(
|
||||||
)
|
)
|
||||||
validate_licenses(plan.charge_automatically, licenses, get_latest_seat_count(user.realm))
|
validate_licenses(plan.charge_automatically, licenses, get_latest_seat_count(user.realm))
|
||||||
update_license_ledger_for_manual_plan(plan, timezone_now(), licenses=licenses)
|
update_license_ledger_for_manual_plan(plan, timezone_now(), licenses=licenses)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
if licenses_at_next_renewal is not None:
|
if licenses_at_next_renewal is not None:
|
||||||
if plan.automanage_licenses:
|
if plan.automanage_licenses:
|
||||||
|
@ -244,6 +244,6 @@ def update_plan(
|
||||||
update_license_ledger_for_manual_plan(
|
update_license_ledger_for_manual_plan(
|
||||||
plan, timezone_now(), licenses_at_next_renewal=licenses_at_next_renewal
|
plan, timezone_now(), licenses_at_next_renewal=licenses_at_next_renewal
|
||||||
)
|
)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
raise JsonableError(_("Nothing to change."))
|
raise JsonableError(_("Nothing to change."))
|
||||||
|
|
|
@ -35,7 +35,7 @@ def event_status(
|
||||||
|
|
||||||
if session.type == Session.CARD_UPDATE_FROM_BILLING_PAGE and not user.has_billing_access:
|
if session.type == Session.CARD_UPDATE_FROM_BILLING_PAGE and not user.has_billing_access:
|
||||||
raise JsonableError(_("Must be a billing administrator or an organization owner"))
|
raise JsonableError(_("Must be a billing administrator or an organization owner"))
|
||||||
return json_success(data={"session": session.to_dict()})
|
return json_success(request, data={"session": session.to_dict()})
|
||||||
|
|
||||||
if stripe_payment_intent_id is not None:
|
if stripe_payment_intent_id is not None:
|
||||||
payment_intent = PaymentIntent.objects.filter(
|
payment_intent = PaymentIntent.objects.filter(
|
||||||
|
@ -45,7 +45,7 @@ def event_status(
|
||||||
|
|
||||||
if payment_intent is None:
|
if payment_intent is None:
|
||||||
raise JsonableError(_("Payment intent not found"))
|
raise JsonableError(_("Payment intent not found"))
|
||||||
return json_success(data={"payment_intent": payment_intent.to_dict()})
|
return json_success(request, data={"payment_intent": payment_intent.to_dict()})
|
||||||
raise JsonableError(_("Pass stripe_session_id or stripe_payment_intent_id"))
|
raise JsonableError(_("Pass stripe_session_id or stripe_payment_intent_id"))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -37,10 +37,11 @@ def start_card_update_stripe_session(request: HttpRequest, user: UserProfile) ->
|
||||||
type=Session.CARD_UPDATE_FROM_BILLING_PAGE,
|
type=Session.CARD_UPDATE_FROM_BILLING_PAGE,
|
||||||
)
|
)
|
||||||
return json_success(
|
return json_success(
|
||||||
|
request,
|
||||||
data={
|
data={
|
||||||
"stripe_session_url": stripe_session.url,
|
"stripe_session_url": stripe_session.url,
|
||||||
"stripe_session_id": stripe_session.id,
|
"stripe_session_id": stripe_session.id,
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -93,8 +94,9 @@ def start_retry_payment_intent_session(
|
||||||
session.save(update_fields=["payment_intent"])
|
session.save(update_fields=["payment_intent"])
|
||||||
session.save()
|
session.save()
|
||||||
return json_success(
|
return json_success(
|
||||||
|
request,
|
||||||
data={
|
data={
|
||||||
"stripe_session_id": stripe_session.id,
|
"stripe_session_id": stripe_session.id,
|
||||||
"stripe_session_url": stripe_session.url,
|
"stripe_session_url": stripe_session.url,
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
|
|
|
@ -192,10 +192,11 @@ def upgrade(
|
||||||
onboarding,
|
onboarding,
|
||||||
)
|
)
|
||||||
return json_success(
|
return json_success(
|
||||||
|
request,
|
||||||
data={
|
data={
|
||||||
"stripe_session_url": stripe_checkout_session.url,
|
"stripe_session_url": stripe_checkout_session.url,
|
||||||
"stripe_session_id": stripe_checkout_session.id,
|
"stripe_session_id": stripe_checkout_session.id,
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
process_initial_upgrade(
|
process_initial_upgrade(
|
||||||
|
@ -206,7 +207,7 @@ def upgrade(
|
||||||
False,
|
False,
|
||||||
is_free_trial_offer_enabled(),
|
is_free_trial_offer_enabled(),
|
||||||
)
|
)
|
||||||
return json_success(data={})
|
return json_success(request)
|
||||||
|
|
||||||
except BillingError as e:
|
except BillingError as e:
|
||||||
billing_logger.warning(
|
billing_logger.warning(
|
||||||
|
@ -357,7 +358,7 @@ def sponsorship(
|
||||||
context=context,
|
context=context,
|
||||||
)
|
)
|
||||||
|
|
||||||
return json_success()
|
return json_success(request)
|
||||||
else:
|
else:
|
||||||
messages = []
|
messages = []
|
||||||
for error_list in form.errors.get_json_data().values():
|
for error_list in form.errors.get_json_data().values():
|
||||||
|
|
|
@ -1000,7 +1000,7 @@ def return_success_on_head_request(view_func: ViewFuncT) -> ViewFuncT:
|
||||||
@wraps(view_func)
|
@wraps(view_func)
|
||||||
def _wrapped_view_func(request: HttpRequest, *args: object, **kwargs: object) -> HttpResponse:
|
def _wrapped_view_func(request: HttpRequest, *args: object, **kwargs: object) -> HttpResponse:
|
||||||
if request.method == "HEAD":
|
if request.method == "HEAD":
|
||||||
return json_success()
|
return json_success(request)
|
||||||
return view_func(request, *args, **kwargs)
|
return view_func(request, *args, **kwargs)
|
||||||
|
|
||||||
return cast(ViewFuncT, _wrapped_view_func) # https://github.com/python/mypy/issues/1927
|
return cast(ViewFuncT, _wrapped_view_func) # https://github.com/python/mypy/issues/1927
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
from typing import Any, List, Mapping, Optional
|
from typing import Any, List, Mapping, Optional
|
||||||
|
|
||||||
import orjson
|
import orjson
|
||||||
from django.http import HttpResponse, HttpResponseNotAllowed
|
from django.http import HttpRequest, HttpResponse, HttpResponseNotAllowed
|
||||||
from django.utils.translation import gettext as _
|
from django.utils.translation import gettext as _
|
||||||
|
|
||||||
from zerver.lib.exceptions import JsonableError
|
from zerver.lib.exceptions import JsonableError
|
||||||
|
@ -60,7 +60,7 @@ def json_response(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def json_success(data: Mapping[str, Any] = {}) -> HttpResponse:
|
def json_success(request: HttpRequest, data: Mapping[str, Any] = {}) -> HttpResponse:
|
||||||
return json_response(data=data)
|
return json_response(data=data)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -395,11 +395,11 @@ class SkipRateLimitingTest(ZulipTestCase):
|
||||||
def test_authenticated_rest_api_view(self) -> None:
|
def test_authenticated_rest_api_view(self) -> None:
|
||||||
@authenticated_rest_api_view(skip_rate_limiting=False)
|
@authenticated_rest_api_view(skip_rate_limiting=False)
|
||||||
def my_rate_limited_view(request: HttpRequest, user_profile: UserProfile) -> HttpResponse:
|
def my_rate_limited_view(request: HttpRequest, user_profile: UserProfile) -> HttpResponse:
|
||||||
return json_success() # nocoverage # mock prevents this from being called
|
return json_success(request) # nocoverage # mock prevents this from being called
|
||||||
|
|
||||||
@authenticated_rest_api_view(skip_rate_limiting=True)
|
@authenticated_rest_api_view(skip_rate_limiting=True)
|
||||||
def my_unlimited_view(request: HttpRequest, user_profile: UserProfile) -> HttpResponse:
|
def my_unlimited_view(request: HttpRequest, user_profile: UserProfile) -> HttpResponse:
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
request = HostRequestMock(host="zulip.testserver")
|
request = HostRequestMock(host="zulip.testserver")
|
||||||
request.META["HTTP_AUTHORIZATION"] = self.encode_email(self.example_email("hamlet"))
|
request.META["HTTP_AUTHORIZATION"] = self.encode_email(self.example_email("hamlet"))
|
||||||
|
@ -418,11 +418,11 @@ class SkipRateLimitingTest(ZulipTestCase):
|
||||||
def test_authenticated_uploads_api_view(self) -> None:
|
def test_authenticated_uploads_api_view(self) -> None:
|
||||||
@authenticated_uploads_api_view(skip_rate_limiting=False)
|
@authenticated_uploads_api_view(skip_rate_limiting=False)
|
||||||
def my_rate_limited_view(request: HttpRequest, user_profile: UserProfile) -> HttpResponse:
|
def my_rate_limited_view(request: HttpRequest, user_profile: UserProfile) -> HttpResponse:
|
||||||
return json_success() # nocoverage # mock prevents this from being called
|
return json_success(request) # nocoverage # mock prevents this from being called
|
||||||
|
|
||||||
@authenticated_uploads_api_view(skip_rate_limiting=True)
|
@authenticated_uploads_api_view(skip_rate_limiting=True)
|
||||||
def my_unlimited_view(request: HttpRequest, user_profile: UserProfile) -> HttpResponse:
|
def my_unlimited_view(request: HttpRequest, user_profile: UserProfile) -> HttpResponse:
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
request = HostRequestMock(host="zulip.testserver")
|
request = HostRequestMock(host="zulip.testserver")
|
||||||
request.method = "POST"
|
request.method = "POST"
|
||||||
|
@ -440,7 +440,7 @@ class SkipRateLimitingTest(ZulipTestCase):
|
||||||
|
|
||||||
def test_authenticated_json_view(self) -> None:
|
def test_authenticated_json_view(self) -> None:
|
||||||
def my_view(request: HttpRequest, user_profile: UserProfile) -> HttpResponse:
|
def my_view(request: HttpRequest, user_profile: UserProfile) -> HttpResponse:
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
my_rate_limited_view = authenticated_json_view(my_view, skip_rate_limiting=False)
|
my_rate_limited_view = authenticated_json_view(my_view, skip_rate_limiting=False)
|
||||||
my_unlimited_view = authenticated_json_view(my_view, skip_rate_limiting=True)
|
my_unlimited_view = authenticated_json_view(my_view, skip_rate_limiting=True)
|
||||||
|
|
|
@ -3516,7 +3516,7 @@ class SubscriptionRestApiTest(ZulipTestCase):
|
||||||
def thunk1() -> HttpResponse:
|
def thunk1() -> HttpResponse:
|
||||||
user_profile.full_name = "Should not be committed"
|
user_profile.full_name = "Should not be committed"
|
||||||
user_profile.save()
|
user_profile.save()
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
def thunk2() -> HttpResponse:
|
def thunk2() -> HttpResponse:
|
||||||
raise JsonableError("random failure")
|
raise JsonableError("random failure")
|
||||||
|
|
|
@ -24,7 +24,7 @@ from zerver.tornado.exceptions import BadEventQueueIdError
|
||||||
@internal_notify_view(True)
|
@internal_notify_view(True)
|
||||||
def notify(request: HttpRequest) -> HttpResponse:
|
def notify(request: HttpRequest) -> HttpResponse:
|
||||||
process_notification(orjson.loads(request.POST["data"]))
|
process_notification(orjson.loads(request.POST["data"]))
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
@has_request_variables
|
@has_request_variables
|
||||||
|
@ -40,7 +40,7 @@ def cleanup_event_queue(
|
||||||
assert log_data is not None
|
assert log_data is not None
|
||||||
log_data["extra"] = f"[{queue_id}]"
|
log_data["extra"] = f"[{queue_id}]"
|
||||||
client.cleanup()
|
client.cleanup()
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
@internal_notify_view(True)
|
@internal_notify_view(True)
|
||||||
|
@ -164,9 +164,9 @@ def get_events_backend(
|
||||||
# Tornado discarding the response and instead long-polling the
|
# Tornado discarding the response and instead long-polling the
|
||||||
# request. See zulip_finish for more design details.
|
# request. See zulip_finish for more design details.
|
||||||
handler._request = request
|
handler._request = request
|
||||||
response = json_success()
|
response = json_success(request)
|
||||||
response.asynchronous = True
|
response.asynchronous = True
|
||||||
return response
|
return response
|
||||||
if result["type"] == "error":
|
if result["type"] == "error":
|
||||||
raise result["exception"]
|
raise result["exception"]
|
||||||
return json_success(result["response"])
|
return json_success(request, data=result["response"])
|
||||||
|
|
|
@ -11,7 +11,7 @@ from zerver.models import UserProfile
|
||||||
|
|
||||||
|
|
||||||
def list_alert_words(request: HttpRequest, user_profile: UserProfile) -> HttpResponse:
|
def list_alert_words(request: HttpRequest, user_profile: UserProfile) -> HttpResponse:
|
||||||
return json_success({"alert_words": user_alert_words(user_profile)})
|
return json_success(request, data={"alert_words": user_alert_words(user_profile)})
|
||||||
|
|
||||||
|
|
||||||
def clean_alert_words(alert_words: List[str]) -> List[str]:
|
def clean_alert_words(alert_words: List[str]) -> List[str]:
|
||||||
|
@ -26,7 +26,7 @@ def add_alert_words(
|
||||||
alert_words: List[str] = REQ(json_validator=check_list(check_capped_string(100))),
|
alert_words: List[str] = REQ(json_validator=check_list(check_capped_string(100))),
|
||||||
) -> HttpResponse:
|
) -> HttpResponse:
|
||||||
do_add_alert_words(user_profile, clean_alert_words(alert_words))
|
do_add_alert_words(user_profile, clean_alert_words(alert_words))
|
||||||
return json_success({"alert_words": user_alert_words(user_profile)})
|
return json_success(request, data={"alert_words": user_alert_words(user_profile)})
|
||||||
|
|
||||||
|
|
||||||
@has_request_variables
|
@has_request_variables
|
||||||
|
@ -36,4 +36,4 @@ def remove_alert_words(
|
||||||
alert_words: List[str] = REQ(json_validator=check_list(check_string)),
|
alert_words: List[str] = REQ(json_validator=check_list(check_string)),
|
||||||
) -> HttpResponse:
|
) -> HttpResponse:
|
||||||
do_remove_alert_words(user_profile, alert_words)
|
do_remove_alert_words(user_profile, alert_words)
|
||||||
return json_success({"alert_words": user_alert_words(user_profile)})
|
return json_success(request, data={"alert_words": user_alert_words(user_profile)})
|
||||||
|
|
|
@ -8,10 +8,11 @@ from zerver.models import UserProfile
|
||||||
|
|
||||||
def list_by_user(request: HttpRequest, user_profile: UserProfile) -> HttpResponse:
|
def list_by_user(request: HttpRequest, user_profile: UserProfile) -> HttpResponse:
|
||||||
return json_success(
|
return json_success(
|
||||||
{
|
request,
|
||||||
|
data={
|
||||||
"attachments": user_attachments(user_profile),
|
"attachments": user_attachments(user_profile),
|
||||||
"upload_space_used": user_profile.realm.currently_used_upload_space_bytes(),
|
"upload_space_used": user_profile.realm.currently_used_upload_space_bytes(),
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,4 +20,4 @@ def remove(request: HttpRequest, user_profile: UserProfile, attachment_id: str)
|
||||||
attachment = access_attachment_by_id(user_profile, int(attachment_id), needs_owner=True)
|
attachment = access_attachment_by_id(user_profile, int(attachment_id), needs_owner=True)
|
||||||
remove_attachment(user_profile, attachment)
|
remove_attachment(user_profile, attachment)
|
||||||
notify_attachment_update(user_profile, "remove", {"id": int(attachment_id)})
|
notify_attachment_update(user_profile, "remove", {"id": int(attachment_id)})
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
|
@ -898,7 +898,7 @@ def api_fetch_api_key(
|
||||||
RequestNotes.get_notes(request).requestor_for_logs = user_profile.format_requestor_for_logs()
|
RequestNotes.get_notes(request).requestor_for_logs = user_profile.format_requestor_for_logs()
|
||||||
|
|
||||||
api_key = get_api_key(user_profile)
|
api_key = get_api_key(user_profile)
|
||||||
return json_success({"api_key": api_key, "email": user_profile.delivery_email})
|
return json_success(request, data={"api_key": api_key, "email": user_profile.delivery_email})
|
||||||
|
|
||||||
|
|
||||||
def get_auth_backends_data(request: HttpRequest) -> Dict[str, Any]:
|
def get_auth_backends_data(request: HttpRequest) -> Dict[str, Any]:
|
||||||
|
@ -963,7 +963,7 @@ def api_get_server_settings(request: HttpRequest) -> HttpResponse:
|
||||||
]:
|
]:
|
||||||
if context[settings_item] is not None:
|
if context[settings_item] is not None:
|
||||||
result[settings_item] = context[settings_item]
|
result[settings_item] = context[settings_item]
|
||||||
return json_success(result)
|
return json_success(request, data=result)
|
||||||
|
|
||||||
|
|
||||||
@has_request_variables
|
@has_request_variables
|
||||||
|
@ -980,7 +980,7 @@ def json_fetch_api_key(
|
||||||
raise JsonableError(_("Password is incorrect."))
|
raise JsonableError(_("Password is incorrect."))
|
||||||
|
|
||||||
api_key = get_api_key(user_profile)
|
api_key = get_api_key(user_profile)
|
||||||
return json_success({"api_key": api_key, "email": user_profile.delivery_email})
|
return json_success(request, data={"api_key": api_key, "email": user_profile.delivery_email})
|
||||||
|
|
||||||
|
|
||||||
@require_post
|
@require_post
|
||||||
|
|
|
@ -27,4 +27,4 @@ def check_global_compatibility(request: HttpRequest) -> HttpResponse:
|
||||||
user_os = find_mobile_os(request.META["HTTP_USER_AGENT"])
|
user_os = find_mobile_os(request.META["HTTP_USER_AGENT"])
|
||||||
if user_os == "android" and version_lt(user_agent["version"], android_min_app_version):
|
if user_os == "android" and version_lt(user_agent["version"], android_min_app_version):
|
||||||
raise JsonableError(legacy_compatibility_error_message)
|
raise JsonableError(legacy_compatibility_error_message)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
|
@ -38,7 +38,7 @@ def list_realm_custom_profile_fields(
|
||||||
request: HttpRequest, user_profile: UserProfile
|
request: HttpRequest, user_profile: UserProfile
|
||||||
) -> HttpResponse:
|
) -> HttpResponse:
|
||||||
fields = custom_profile_fields_for_realm(user_profile.realm_id)
|
fields = custom_profile_fields_for_realm(user_profile.realm_id)
|
||||||
return json_success({"custom_fields": [f.as_dict() for f in fields]})
|
return json_success(request, data={"custom_fields": [f.as_dict() for f in fields]})
|
||||||
|
|
||||||
|
|
||||||
hint_validator = check_capped_string(CustomProfileField.HINT_MAX_LENGTH)
|
hint_validator = check_capped_string(CustomProfileField.HINT_MAX_LENGTH)
|
||||||
|
@ -113,7 +113,7 @@ def create_realm_custom_profile_field(
|
||||||
realm=user_profile.realm,
|
realm=user_profile.realm,
|
||||||
field_subtype=field_subtype,
|
field_subtype=field_subtype,
|
||||||
)
|
)
|
||||||
return json_success({"id": field.id})
|
return json_success(request, data={"id": field.id})
|
||||||
else:
|
else:
|
||||||
field = try_add_realm_custom_profile_field(
|
field = try_add_realm_custom_profile_field(
|
||||||
realm=user_profile.realm,
|
realm=user_profile.realm,
|
||||||
|
@ -122,7 +122,7 @@ def create_realm_custom_profile_field(
|
||||||
field_type=field_type,
|
field_type=field_type,
|
||||||
hint=hint,
|
hint=hint,
|
||||||
)
|
)
|
||||||
return json_success({"id": field.id})
|
return json_success(request, data={"id": field.id})
|
||||||
except IntegrityError:
|
except IntegrityError:
|
||||||
raise JsonableError(_("A field with that label already exists."))
|
raise JsonableError(_("A field with that label already exists."))
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ def delete_realm_custom_profile_field(
|
||||||
raise JsonableError(_("Field id {id} not found.").format(id=field_id))
|
raise JsonableError(_("Field id {id} not found.").format(id=field_id))
|
||||||
|
|
||||||
do_remove_realm_custom_profile_field(realm=user_profile.realm, field=field)
|
do_remove_realm_custom_profile_field(realm=user_profile.realm, field=field)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
@require_realm_admin
|
@require_realm_admin
|
||||||
|
@ -165,7 +165,7 @@ def update_realm_custom_profile_field(
|
||||||
try_update_realm_custom_profile_field(realm, field, name, hint=hint, field_data=field_data)
|
try_update_realm_custom_profile_field(realm, field, name, hint=hint, field_data=field_data)
|
||||||
except IntegrityError:
|
except IntegrityError:
|
||||||
raise JsonableError(_("A field with that label already exists."))
|
raise JsonableError(_("A field with that label already exists."))
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
@require_realm_admin
|
@require_realm_admin
|
||||||
|
@ -176,7 +176,7 @@ def reorder_realm_custom_profile_fields(
|
||||||
order: List[int] = REQ(json_validator=check_list(check_int)),
|
order: List[int] = REQ(json_validator=check_list(check_int)),
|
||||||
) -> HttpResponse:
|
) -> HttpResponse:
|
||||||
try_reorder_realm_custom_profile_fields(user_profile.realm, order)
|
try_reorder_realm_custom_profile_fields(user_profile.realm, order)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
@human_users_only
|
@human_users_only
|
||||||
|
@ -188,7 +188,7 @@ def remove_user_custom_profile_data(
|
||||||
) -> HttpResponse:
|
) -> HttpResponse:
|
||||||
for field_id in data:
|
for field_id in data:
|
||||||
check_remove_custom_profile_field_value(user_profile, field_id)
|
check_remove_custom_profile_field_value(user_profile, field_id)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
@human_users_only
|
@human_users_only
|
||||||
|
@ -211,4 +211,4 @@ def update_user_custom_profile_data(
|
||||||
validate_user_custom_profile_data(user_profile.realm.id, data)
|
validate_user_custom_profile_data(user_profile.realm.id, data)
|
||||||
do_update_user_custom_profile_data_if_changed(user_profile, data)
|
do_update_user_custom_profile_data_if_changed(user_profile, data)
|
||||||
# We need to call this explicitly otherwise constraints are not check
|
# We need to call this explicitly otherwise constraints are not check
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
|
@ -18,4 +18,4 @@ def remove_caches(request: HttpRequest) -> HttpResponse:
|
||||||
cache.clear()
|
cache.clear()
|
||||||
clear_client_cache()
|
clear_client_cache()
|
||||||
flush_per_request_caches()
|
flush_per_request_caches()
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
|
@ -135,7 +135,7 @@ def api_dev_fetch_api_key(request: HttpRequest, username: str = REQ()) -> HttpRe
|
||||||
|
|
||||||
do_login(request, user_profile)
|
do_login(request, user_profile)
|
||||||
api_key = get_api_key(user_profile)
|
api_key = get_api_key(user_profile)
|
||||||
return json_success({"api_key": api_key, "email": user_profile.delivery_email})
|
return json_success(request, data={"api_key": api_key, "email": user_profile.delivery_email})
|
||||||
|
|
||||||
|
|
||||||
@csrf_exempt
|
@csrf_exempt
|
||||||
|
@ -144,7 +144,8 @@ def api_dev_list_users(request: HttpRequest) -> HttpResponse:
|
||||||
|
|
||||||
users = get_dev_users()
|
users = get_dev_users()
|
||||||
return json_success(
|
return json_success(
|
||||||
dict(
|
request,
|
||||||
|
data=dict(
|
||||||
direct_admins=[
|
direct_admins=[
|
||||||
dict(email=u.delivery_email, realm_uri=u.realm.uri)
|
dict(email=u.delivery_email, realm_uri=u.realm.uri)
|
||||||
for u in users
|
for u in users
|
||||||
|
@ -155,5 +156,5 @@ def api_dev_list_users(request: HttpRequest) -> HttpResponse:
|
||||||
for u in users
|
for u in users
|
||||||
if not u.is_realm_admin
|
if not u.is_realm_admin
|
||||||
],
|
],
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
|
|
|
@ -25,7 +25,7 @@ ZULIP_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../")
|
||||||
def email_page(request: HttpRequest) -> HttpResponse:
|
def email_page(request: HttpRequest) -> HttpResponse:
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
set_forward_address(request.POST["forward_address"])
|
set_forward_address(request.POST["forward_address"])
|
||||||
return json_success()
|
return json_success(request)
|
||||||
try:
|
try:
|
||||||
with open(settings.EMAIL_CONTENT_LOG_PATH, "r+") as f:
|
with open(settings.EMAIL_CONTENT_LOG_PATH, "r+") as f:
|
||||||
content = f.read()
|
content = f.read()
|
||||||
|
|
|
@ -91,7 +91,7 @@ def get_fixtures(request: HttpResponse, integration_name: str = REQ()) -> HttpRe
|
||||||
headers = {fix_name(k): v for k, v in headers_raw.items()}
|
headers = {fix_name(k): v for k, v in headers_raw.items()}
|
||||||
fixtures[fixture] = {"body": body, "headers": headers}
|
fixtures[fixture] = {"body": body, "headers": headers}
|
||||||
|
|
||||||
return json_success({"fixtures": fixtures})
|
return json_success(request, data={"fixtures": fixtures})
|
||||||
|
|
||||||
|
|
||||||
@has_request_variables
|
@has_request_variables
|
||||||
|
@ -110,7 +110,7 @@ def check_send_webhook_fixture_message(
|
||||||
response = send_webhook_fixture_message(url, body, is_json, custom_headers_dict)
|
response = send_webhook_fixture_message(url, body, is_json, custom_headers_dict)
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
responses = [{"status_code": response.status_code, "message": response.content.decode()}]
|
responses = [{"status_code": response.status_code, "message": response.content.decode()}]
|
||||||
return json_success({"responses": responses})
|
return json_success(request, data={"responses": responses})
|
||||||
else:
|
else:
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
@ -150,4 +150,4 @@ def send_all_webhook_fixture_messages(
|
||||||
"message": response.content.decode(),
|
"message": response.content.decode(),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
return json_success({"responses": responses})
|
return json_success(request, data={"responses": responses})
|
||||||
|
|
|
@ -16,7 +16,7 @@ from zerver.views.registration import accounts_register
|
||||||
|
|
||||||
# This is used only by the Puppeteer test in 01-realm-creation.js.
|
# This is used only by the Puppeteer test in 01-realm-creation.js.
|
||||||
def confirmation_key(request: HttpRequest) -> HttpResponse:
|
def confirmation_key(request: HttpRequest) -> HttpResponse:
|
||||||
return json_success(request.session.get("confirmation_key"))
|
return json_success(request, data=request.session.get("confirmation_key"))
|
||||||
|
|
||||||
|
|
||||||
def modify_postdata(request: HttpRequest, **kwargs: Any) -> None:
|
def modify_postdata(request: HttpRequest, **kwargs: Any) -> None:
|
||||||
|
|
|
@ -19,7 +19,7 @@ from zerver.models import Draft, UserProfile
|
||||||
def fetch_drafts(request: HttpRequest, user_profile: UserProfile) -> HttpResponse:
|
def fetch_drafts(request: HttpRequest, user_profile: UserProfile) -> HttpResponse:
|
||||||
user_drafts = Draft.objects.filter(user_profile=user_profile).order_by("last_edit_time")
|
user_drafts = Draft.objects.filter(user_profile=user_profile).order_by("last_edit_time")
|
||||||
draft_dicts = [draft.to_dict() for draft in user_drafts]
|
draft_dicts = [draft.to_dict() for draft in user_drafts]
|
||||||
return json_success({"count": user_drafts.count(), "drafts": draft_dicts})
|
return json_success(request, data={"count": user_drafts.count(), "drafts": draft_dicts})
|
||||||
|
|
||||||
|
|
||||||
@draft_endpoint
|
@draft_endpoint
|
||||||
|
@ -33,7 +33,7 @@ def create_drafts(
|
||||||
) -> HttpResponse:
|
) -> HttpResponse:
|
||||||
created_draft_objects = do_create_drafts(draft_dicts, user_profile)
|
created_draft_objects = do_create_drafts(draft_dicts, user_profile)
|
||||||
draft_ids = [draft_object.id for draft_object in created_draft_objects]
|
draft_ids = [draft_object.id for draft_object in created_draft_objects]
|
||||||
return json_success({"ids": draft_ids})
|
return json_success(request, data={"ids": draft_ids})
|
||||||
|
|
||||||
|
|
||||||
@draft_endpoint
|
@draft_endpoint
|
||||||
|
@ -45,10 +45,10 @@ def edit_draft(
|
||||||
draft_dict: Dict[str, Any] = REQ("draft", json_validator=draft_dict_validator),
|
draft_dict: Dict[str, Any] = REQ("draft", json_validator=draft_dict_validator),
|
||||||
) -> HttpResponse:
|
) -> HttpResponse:
|
||||||
do_edit_draft(draft_id, draft_dict, user_profile)
|
do_edit_draft(draft_id, draft_dict, user_profile)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
@draft_endpoint
|
@draft_endpoint
|
||||||
def delete_draft(request: HttpRequest, user_profile: UserProfile, draft_id: int) -> HttpResponse:
|
def delete_draft(request: HttpRequest, user_profile: UserProfile, draft_id: int) -> HttpResponse:
|
||||||
do_delete_draft(draft_id, user_profile)
|
do_delete_draft(draft_id, user_profile)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
|
@ -17,4 +17,4 @@ def email_mirror_message(
|
||||||
result = mirror_email_message(rcpt_to, msg_base64)
|
result = mirror_email_message(rcpt_to, msg_base64)
|
||||||
if result["status"] == "error":
|
if result["status"] == "error":
|
||||||
raise JsonableError(result["msg"])
|
raise JsonableError(result["msg"])
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
|
@ -97,4 +97,4 @@ def events_register_backend(
|
||||||
client_capabilities=client_capabilities,
|
client_capabilities=client_capabilities,
|
||||||
fetch_event_types=fetch_event_types,
|
fetch_event_types=fetch_event_types,
|
||||||
)
|
)
|
||||||
return json_success(ret)
|
return json_success(request, data=ret)
|
||||||
|
|
|
@ -18,4 +18,4 @@ def mark_hotspot_as_read(
|
||||||
if hotspot not in ALL_HOTSPOTS:
|
if hotspot not in ALL_HOTSPOTS:
|
||||||
raise JsonableError(_("Unknown hotspot: {}").format(hotspot))
|
raise JsonableError(_("Unknown hotspot: {}").format(hotspot))
|
||||||
do_mark_hotspot_as_read(user, hotspot)
|
do_mark_hotspot_as_read(user, hotspot)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
|
@ -83,7 +83,7 @@ def invite_users_backend(
|
||||||
invite_expires_in_days=invite_expires_in_days,
|
invite_expires_in_days=invite_expires_in_days,
|
||||||
invite_as=invite_as,
|
invite_as=invite_as,
|
||||||
)
|
)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
def get_invitee_emails_set(invitee_emails_raw: str) -> Set[str]:
|
def get_invitee_emails_set(invitee_emails_raw: str) -> Set[str]:
|
||||||
|
@ -100,7 +100,7 @@ def get_invitee_emails_set(invitee_emails_raw: str) -> Set[str]:
|
||||||
@require_member_or_admin
|
@require_member_or_admin
|
||||||
def get_user_invites(request: HttpRequest, user_profile: UserProfile) -> HttpResponse:
|
def get_user_invites(request: HttpRequest, user_profile: UserProfile) -> HttpResponse:
|
||||||
all_users = do_get_invites_controlled_by_user(user_profile)
|
all_users = do_get_invites_controlled_by_user(user_profile)
|
||||||
return json_success({"invites": all_users})
|
return json_success(request, data={"invites": all_users})
|
||||||
|
|
||||||
|
|
||||||
@require_member_or_admin
|
@require_member_or_admin
|
||||||
|
@ -122,7 +122,7 @@ def revoke_user_invite(
|
||||||
raise JsonableError(_("Must be an organization administrator"))
|
raise JsonableError(_("Must be an organization administrator"))
|
||||||
|
|
||||||
do_revoke_user_invite(prereg_user)
|
do_revoke_user_invite(prereg_user)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
@require_realm_admin
|
@require_realm_admin
|
||||||
|
@ -142,7 +142,7 @@ def revoke_multiuse_invite(
|
||||||
check_if_owner_required(invite.invited_as, user_profile)
|
check_if_owner_required(invite.invited_as, user_profile)
|
||||||
|
|
||||||
do_revoke_multi_use_invite(invite)
|
do_revoke_multi_use_invite(invite)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
@require_member_or_admin
|
@require_member_or_admin
|
||||||
|
@ -166,7 +166,7 @@ def resend_user_invite_email(
|
||||||
raise JsonableError(_("Must be an organization administrator"))
|
raise JsonableError(_("Must be an organization administrator"))
|
||||||
|
|
||||||
timestamp = do_resend_user_invite_email(prereg_user)
|
timestamp = do_resend_user_invite_email(prereg_user)
|
||||||
return json_success({"timestamp": timestamp})
|
return json_success(request, data={"timestamp": timestamp})
|
||||||
|
|
||||||
|
|
||||||
@require_realm_admin
|
@require_realm_admin
|
||||||
|
@ -193,4 +193,4 @@ def generate_multiuse_invite_backend(
|
||||||
invite_link = do_create_multiuse_invite_link(
|
invite_link = do_create_multiuse_invite_link(
|
||||||
user_profile, invite_as, invite_expires_in_days, streams
|
user_profile, invite_as, invite_expires_in_days, streams
|
||||||
)
|
)
|
||||||
return json_success({"invite_link": invite_link})
|
return json_success(request, data={"invite_link": invite_link})
|
||||||
|
|
|
@ -87,7 +87,7 @@ def get_message_edit_history(
|
||||||
|
|
||||||
# Fill in all the extra data that will make it usable
|
# Fill in all the extra data that will make it usable
|
||||||
fill_edit_history_entries(message_edit_history, message)
|
fill_edit_history_entries(message_edit_history, message)
|
||||||
return json_success({"message_history": list(reversed(message_edit_history))})
|
return json_success(request, data={"message_history": list(reversed(message_edit_history))})
|
||||||
|
|
||||||
|
|
||||||
PROPAGATE_MODE_VALUES = ["change_later", "change_one", "change_all"]
|
PROPAGATE_MODE_VALUES = ["change_later", "change_one", "change_all"]
|
||||||
|
@ -123,7 +123,7 @@ def update_message_backend(
|
||||||
assert log_data is not None
|
assert log_data is not None
|
||||||
log_data["extra"] = f"[{number_changed}]"
|
log_data["extra"] = f"[{number_changed}]"
|
||||||
|
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
def validate_can_delete_message(user_profile: UserProfile, message: Message) -> None:
|
def validate_can_delete_message(user_profile: UserProfile, message: Message) -> None:
|
||||||
|
@ -164,7 +164,7 @@ def delete_message_backend(
|
||||||
do_delete_messages(user_profile.realm, [message])
|
do_delete_messages(user_profile.realm, [message])
|
||||||
except (Message.DoesNotExist, IntegrityError):
|
except (Message.DoesNotExist, IntegrityError):
|
||||||
raise JsonableError(_("Message already deleted"))
|
raise JsonableError(_("Message already deleted"))
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
@has_request_variables
|
@has_request_variables
|
||||||
|
@ -180,4 +180,4 @@ def json_fetch_raw_message(
|
||||||
else:
|
else:
|
||||||
(message, user_message) = access_message(maybe_user_profile, message_id)
|
(message, user_message) = access_message(maybe_user_profile, message_id)
|
||||||
|
|
||||||
return json_success({"raw_content": message.content})
|
return json_success(request, data={"raw_content": message.content})
|
||||||
|
|
|
@ -1168,7 +1168,7 @@ def get_messages_backend(
|
||||||
history_limited=query_info["history_limited"],
|
history_limited=query_info["history_limited"],
|
||||||
anchor=anchor,
|
anchor=anchor,
|
||||||
)
|
)
|
||||||
return json_success(ret)
|
return json_success(request, data=ret)
|
||||||
|
|
||||||
|
|
||||||
def limit_query_to_range(
|
def limit_query_to_range(
|
||||||
|
@ -1372,4 +1372,4 @@ def messages_in_narrow_backend(
|
||||||
topic_matches,
|
topic_matches,
|
||||||
)
|
)
|
||||||
|
|
||||||
return json_success({"messages": search_fields})
|
return json_success(request, data={"messages": search_fields})
|
||||||
|
|
|
@ -45,7 +45,7 @@ def update_message_flags(
|
||||||
log_data_str = f"[{operation} {flag}/{target_count_str}] actually {count}"
|
log_data_str = f"[{operation} {flag}/{target_count_str}] actually {count}"
|
||||||
request_notes.log_data["extra"] = log_data_str
|
request_notes.log_data["extra"] = log_data_str
|
||||||
|
|
||||||
return json_success({"result": "success", "messages": messages, "msg": ""})
|
return json_success(request, data={"messages": messages})
|
||||||
|
|
||||||
|
|
||||||
@has_request_variables
|
@has_request_variables
|
||||||
|
@ -58,7 +58,7 @@ def mark_all_as_read(request: HttpRequest, user_profile: UserProfile) -> HttpRes
|
||||||
assert request_notes.log_data is not None
|
assert request_notes.log_data is not None
|
||||||
request_notes.log_data["extra"] = log_data_str
|
request_notes.log_data["extra"] = log_data_str
|
||||||
|
|
||||||
return json_success({"result": "success", "msg": ""})
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
@has_request_variables
|
@has_request_variables
|
||||||
|
@ -73,7 +73,7 @@ def mark_stream_as_read(
|
||||||
assert log_data is not None
|
assert log_data is not None
|
||||||
log_data["extra"] = log_data_str
|
log_data["extra"] = log_data_str
|
||||||
|
|
||||||
return json_success({"result": "success", "msg": ""})
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
@has_request_variables
|
@has_request_variables
|
||||||
|
@ -102,4 +102,4 @@ def mark_topic_as_read(
|
||||||
assert log_data is not None
|
assert log_data is not None
|
||||||
log_data["extra"] = log_data_str
|
log_data["extra"] = log_data_str
|
||||||
|
|
||||||
return json_success({"result": "success", "msg": ""})
|
return json_success(request)
|
||||||
|
|
|
@ -297,7 +297,7 @@ def send_message_backend(
|
||||||
forwarder_user_profile=user_profile,
|
forwarder_user_profile=user_profile,
|
||||||
realm=realm,
|
realm=realm,
|
||||||
)
|
)
|
||||||
return json_success(data={"deliver_at": deliver_at})
|
return json_success(request, data={"deliver_at": deliver_at})
|
||||||
|
|
||||||
ret = check_send_message(
|
ret = check_send_message(
|
||||||
sender,
|
sender,
|
||||||
|
@ -314,14 +314,14 @@ def send_message_backend(
|
||||||
sender_queue_id=queue_id,
|
sender_queue_id=queue_id,
|
||||||
widget_content=widget_content,
|
widget_content=widget_content,
|
||||||
)
|
)
|
||||||
return json_success({"id": ret})
|
return json_success(request, data={"id": ret})
|
||||||
|
|
||||||
|
|
||||||
@has_request_variables
|
@has_request_variables
|
||||||
def zcommand_backend(
|
def zcommand_backend(
|
||||||
request: HttpRequest, user_profile: UserProfile, command: str = REQ("command")
|
request: HttpRequest, user_profile: UserProfile, command: str = REQ("command")
|
||||||
) -> HttpResponse:
|
) -> HttpResponse:
|
||||||
return json_success(process_zcommands(command, user_profile))
|
return json_success(request, data=process_zcommands(command, user_profile))
|
||||||
|
|
||||||
|
|
||||||
@has_request_variables
|
@has_request_variables
|
||||||
|
@ -336,4 +336,4 @@ def render_message_backend(
|
||||||
message.sending_client = client
|
message.sending_client = client
|
||||||
|
|
||||||
rendering_result = render_markdown(message, content, realm=user_profile.realm)
|
rendering_result = render_markdown(message, content, realm=user_profile.realm)
|
||||||
return json_success({"rendered": rendering_result.rendered_content})
|
return json_success(request, data={"rendered": rendering_result.rendered_content})
|
||||||
|
|
|
@ -79,7 +79,7 @@ def update_muted_topic(
|
||||||
topic_name=topic,
|
topic_name=topic,
|
||||||
date_muted=timezone_now(),
|
date_muted=timezone_now(),
|
||||||
)
|
)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
elif op == "remove":
|
elif op == "remove":
|
||||||
unmute_topic(
|
unmute_topic(
|
||||||
user_profile=user_profile,
|
user_profile=user_profile,
|
||||||
|
@ -87,7 +87,7 @@ def update_muted_topic(
|
||||||
stream_name=stream,
|
stream_name=stream,
|
||||||
topic_name=topic,
|
topic_name=topic,
|
||||||
)
|
)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
def mute_user(request: HttpRequest, user_profile: UserProfile, muted_user_id: int) -> HttpResponse:
|
def mute_user(request: HttpRequest, user_profile: UserProfile, muted_user_id: int) -> HttpResponse:
|
||||||
|
@ -103,7 +103,7 @@ def mute_user(request: HttpRequest, user_profile: UserProfile, muted_user_id: in
|
||||||
raise JsonableError(_("User already muted"))
|
raise JsonableError(_("User already muted"))
|
||||||
|
|
||||||
do_mute_user(user_profile, muted_user, date_muted)
|
do_mute_user(user_profile, muted_user, date_muted)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
def unmute_user(
|
def unmute_user(
|
||||||
|
@ -118,4 +118,4 @@ def unmute_user(
|
||||||
raise JsonableError(_("User is not muted"))
|
raise JsonableError(_("User is not muted"))
|
||||||
|
|
||||||
do_unmute_user(mute_object)
|
do_unmute_user(mute_object)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
|
@ -60,7 +60,7 @@ def get_presence_backend(
|
||||||
for val in result["presence"].values():
|
for val in result["presence"].values():
|
||||||
val.pop("client", None)
|
val.pop("client", None)
|
||||||
val.pop("pushable", None)
|
val.pop("pushable", None)
|
||||||
return json_success(result)
|
return json_success(request, data=result)
|
||||||
|
|
||||||
|
|
||||||
@human_users_only
|
@human_users_only
|
||||||
|
@ -126,7 +126,7 @@ def update_user_status_backend(
|
||||||
reaction_type=emoji_type,
|
reaction_type=emoji_type,
|
||||||
)
|
)
|
||||||
|
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
@human_users_only
|
@human_users_only
|
||||||
|
@ -167,11 +167,11 @@ def update_active_status_backend(
|
||||||
except UserActivity.DoesNotExist:
|
except UserActivity.DoesNotExist:
|
||||||
ret["zephyr_mirror_active"] = False
|
ret["zephyr_mirror_active"] = False
|
||||||
|
|
||||||
return json_success(ret)
|
return json_success(request, data=ret)
|
||||||
|
|
||||||
|
|
||||||
def get_statuses_for_realm(request: HttpRequest, user_profile: UserProfile) -> HttpResponse:
|
def get_statuses_for_realm(request: HttpRequest, user_profile: UserProfile) -> HttpResponse:
|
||||||
# This isn't used by the web app; it's available for API use by
|
# This isn't used by the web app; it's available for API use by
|
||||||
# bots and other clients. We may want to add slim_presence
|
# bots and other clients. We may want to add slim_presence
|
||||||
# support for it (or just migrate its API wholesale) later.
|
# support for it (or just migrate its API wholesale) later.
|
||||||
return json_success(get_presence_response(user_profile, slim_presence=False))
|
return json_success(request, data=get_presence_response(user_profile, slim_presence=False))
|
||||||
|
|
|
@ -35,7 +35,7 @@ def add_apns_device_token(
|
||||||
) -> HttpResponse:
|
) -> HttpResponse:
|
||||||
validate_token(token, PushDeviceToken.APNS)
|
validate_token(token, PushDeviceToken.APNS)
|
||||||
add_push_device_token(user_profile, token, PushDeviceToken.APNS, ios_app_id=appid)
|
add_push_device_token(user_profile, token, PushDeviceToken.APNS, ios_app_id=appid)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
@human_users_only
|
@human_users_only
|
||||||
|
@ -45,7 +45,7 @@ def add_android_reg_id(
|
||||||
) -> HttpResponse:
|
) -> HttpResponse:
|
||||||
validate_token(token, PushDeviceToken.GCM)
|
validate_token(token, PushDeviceToken.GCM)
|
||||||
add_push_device_token(user_profile, token, PushDeviceToken.GCM)
|
add_push_device_token(user_profile, token, PushDeviceToken.GCM)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
@human_users_only
|
@human_users_only
|
||||||
|
@ -55,7 +55,7 @@ def remove_apns_device_token(
|
||||||
) -> HttpResponse:
|
) -> HttpResponse:
|
||||||
validate_token(token, PushDeviceToken.APNS)
|
validate_token(token, PushDeviceToken.APNS)
|
||||||
remove_push_device_token(user_profile, token, PushDeviceToken.APNS)
|
remove_push_device_token(user_profile, token, PushDeviceToken.APNS)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
@human_users_only
|
@human_users_only
|
||||||
|
@ -65,4 +65,4 @@ def remove_android_reg_id(
|
||||||
) -> HttpResponse:
|
) -> HttpResponse:
|
||||||
validate_token(token, PushDeviceToken.GCM)
|
validate_token(token, PushDeviceToken.GCM)
|
||||||
remove_push_device_token(user_profile, token, PushDeviceToken.GCM)
|
remove_push_device_token(user_profile, token, PushDeviceToken.GCM)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
|
@ -26,7 +26,7 @@ def add_reaction(
|
||||||
) -> HttpResponse:
|
) -> HttpResponse:
|
||||||
check_add_reaction(user_profile, message_id, emoji_name, emoji_code, reaction_type)
|
check_add_reaction(user_profile, message_id, emoji_name, emoji_code, reaction_type)
|
||||||
|
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
# transaction.atomic is required since we use FOR UPDATE queries in access_message
|
# transaction.atomic is required since we use FOR UPDATE queries in access_message
|
||||||
|
@ -77,4 +77,4 @@ def remove_reaction(
|
||||||
# deactivated by an administrator in the meantime).
|
# deactivated by an administrator in the meantime).
|
||||||
do_remove_reaction(user_profile, message, emoji_code, reaction_type)
|
do_remove_reaction(user_profile, message, emoji_code, reaction_type)
|
||||||
|
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
|
@ -294,7 +294,7 @@ def update_realm(
|
||||||
do_change_realm_subdomain(realm, string_id, acting_user=user_profile)
|
do_change_realm_subdomain(realm, string_id, acting_user=user_profile)
|
||||||
data["realm_uri"] = realm.uri
|
data["realm_uri"] = realm.uri
|
||||||
|
|
||||||
return json_success(data)
|
return json_success(request, data)
|
||||||
|
|
||||||
|
|
||||||
@require_realm_owner
|
@require_realm_owner
|
||||||
|
@ -302,16 +302,16 @@ def update_realm(
|
||||||
def deactivate_realm(request: HttpRequest, user: UserProfile) -> HttpResponse:
|
def deactivate_realm(request: HttpRequest, user: UserProfile) -> HttpResponse:
|
||||||
realm = user.realm
|
realm = user.realm
|
||||||
do_deactivate_realm(realm, acting_user=user)
|
do_deactivate_realm(realm, acting_user=user)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
@require_safe
|
@require_safe
|
||||||
def check_subdomain_available(request: HttpRequest, subdomain: str) -> HttpResponse:
|
def check_subdomain_available(request: HttpRequest, subdomain: str) -> HttpResponse:
|
||||||
try:
|
try:
|
||||||
check_subdomain(subdomain)
|
check_subdomain(subdomain)
|
||||||
return json_success({"msg": "available"})
|
return json_success(request, data={"msg": "available"})
|
||||||
except ValidationError as e:
|
except ValidationError as e:
|
||||||
return json_success({"msg": e.message})
|
return json_success(request, data={"msg": e.message})
|
||||||
|
|
||||||
|
|
||||||
def realm_reactivation(request: HttpRequest, confirmation_key: str) -> HttpResponse:
|
def realm_reactivation(request: HttpRequest, confirmation_key: str) -> HttpResponse:
|
||||||
|
@ -426,4 +426,4 @@ def update_realm_user_settings_defaults(
|
||||||
if len(request_notes.ignored_parameters) > 0:
|
if len(request_notes.ignored_parameters) > 0:
|
||||||
result["ignored_parameters_unsupported"] = list(request_notes.ignored_parameters)
|
result["ignored_parameters_unsupported"] = list(request_notes.ignored_parameters)
|
||||||
|
|
||||||
return json_success(result)
|
return json_success(request, data=result)
|
||||||
|
|
|
@ -14,7 +14,7 @@ from zerver.models import RealmDomain, UserProfile, get_realm_domains
|
||||||
|
|
||||||
def list_realm_domains(request: HttpRequest, user_profile: UserProfile) -> HttpResponse:
|
def list_realm_domains(request: HttpRequest, user_profile: UserProfile) -> HttpResponse:
|
||||||
domains = get_realm_domains(user_profile.realm)
|
domains = get_realm_domains(user_profile.realm)
|
||||||
return json_success({"domains": domains})
|
return json_success(request, data={"domains": domains})
|
||||||
|
|
||||||
|
|
||||||
@require_realm_admin
|
@require_realm_admin
|
||||||
|
@ -35,7 +35,7 @@ def create_realm_domain(
|
||||||
_("The domain {domain} is already a part of your organization.").format(domain=domain)
|
_("The domain {domain} is already a part of your organization.").format(domain=domain)
|
||||||
)
|
)
|
||||||
realm_domain = do_add_realm_domain(user_profile.realm, domain, allow_subdomains)
|
realm_domain = do_add_realm_domain(user_profile.realm, domain, allow_subdomains)
|
||||||
return json_success({"new_domain": [realm_domain.id, realm_domain.domain]})
|
return json_success(request, data={"new_domain": [realm_domain.id, realm_domain.domain]})
|
||||||
|
|
||||||
|
|
||||||
@require_realm_admin
|
@require_realm_admin
|
||||||
|
@ -51,7 +51,7 @@ def patch_realm_domain(
|
||||||
do_change_realm_domain(realm_domain, allow_subdomains)
|
do_change_realm_domain(realm_domain, allow_subdomains)
|
||||||
except RealmDomain.DoesNotExist:
|
except RealmDomain.DoesNotExist:
|
||||||
raise JsonableError(_("No entry found for domain {domain}.").format(domain=domain))
|
raise JsonableError(_("No entry found for domain {domain}.").format(domain=domain))
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
@require_realm_admin
|
@require_realm_admin
|
||||||
|
@ -64,4 +64,4 @@ def delete_realm_domain(
|
||||||
do_remove_realm_domain(realm_domain, acting_user=user_profile)
|
do_remove_realm_domain(realm_domain, acting_user=user_profile)
|
||||||
except RealmDomain.DoesNotExist:
|
except RealmDomain.DoesNotExist:
|
||||||
raise JsonableError(_("No entry found for domain {domain}.").format(domain=domain))
|
raise JsonableError(_("No entry found for domain {domain}.").format(domain=domain))
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
|
@ -15,7 +15,7 @@ def list_emoji(request: HttpRequest, user_profile: UserProfile) -> HttpResponse:
|
||||||
|
|
||||||
# We don't do any checks here because the list of realm
|
# We don't do any checks here because the list of realm
|
||||||
# emoji is public.
|
# emoji is public.
|
||||||
return json_success({"emoji": user_profile.realm.get_emoji()})
|
return json_success(request, data={"emoji": user_profile.realm.get_emoji()})
|
||||||
|
|
||||||
|
|
||||||
@require_member_or_admin
|
@require_member_or_admin
|
||||||
|
@ -50,7 +50,7 @@ def upload_emoji(
|
||||||
realm_emoji = check_add_realm_emoji(user_profile.realm, emoji_name, user_profile, emoji_file)
|
realm_emoji = check_add_realm_emoji(user_profile.realm, emoji_name, user_profile, emoji_file)
|
||||||
if realm_emoji is None:
|
if realm_emoji is None:
|
||||||
raise JsonableError(_("Image file upload failed."))
|
raise JsonableError(_("Image file upload failed."))
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
def delete_emoji(request: HttpRequest, user_profile: UserProfile, emoji_name: str) -> HttpResponse:
|
def delete_emoji(request: HttpRequest, user_profile: UserProfile, emoji_name: str) -> HttpResponse:
|
||||||
|
@ -60,4 +60,4 @@ def delete_emoji(request: HttpRequest, user_profile: UserProfile, emoji_name: st
|
||||||
raise JsonableError(_("Emoji '{}' does not exist").format(emoji_name))
|
raise JsonableError(_("Emoji '{}' does not exist").format(emoji_name))
|
||||||
check_remove_custom_emoji(user_profile, emoji_name)
|
check_remove_custom_emoji(user_profile, emoji_name)
|
||||||
do_remove_realm_emoji(user_profile.realm, emoji_name)
|
do_remove_realm_emoji(user_profile.realm, emoji_name)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
|
@ -73,13 +73,13 @@ def export_realm(request: HttpRequest, user: UserProfile) -> HttpResponse:
|
||||||
"id": row.id,
|
"id": row.id,
|
||||||
}
|
}
|
||||||
queue_json_publish("deferred_work", event)
|
queue_json_publish("deferred_work", event)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
@require_realm_admin
|
@require_realm_admin
|
||||||
def get_realm_exports(request: HttpRequest, user: UserProfile) -> HttpResponse:
|
def get_realm_exports(request: HttpRequest, user: UserProfile) -> HttpResponse:
|
||||||
realm_exports = get_realm_exports_serialized(user)
|
realm_exports = get_realm_exports_serialized(user)
|
||||||
return json_success({"exports": realm_exports})
|
return json_success(request, data={"exports": realm_exports})
|
||||||
|
|
||||||
|
|
||||||
@require_realm_admin
|
@require_realm_admin
|
||||||
|
@ -95,4 +95,4 @@ def delete_realm_export(request: HttpRequest, user: UserProfile, export_id: int)
|
||||||
if "deleted_timestamp" in export_data:
|
if "deleted_timestamp" in export_data:
|
||||||
raise JsonableError(_("Export already deleted"))
|
raise JsonableError(_("Export already deleted"))
|
||||||
do_delete_realm_export(user, audit_log_entry)
|
do_delete_realm_export(user, audit_log_entry)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
|
@ -35,7 +35,7 @@ def upload_icon(request: HttpRequest, user_profile: UserProfile) -> HttpResponse
|
||||||
json_result = dict(
|
json_result = dict(
|
||||||
icon_url=icon_url,
|
icon_url=icon_url,
|
||||||
)
|
)
|
||||||
return json_success(json_result)
|
return json_success(request, data=json_result)
|
||||||
|
|
||||||
|
|
||||||
@require_realm_admin
|
@require_realm_admin
|
||||||
|
@ -50,7 +50,7 @@ def delete_icon_backend(request: HttpRequest, user_profile: UserProfile) -> Http
|
||||||
json_result = dict(
|
json_result = dict(
|
||||||
icon_url=gravatar_url,
|
icon_url=gravatar_url,
|
||||||
)
|
)
|
||||||
return json_success(json_result)
|
return json_success(request, data=json_result)
|
||||||
|
|
||||||
|
|
||||||
def get_icon_backend(request: HttpRequest, user_profile: UserProfile) -> HttpResponse:
|
def get_icon_backend(request: HttpRequest, user_profile: UserProfile) -> HttpResponse:
|
||||||
|
|
|
@ -13,7 +13,7 @@ from zerver.models import RealmFilter, UserProfile, linkifiers_for_realm
|
||||||
# Custom realm linkifiers
|
# Custom realm linkifiers
|
||||||
def list_linkifiers(request: HttpRequest, user_profile: UserProfile) -> HttpResponse:
|
def list_linkifiers(request: HttpRequest, user_profile: UserProfile) -> HttpResponse:
|
||||||
linkifiers = linkifiers_for_realm(user_profile.realm_id)
|
linkifiers = linkifiers_for_realm(user_profile.realm_id)
|
||||||
return json_success({"linkifiers": linkifiers})
|
return json_success(request, data={"linkifiers": linkifiers})
|
||||||
|
|
||||||
|
|
||||||
@require_realm_admin
|
@require_realm_admin
|
||||||
|
@ -30,7 +30,7 @@ def create_linkifier(
|
||||||
pattern=pattern,
|
pattern=pattern,
|
||||||
url_format_string=url_format_string,
|
url_format_string=url_format_string,
|
||||||
)
|
)
|
||||||
return json_success({"id": linkifier_id})
|
return json_success(request, data={"id": linkifier_id})
|
||||||
except ValidationError as e:
|
except ValidationError as e:
|
||||||
raise ValidationFailureError(e)
|
raise ValidationFailureError(e)
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ def delete_linkifier(
|
||||||
do_remove_linkifier(realm=user_profile.realm, id=filter_id)
|
do_remove_linkifier(realm=user_profile.realm, id=filter_id)
|
||||||
except RealmFilter.DoesNotExist:
|
except RealmFilter.DoesNotExist:
|
||||||
raise JsonableError(_("Linkifier not found."))
|
raise JsonableError(_("Linkifier not found."))
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
@require_realm_admin
|
@require_realm_admin
|
||||||
|
@ -62,7 +62,7 @@ def update_linkifier(
|
||||||
pattern=pattern,
|
pattern=pattern,
|
||||||
url_format_string=url_format_string,
|
url_format_string=url_format_string,
|
||||||
)
|
)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
except RealmFilter.DoesNotExist:
|
except RealmFilter.DoesNotExist:
|
||||||
raise JsonableError(_("Linkifier not found."))
|
raise JsonableError(_("Linkifier not found."))
|
||||||
except ValidationError as e:
|
except ValidationError as e:
|
||||||
|
|
|
@ -35,7 +35,7 @@ def upload_logo(
|
||||||
do_change_logo_source(
|
do_change_logo_source(
|
||||||
user_profile.realm, user_profile.realm.LOGO_UPLOADED, night, acting_user=user_profile
|
user_profile.realm, user_profile.realm.LOGO_UPLOADED, night, acting_user=user_profile
|
||||||
)
|
)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
@require_realm_admin
|
@require_realm_admin
|
||||||
|
@ -49,7 +49,7 @@ def delete_logo_backend(
|
||||||
do_change_logo_source(
|
do_change_logo_source(
|
||||||
user_profile.realm, user_profile.realm.LOGO_DEFAULT, night, acting_user=user_profile
|
user_profile.realm, user_profile.realm.LOGO_DEFAULT, night, acting_user=user_profile
|
||||||
)
|
)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
@has_request_variables
|
@has_request_variables
|
||||||
|
|
|
@ -52,7 +52,7 @@ def add_realm_playground(
|
||||||
)
|
)
|
||||||
except ValidationError as e:
|
except ValidationError as e:
|
||||||
raise ValidationFailureError(e)
|
raise ValidationFailureError(e)
|
||||||
return json_success({"id": playground_id})
|
return json_success(request, data={"id": playground_id})
|
||||||
|
|
||||||
|
|
||||||
@require_realm_admin
|
@require_realm_admin
|
||||||
|
@ -62,4 +62,4 @@ def delete_realm_playground(
|
||||||
) -> HttpResponse:
|
) -> HttpResponse:
|
||||||
realm_playground = access_playground_by_id(user_profile.realm, playground_id)
|
realm_playground = access_playground_by_id(user_profile.realm, playground_id)
|
||||||
do_remove_realm_playground(user_profile.realm, realm_playground)
|
do_remove_realm_playground(user_profile.realm, realm_playground)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
|
@ -70,7 +70,7 @@ def report_send_times(
|
||||||
statsd.incr("locally_echoed")
|
statsd.incr("locally_echoed")
|
||||||
if rendered_content_disparity:
|
if rendered_content_disparity:
|
||||||
statsd.incr("render_disparity")
|
statsd.incr("render_disparity")
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
@has_request_variables
|
@has_request_variables
|
||||||
|
@ -89,7 +89,7 @@ def report_narrow_times(
|
||||||
statsd.timing(f"narrow.initial_core.{base_key}", initial_core)
|
statsd.timing(f"narrow.initial_core.{base_key}", initial_core)
|
||||||
statsd.timing(f"narrow.initial_free.{base_key}", initial_free)
|
statsd.timing(f"narrow.initial_free.{base_key}", initial_free)
|
||||||
statsd.timing(f"narrow.network.{base_key}", network)
|
statsd.timing(f"narrow.network.{base_key}", network)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
@has_request_variables
|
@has_request_variables
|
||||||
|
@ -106,7 +106,7 @@ def report_unnarrow_times(
|
||||||
base_key = statsd_key(realm.string_id, clean_periods=True)
|
base_key = statsd_key(realm.string_id, clean_periods=True)
|
||||||
statsd.timing(f"unnarrow.initial_core.{base_key}", initial_core)
|
statsd.timing(f"unnarrow.initial_core.{base_key}", initial_core)
|
||||||
statsd.timing(f"unnarrow.initial_free.{base_key}", initial_free)
|
statsd.timing(f"unnarrow.initial_free.{base_key}", initial_free)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
@has_request_variables
|
@has_request_variables
|
||||||
|
@ -124,7 +124,7 @@ def report_error(
|
||||||
"""Accepts an error report and stores in a queue for processing. The
|
"""Accepts an error report and stores in a queue for processing. The
|
||||||
actual error reports are later handled by do_report_error"""
|
actual error reports are later handled by do_report_error"""
|
||||||
if not settings.BROWSER_ERROR_REPORTING:
|
if not settings.BROWSER_ERROR_REPORTING:
|
||||||
return json_success()
|
return json_success(request)
|
||||||
more_info = dict(more_info)
|
more_info = dict(more_info)
|
||||||
|
|
||||||
js_source_map = get_js_source_map()
|
js_source_map = get_js_source_map()
|
||||||
|
@ -177,7 +177,7 @@ def report_error(
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
@csrf_exempt
|
@csrf_exempt
|
||||||
|
@ -206,4 +206,4 @@ def report_csp_violations(
|
||||||
get_attr("script-sample"),
|
get_attr("script-sample"),
|
||||||
)
|
)
|
||||||
|
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
|
@ -26,7 +26,7 @@ def update_storage(
|
||||||
set_bot_storage(user_profile, list(storage.items()))
|
set_bot_storage(user_profile, list(storage.items()))
|
||||||
except StateError as e: # nocoverage
|
except StateError as e: # nocoverage
|
||||||
raise JsonableError(str(e))
|
raise JsonableError(str(e))
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
@has_request_variables
|
@has_request_variables
|
||||||
|
@ -41,7 +41,7 @@ def get_storage(
|
||||||
storage = {key: get_bot_storage(user_profile, key) for key in keys}
|
storage = {key: get_bot_storage(user_profile, key) for key in keys}
|
||||||
except StateError as e:
|
except StateError as e:
|
||||||
raise JsonableError(str(e))
|
raise JsonableError(str(e))
|
||||||
return json_success({"storage": storage})
|
return json_success(request, data={"storage": storage})
|
||||||
|
|
||||||
|
|
||||||
@has_request_variables
|
@has_request_variables
|
||||||
|
@ -56,4 +56,4 @@ def remove_storage(
|
||||||
remove_bot_storage(user_profile, keys)
|
remove_bot_storage(user_profile, keys)
|
||||||
except StateError as e:
|
except StateError as e:
|
||||||
raise JsonableError(str(e))
|
raise JsonableError(str(e))
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
|
@ -145,7 +145,7 @@ def deactivate_stream_backend(
|
||||||
) -> HttpResponse:
|
) -> HttpResponse:
|
||||||
(stream, sub) = access_stream_for_delete_or_update(user_profile, stream_id)
|
(stream, sub) = access_stream_for_delete_or_update(user_profile, stream_id)
|
||||||
do_deactivate_stream(stream, acting_user=user_profile)
|
do_deactivate_stream(stream, acting_user=user_profile)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
@require_realm_admin
|
@require_realm_admin
|
||||||
|
@ -157,7 +157,7 @@ def add_default_stream(
|
||||||
if stream.invite_only:
|
if stream.invite_only:
|
||||||
raise JsonableError(_("Private streams cannot be made default."))
|
raise JsonableError(_("Private streams cannot be made default."))
|
||||||
do_add_default_stream(stream)
|
do_add_default_stream(stream)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
@require_realm_admin
|
@require_realm_admin
|
||||||
|
@ -174,7 +174,7 @@ def create_default_stream_group(
|
||||||
(stream, sub) = access_stream_by_name(user_profile, stream_name)
|
(stream, sub) = access_stream_by_name(user_profile, stream_name)
|
||||||
streams.append(stream)
|
streams.append(stream)
|
||||||
do_create_default_stream_group(user_profile.realm, group_name, description, streams)
|
do_create_default_stream_group(user_profile.realm, group_name, description, streams)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
@require_realm_admin
|
@require_realm_admin
|
||||||
|
@ -194,7 +194,7 @@ def update_default_stream_group_info(
|
||||||
do_change_default_stream_group_name(user_profile.realm, group, new_group_name)
|
do_change_default_stream_group_name(user_profile.realm, group, new_group_name)
|
||||||
if new_description is not None:
|
if new_description is not None:
|
||||||
do_change_default_stream_group_description(user_profile.realm, group, new_description)
|
do_change_default_stream_group_description(user_profile.realm, group, new_description)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
@require_realm_admin
|
@require_realm_admin
|
||||||
|
@ -218,7 +218,7 @@ def update_default_stream_group_streams(
|
||||||
do_remove_streams_from_default_stream_group(user_profile.realm, group, streams)
|
do_remove_streams_from_default_stream_group(user_profile.realm, group, streams)
|
||||||
else:
|
else:
|
||||||
raise JsonableError(_('Invalid value for "op". Specify one of "add" or "remove".'))
|
raise JsonableError(_('Invalid value for "op". Specify one of "add" or "remove".'))
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
@require_realm_admin
|
@require_realm_admin
|
||||||
|
@ -228,7 +228,7 @@ def remove_default_stream_group(
|
||||||
) -> HttpResponse:
|
) -> HttpResponse:
|
||||||
group = access_default_stream_group_by_id(user_profile.realm, group_id)
|
group = access_default_stream_group_by_id(user_profile.realm, group_id)
|
||||||
do_remove_default_stream_group(user_profile.realm, group)
|
do_remove_default_stream_group(user_profile.realm, group)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
@require_realm_admin
|
@require_realm_admin
|
||||||
|
@ -242,7 +242,7 @@ def remove_default_stream(
|
||||||
allow_realm_admin=True,
|
allow_realm_admin=True,
|
||||||
)
|
)
|
||||||
do_remove_default_stream(stream)
|
do_remove_default_stream(stream)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
@has_request_variables
|
@has_request_variables
|
||||||
|
@ -331,7 +331,7 @@ def update_stream_backend(
|
||||||
is_web_public=is_web_public,
|
is_web_public=is_web_public,
|
||||||
acting_user=user_profile,
|
acting_user=user_profile,
|
||||||
)
|
)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
@has_request_variables
|
@has_request_variables
|
||||||
|
@ -344,7 +344,7 @@ def list_subscriptions_backend(
|
||||||
user_profile,
|
user_profile,
|
||||||
include_subscribers=include_subscribers,
|
include_subscribers=include_subscribers,
|
||||||
)
|
)
|
||||||
return json_success({"subscriptions": subscribed})
|
return json_success(request, data={"subscriptions": subscribed})
|
||||||
|
|
||||||
|
|
||||||
add_subscriptions_schema = check_list(
|
add_subscriptions_schema = check_list(
|
||||||
|
@ -376,7 +376,7 @@ def update_subscriptions_backend(
|
||||||
]
|
]
|
||||||
data = compose_views(thunks)
|
data = compose_views(thunks)
|
||||||
|
|
||||||
return json_success(data)
|
return json_success(request, data)
|
||||||
|
|
||||||
|
|
||||||
def compose_views(thunks: List[Callable[[], HttpResponse]]) -> Dict[str, Any]:
|
def compose_views(thunks: List[Callable[[], HttpResponse]]) -> Dict[str, Any]:
|
||||||
|
@ -439,7 +439,7 @@ def remove_subscriptions_backend(
|
||||||
for (subscriber, not_subscribed_stream) in not_subscribed:
|
for (subscriber, not_subscribed_stream) in not_subscribed:
|
||||||
result["not_removed"].append(not_subscribed_stream.name)
|
result["not_removed"].append(not_subscribed_stream.name)
|
||||||
|
|
||||||
return json_success(result)
|
return json_success(request, data=result)
|
||||||
|
|
||||||
|
|
||||||
def you_were_just_subscribed_message(
|
def you_were_just_subscribed_message(
|
||||||
|
@ -586,7 +586,7 @@ def add_subscriptions_backend(
|
||||||
result["already_subscribed"] = dict(result["already_subscribed"])
|
result["already_subscribed"] = dict(result["already_subscribed"])
|
||||||
if not authorization_errors_fatal:
|
if not authorization_errors_fatal:
|
||||||
result["unauthorized"] = [s.name for s in unauthorized_streams]
|
result["unauthorized"] = [s.name for s in unauthorized_streams]
|
||||||
return json_success(result)
|
return json_success(request, data=result)
|
||||||
|
|
||||||
|
|
||||||
def send_messages_for_new_subscribers(
|
def send_messages_for_new_subscribers(
|
||||||
|
@ -708,7 +708,7 @@ def get_subscribers_backend(
|
||||||
)
|
)
|
||||||
subscribers = get_subscriber_ids(stream, user_profile)
|
subscribers = get_subscriber_ids(stream, user_profile)
|
||||||
|
|
||||||
return json_success({"subscribers": list(subscribers)})
|
return json_success(request, data={"subscribers": list(subscribers)})
|
||||||
|
|
||||||
|
|
||||||
# By default, lists all streams that the user has access to --
|
# By default, lists all streams that the user has access to --
|
||||||
|
@ -734,7 +734,7 @@ def get_streams_backend(
|
||||||
include_default=include_default,
|
include_default=include_default,
|
||||||
include_owner_subscribed=include_owner_subscribed,
|
include_owner_subscribed=include_owner_subscribed,
|
||||||
)
|
)
|
||||||
return json_success({"streams": streams})
|
return json_success(request, data={"streams": streams})
|
||||||
|
|
||||||
|
|
||||||
@has_request_variables
|
@has_request_variables
|
||||||
|
@ -771,7 +771,7 @@ def get_topics_backend(
|
||||||
public_history=stream.is_history_public_to_subscribers(),
|
public_history=stream.is_history_public_to_subscribers(),
|
||||||
)
|
)
|
||||||
|
|
||||||
return json_success(dict(topics=result))
|
return json_success(request, data=dict(topics=result))
|
||||||
|
|
||||||
|
|
||||||
@transaction.atomic
|
@transaction.atomic
|
||||||
|
@ -797,7 +797,7 @@ def delete_in_topic(
|
||||||
|
|
||||||
do_delete_messages(user_profile.realm, messages)
|
do_delete_messages(user_profile.realm, messages)
|
||||||
|
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
@require_post
|
@require_post
|
||||||
|
@ -829,7 +829,7 @@ def json_stream_exists(
|
||||||
)
|
)
|
||||||
result["subscribed"] = True
|
result["subscribed"] = True
|
||||||
|
|
||||||
return json_success(result) # results are ignored for HEAD requests
|
return json_success(request, data=result) # results are ignored for HEAD requests
|
||||||
|
|
||||||
|
|
||||||
@has_request_variables
|
@has_request_variables
|
||||||
|
@ -837,7 +837,7 @@ def json_get_stream_id(
|
||||||
request: HttpRequest, user_profile: UserProfile, stream_name: str = REQ("stream")
|
request: HttpRequest, user_profile: UserProfile, stream_name: str = REQ("stream")
|
||||||
) -> HttpResponse:
|
) -> HttpResponse:
|
||||||
(stream, sub) = access_stream_by_name(user_profile, stream_name)
|
(stream, sub) = access_stream_by_name(user_profile, stream_name)
|
||||||
return json_success({"stream_id": stream.id})
|
return json_success(request, data={"stream_id": stream.id})
|
||||||
|
|
||||||
|
|
||||||
@has_request_variables
|
@has_request_variables
|
||||||
|
@ -925,4 +925,4 @@ def update_subscription_properties_backend(
|
||||||
if len(request_notes.ignored_parameters) > 0:
|
if len(request_notes.ignored_parameters) > 0:
|
||||||
result["ignored_parameters_unsupported"] = list(request_notes.ignored_parameters)
|
result["ignored_parameters_unsupported"] = list(request_notes.ignored_parameters)
|
||||||
|
|
||||||
return json_success(result)
|
return json_success(request, data=result)
|
||||||
|
|
|
@ -60,4 +60,4 @@ def process_submessage(
|
||||||
msg_type=msg_type,
|
msg_type=msg_type,
|
||||||
content=content,
|
content=content,
|
||||||
)
|
)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
|
@ -17,4 +17,4 @@ def set_tutorial_status(
|
||||||
user_profile.tutorial_status = UserProfile.TUTORIAL_FINISHED
|
user_profile.tutorial_status = UserProfile.TUTORIAL_FINISHED
|
||||||
user_profile.save(update_fields=["tutorial_status"])
|
user_profile.save(update_fields=["tutorial_status"])
|
||||||
|
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
|
@ -54,4 +54,4 @@ def send_notification_backend(
|
||||||
user_ids = notification_to
|
user_ids = notification_to
|
||||||
check_send_typing_notification(user_profile, user_ids, operator)
|
check_send_typing_notification(user_profile, user_ids, operator)
|
||||||
|
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
|
@ -24,7 +24,7 @@ from zerver.models import UserProfile, validate_attachment_request
|
||||||
def serve_s3(request: HttpRequest, url_path: str, url_only: bool) -> HttpResponse:
|
def serve_s3(request: HttpRequest, url_path: str, url_only: bool) -> HttpResponse:
|
||||||
url = get_signed_upload_url(url_path)
|
url = get_signed_upload_url(url_path)
|
||||||
if url_only:
|
if url_only:
|
||||||
return json_success(dict(url=url))
|
return json_success(request, data=dict(url=url))
|
||||||
|
|
||||||
return redirect(url)
|
return redirect(url)
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ def serve_local(request: HttpRequest, path_id: str, url_only: bool) -> HttpRespo
|
||||||
|
|
||||||
if url_only:
|
if url_only:
|
||||||
url = generate_unauthed_file_access_url(path_id)
|
url = generate_unauthed_file_access_url(path_id)
|
||||||
return json_success(dict(url=url))
|
return json_success(request, data=dict(url=url))
|
||||||
|
|
||||||
# Here we determine whether a browser should treat the file like
|
# Here we determine whether a browser should treat the file like
|
||||||
# an attachment (and thus clicking a link to it should download)
|
# an attachment (and thus clicking a link to it should download)
|
||||||
|
@ -129,4 +129,4 @@ def upload_file_backend(request: HttpRequest, user_profile: UserProfile) -> Http
|
||||||
check_upload_within_quota(user_profile.realm, file_size)
|
check_upload_within_quota(user_profile.realm, file_size)
|
||||||
|
|
||||||
uri = upload_message_image_from_request(request, user_file, user_profile)
|
uri = upload_message_image_from_request(request, user_file, user_profile)
|
||||||
return json_success({"uri": uri})
|
return json_success(request, data={"uri": uri})
|
||||||
|
|
|
@ -38,14 +38,14 @@ def add_user_group(
|
||||||
) -> HttpResponse:
|
) -> HttpResponse:
|
||||||
user_profiles = user_ids_to_users(members, user_profile.realm)
|
user_profiles = user_ids_to_users(members, user_profile.realm)
|
||||||
check_add_user_group(user_profile.realm, name, user_profiles, description)
|
check_add_user_group(user_profile.realm, name, user_profiles, description)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
@require_member_or_admin
|
@require_member_or_admin
|
||||||
@has_request_variables
|
@has_request_variables
|
||||||
def get_user_group(request: HttpRequest, user_profile: UserProfile) -> HttpResponse:
|
def get_user_group(request: HttpRequest, user_profile: UserProfile) -> HttpResponse:
|
||||||
user_groups = user_groups_in_realm_serialized(user_profile.realm)
|
user_groups = user_groups_in_realm_serialized(user_profile.realm)
|
||||||
return json_success({"user_groups": user_groups})
|
return json_success(request, data={"user_groups": user_groups})
|
||||||
|
|
||||||
|
|
||||||
@require_user_group_edit_permission
|
@require_user_group_edit_permission
|
||||||
|
@ -68,7 +68,7 @@ def edit_user_group(
|
||||||
if description != user_group.description:
|
if description != user_group.description:
|
||||||
do_update_user_group_description(user_group, description)
|
do_update_user_group_description(user_group, description)
|
||||||
|
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
@require_user_group_edit_permission
|
@require_user_group_edit_permission
|
||||||
|
@ -80,7 +80,7 @@ def delete_user_group(
|
||||||
) -> HttpResponse:
|
) -> HttpResponse:
|
||||||
|
|
||||||
check_delete_user_group(user_group_id, user_profile)
|
check_delete_user_group(user_group_id, user_profile)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
@require_user_group_edit_permission
|
@require_user_group_edit_permission
|
||||||
|
@ -105,14 +105,14 @@ def update_user_group_backend(
|
||||||
]
|
]
|
||||||
data = compose_views(thunks)
|
data = compose_views(thunks)
|
||||||
|
|
||||||
return json_success(data)
|
return json_success(request, data)
|
||||||
|
|
||||||
|
|
||||||
def add_members_to_group_backend(
|
def add_members_to_group_backend(
|
||||||
request: HttpRequest, user_profile: UserProfile, user_group_id: int, members: Sequence[int]
|
request: HttpRequest, user_profile: UserProfile, user_group_id: int, members: Sequence[int]
|
||||||
) -> HttpResponse:
|
) -> HttpResponse:
|
||||||
if not members:
|
if not members:
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
user_group = access_user_group_by_id(user_group_id, user_profile)
|
user_group = access_user_group_by_id(user_group_id, user_profile)
|
||||||
user_profiles = user_ids_to_users(members, user_profile.realm)
|
user_profiles = user_ids_to_users(members, user_profile.realm)
|
||||||
|
@ -127,14 +127,14 @@ def add_members_to_group_backend(
|
||||||
)
|
)
|
||||||
|
|
||||||
bulk_add_members_to_user_group(user_group, user_profiles)
|
bulk_add_members_to_user_group(user_group, user_profiles)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
def remove_members_from_group_backend(
|
def remove_members_from_group_backend(
|
||||||
request: HttpRequest, user_profile: UserProfile, user_group_id: int, members: Sequence[int]
|
request: HttpRequest, user_profile: UserProfile, user_group_id: int, members: Sequence[int]
|
||||||
) -> HttpResponse:
|
) -> HttpResponse:
|
||||||
if not members:
|
if not members:
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
user_profiles = user_ids_to_users(members, user_profile.realm)
|
user_profiles = user_ids_to_users(members, user_profile.realm)
|
||||||
user_group = access_user_group_by_id(user_group_id, user_profile)
|
user_group = access_user_group_by_id(user_group_id, user_profile)
|
||||||
|
@ -144,4 +144,4 @@ def remove_members_from_group_backend(
|
||||||
raise JsonableError(_("There is no member '{}' in this user group").format(member))
|
raise JsonableError(_("There is no member '{}' in this user group").format(member))
|
||||||
|
|
||||||
remove_members_from_user_group(user_group, user_profiles)
|
remove_members_from_user_group(user_group, user_profiles)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
|
@ -315,7 +315,7 @@ def json_change_settings(
|
||||||
if len(request_notes.ignored_parameters) > 0:
|
if len(request_notes.ignored_parameters) > 0:
|
||||||
result["ignored_parameters_unsupported"] = list(request_notes.ignored_parameters)
|
result["ignored_parameters_unsupported"] = list(request_notes.ignored_parameters)
|
||||||
|
|
||||||
return json_success(result)
|
return json_success(request, data=result)
|
||||||
|
|
||||||
|
|
||||||
def set_avatar_backend(request: HttpRequest, user_profile: UserProfile) -> HttpResponse:
|
def set_avatar_backend(request: HttpRequest, user_profile: UserProfile) -> HttpResponse:
|
||||||
|
@ -339,7 +339,7 @@ def set_avatar_backend(request: HttpRequest, user_profile: UserProfile) -> HttpR
|
||||||
json_result = dict(
|
json_result = dict(
|
||||||
avatar_url=user_avatar_url,
|
avatar_url=user_avatar_url,
|
||||||
)
|
)
|
||||||
return json_success(json_result)
|
return json_success(request, data=json_result)
|
||||||
|
|
||||||
|
|
||||||
def delete_avatar_backend(request: HttpRequest, user_profile: UserProfile) -> HttpResponse:
|
def delete_avatar_backend(request: HttpRequest, user_profile: UserProfile) -> HttpResponse:
|
||||||
|
@ -354,7 +354,7 @@ def delete_avatar_backend(request: HttpRequest, user_profile: UserProfile) -> Ht
|
||||||
json_result = dict(
|
json_result = dict(
|
||||||
avatar_url=gravatar_url,
|
avatar_url=gravatar_url,
|
||||||
)
|
)
|
||||||
return json_success(json_result)
|
return json_success(request, data=json_result)
|
||||||
|
|
||||||
|
|
||||||
# We don't use @human_users_only here, because there are use cases for
|
# We don't use @human_users_only here, because there are use cases for
|
||||||
|
@ -365,4 +365,4 @@ def regenerate_api_key(request: HttpRequest, user_profile: UserProfile) -> HttpR
|
||||||
json_result = dict(
|
json_result = dict(
|
||||||
api_key=new_api_key,
|
api_key=new_api_key,
|
||||||
)
|
)
|
||||||
return json_success(json_result)
|
return json_success(request, data=json_result)
|
||||||
|
|
|
@ -114,7 +114,7 @@ def deactivate_user_own_backend(request: HttpRequest, user_profile: UserProfile)
|
||||||
raise CannotDeactivateLastUserError(is_last_owner=True)
|
raise CannotDeactivateLastUserError(is_last_owner=True)
|
||||||
|
|
||||||
do_deactivate_user(user_profile, acting_user=user_profile)
|
do_deactivate_user(user_profile, acting_user=user_profile)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
def deactivate_bot_backend(
|
def deactivate_bot_backend(
|
||||||
|
@ -128,7 +128,7 @@ def _deactivate_user_profile_backend(
|
||||||
request: HttpRequest, user_profile: UserProfile, target: UserProfile
|
request: HttpRequest, user_profile: UserProfile, target: UserProfile
|
||||||
) -> HttpResponse:
|
) -> HttpResponse:
|
||||||
do_deactivate_user(target, acting_user=user_profile)
|
do_deactivate_user(target, acting_user=user_profile)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
def reactivate_user_backend(
|
def reactivate_user_backend(
|
||||||
|
@ -141,7 +141,7 @@ def reactivate_user_backend(
|
||||||
assert target.bot_type is not None
|
assert target.bot_type is not None
|
||||||
check_bot_creation_policy(user_profile, target.bot_type)
|
check_bot_creation_policy(user_profile, target.bot_type)
|
||||||
do_reactivate_user(target, acting_user=user_profile)
|
do_reactivate_user(target, acting_user=user_profile)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
check_profile_data: Validator[
|
check_profile_data: Validator[
|
||||||
|
@ -218,7 +218,7 @@ def update_user_backend(
|
||||||
validate_user_custom_profile_data(target.realm.id, clean_profile_data)
|
validate_user_custom_profile_data(target.realm.id, clean_profile_data)
|
||||||
do_update_user_custom_profile_data_if_changed(target, clean_profile_data)
|
do_update_user_custom_profile_data_if_changed(target, clean_profile_data)
|
||||||
|
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
def avatar(
|
def avatar(
|
||||||
|
@ -366,7 +366,7 @@ def patch_bot_backend(
|
||||||
if bot.bot_owner is not None:
|
if bot.bot_owner is not None:
|
||||||
json_result["bot_owner"] = bot.bot_owner.email
|
json_result["bot_owner"] = bot.bot_owner.email
|
||||||
|
|
||||||
return json_success(json_result)
|
return json_success(request, data=json_result)
|
||||||
|
|
||||||
|
|
||||||
@require_member_or_admin
|
@require_member_or_admin
|
||||||
|
@ -380,7 +380,7 @@ def regenerate_bot_api_key(
|
||||||
json_result = dict(
|
json_result = dict(
|
||||||
api_key=new_api_key,
|
api_key=new_api_key,
|
||||||
)
|
)
|
||||||
return json_success(json_result)
|
return json_success(request, data=json_result)
|
||||||
|
|
||||||
|
|
||||||
@require_member_or_admin
|
@require_member_or_admin
|
||||||
|
@ -511,7 +511,7 @@ def add_bot_backend(
|
||||||
default_events_register_stream=get_stream_name(bot_profile.default_events_register_stream),
|
default_events_register_stream=get_stream_name(bot_profile.default_events_register_stream),
|
||||||
default_all_public_streams=bot_profile.default_all_public_streams,
|
default_all_public_streams=bot_profile.default_all_public_streams,
|
||||||
)
|
)
|
||||||
return json_success(json_result)
|
return json_success(request, data=json_result)
|
||||||
|
|
||||||
|
|
||||||
@require_member_or_admin
|
@require_member_or_admin
|
||||||
|
@ -541,7 +541,7 @@ def get_bots_backend(request: HttpRequest, user_profile: UserProfile) -> HttpRes
|
||||||
default_all_public_streams=bot_profile.default_all_public_streams,
|
default_all_public_streams=bot_profile.default_all_public_streams,
|
||||||
)
|
)
|
||||||
|
|
||||||
return json_success({"bots": list(map(bot_info, bot_profiles))})
|
return json_success(request, data={"bots": list(map(bot_info, bot_profiles))})
|
||||||
|
|
||||||
|
|
||||||
@has_request_variables
|
@has_request_variables
|
||||||
|
@ -583,7 +583,7 @@ def get_members_backend(
|
||||||
else:
|
else:
|
||||||
data = {"members": [members[k] for k in members]}
|
data = {"members": [members[k] for k in members]}
|
||||||
|
|
||||||
return json_success(data)
|
return json_success(request, data)
|
||||||
|
|
||||||
|
|
||||||
@require_realm_admin
|
@require_realm_admin
|
||||||
|
@ -630,7 +630,7 @@ def create_user_backend(
|
||||||
raise JsonableError(PASSWORD_TOO_WEAK_ERROR)
|
raise JsonableError(PASSWORD_TOO_WEAK_ERROR)
|
||||||
|
|
||||||
target_user = do_create_user(email, password, realm, full_name, acting_user=user_profile)
|
target_user = do_create_user(email, password, realm, full_name, acting_user=user_profile)
|
||||||
return json_success({"user_id": target_user.id})
|
return json_success(request, data={"user_id": target_user.id})
|
||||||
|
|
||||||
|
|
||||||
def get_profile_backend(request: HttpRequest, user_profile: UserProfile) -> HttpResponse:
|
def get_profile_backend(request: HttpRequest, user_profile: UserProfile) -> HttpResponse:
|
||||||
|
@ -649,7 +649,7 @@ def get_profile_backend(request: HttpRequest, user_profile: UserProfile) -> Http
|
||||||
if messages:
|
if messages:
|
||||||
result["max_message_id"] = messages[0].id
|
result["max_message_id"] = messages[0].id
|
||||||
|
|
||||||
return json_success(result)
|
return json_success(request, data=result)
|
||||||
|
|
||||||
|
|
||||||
@has_request_variables
|
@has_request_variables
|
||||||
|
@ -664,7 +664,7 @@ def get_subscription_backend(
|
||||||
|
|
||||||
subscription_status = {"is_subscribed": subscribed_to_stream(target_user, stream_id)}
|
subscription_status = {"is_subscribed": subscribed_to_stream(target_user, stream_id)}
|
||||||
|
|
||||||
return json_success(subscription_status)
|
return json_success(request, data=subscription_status)
|
||||||
|
|
||||||
|
|
||||||
@has_request_variables
|
@has_request_variables
|
||||||
|
|
|
@ -158,14 +158,14 @@ def make_zoom_video_call(request: HttpRequest, user: UserProfile) -> HttpRespons
|
||||||
elif not res.ok:
|
elif not res.ok:
|
||||||
raise JsonableError(_("Failed to create Zoom call"))
|
raise JsonableError(_("Failed to create Zoom call"))
|
||||||
|
|
||||||
return json_success({"url": res.json()["join_url"]})
|
return json_success(request, data={"url": res.json()["join_url"]})
|
||||||
|
|
||||||
|
|
||||||
@csrf_exempt
|
@csrf_exempt
|
||||||
@require_POST
|
@require_POST
|
||||||
@has_request_variables
|
@has_request_variables
|
||||||
def deauthorize_zoom_user(request: HttpRequest) -> HttpResponse:
|
def deauthorize_zoom_user(request: HttpRequest) -> HttpResponse:
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
def get_bigbluebutton_url(request: HttpRequest, user_profile: UserProfile) -> HttpResponse:
|
def get_bigbluebutton_url(request: HttpRequest, user_profile: UserProfile) -> HttpResponse:
|
||||||
|
@ -196,7 +196,7 @@ def get_bigbluebutton_url(request: HttpRequest, user_profile: UserProfile) -> Ht
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
return json_success({"url": url})
|
return json_success(request, data={"url": url})
|
||||||
|
|
||||||
|
|
||||||
# We use zulip_login_required here mainly to get access to the user's
|
# We use zulip_login_required here mainly to get access to the user's
|
||||||
|
|
|
@ -74,4 +74,4 @@ def webathena_kerberos_login(
|
||||||
logging.exception("Error updating the user's ccache", stack_info=True)
|
logging.exception("Error updating the user's ccache", stack_info=True)
|
||||||
raise JsonableError(_("We were unable to set up mirroring for you"))
|
raise JsonableError(_("We were unable to set up mirroring for you"))
|
||||||
|
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
|
@ -23,7 +23,7 @@ def api_airbrake_webhook(
|
||||||
subject = get_subject(payload)
|
subject = get_subject(payload)
|
||||||
body = get_body(payload)
|
body = get_body(payload)
|
||||||
check_send_webhook_message(request, user_profile, subject, body)
|
check_send_webhook_message(request, user_profile, subject, body)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
def get_subject(payload: Dict[str, Any]) -> str:
|
def get_subject(payload: Dict[str, Any]) -> str:
|
||||||
|
|
|
@ -55,4 +55,4 @@ def api_alertmanager_webhook(
|
||||||
|
|
||||||
check_send_webhook_message(request, user_profile, topic, body)
|
check_send_webhook_message(request, user_profile, topic, body)
|
||||||
|
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
|
@ -32,7 +32,7 @@ def api_ansibletower_webhook(
|
||||||
subject = payload["name"]
|
subject = payload["name"]
|
||||||
|
|
||||||
check_send_webhook_message(request, user_profile, subject, body)
|
check_send_webhook_message(request, user_profile, subject, body)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
def extract_friendly_name(payload: Dict[str, Any]) -> str:
|
def extract_friendly_name(payload: Dict[str, Any]) -> str:
|
||||||
|
|
|
@ -25,7 +25,7 @@ def api_appfollow_webhook(
|
||||||
topic = app_name
|
topic = app_name
|
||||||
|
|
||||||
check_send_webhook_message(request, user_profile, topic, body=convert_markdown(message))
|
check_send_webhook_message(request, user_profile, topic, body=convert_markdown(message))
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
def convert_markdown(text: str) -> str:
|
def convert_markdown(text: str) -> str:
|
||||||
|
|
|
@ -29,7 +29,7 @@ def api_appveyor_webhook(
|
||||||
subject = get_subject_for_http_request(payload)
|
subject = get_subject_for_http_request(payload)
|
||||||
|
|
||||||
check_send_webhook_message(request, user_profile, subject, body)
|
check_send_webhook_message(request, user_profile, subject, body)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
def get_subject_for_http_request(payload: Dict[str, Any]) -> str:
|
def get_subject_for_http_request(payload: Dict[str, Any]) -> str:
|
||||||
|
|
|
@ -75,7 +75,7 @@ def api_basecamp_webhook(
|
||||||
raise UnsupportedWebhookEventType(event)
|
raise UnsupportedWebhookEventType(event)
|
||||||
|
|
||||||
check_send_webhook_message(request, user_profile, subject, body, event)
|
check_send_webhook_message(request, user_profile, subject, body, event)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
def get_project_name(payload: Dict[str, Any]) -> str:
|
def get_project_name(payload: Dict[str, Any]) -> str:
|
||||||
|
|
|
@ -88,7 +88,7 @@ def api_beanstalk_webhook(
|
||||||
git_repo = "uri" in payload
|
git_repo = "uri" in payload
|
||||||
if git_repo:
|
if git_repo:
|
||||||
if branches is not None and branches.find(payload["branch"]) == -1:
|
if branches is not None and branches.find(payload["branch"]) == -1:
|
||||||
return json_success()
|
return json_success(request)
|
||||||
# To get a linkable url,
|
# To get a linkable url,
|
||||||
for commit in payload["commits"]:
|
for commit in payload["commits"]:
|
||||||
commit["author"] = {"username": commit["author"]["name"]}
|
commit["author"] = {"username": commit["author"]["name"]}
|
||||||
|
@ -113,4 +113,4 @@ def api_beanstalk_webhook(
|
||||||
content = f"{author} pushed [revision {revision}]({url}):\n\n> {short_commit_msg}"
|
content = f"{author} pushed [revision {revision}]({url}):\n\n> {short_commit_msg}"
|
||||||
|
|
||||||
check_send_webhook_message(request, user_profile, subject, content)
|
check_send_webhook_message(request, user_profile, subject, content)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
|
@ -50,4 +50,4 @@ def api_beeminder_webhook(
|
||||||
expression=expression,
|
expression=expression,
|
||||||
)
|
)
|
||||||
check_send_webhook_message(request, user_profile, topic, body)
|
check_send_webhook_message(request, user_profile, topic, body)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
|
@ -44,7 +44,7 @@ def api_bitbucket_webhook(
|
||||||
else:
|
else:
|
||||||
branch = payload["commits"][-1]["branch"]
|
branch = payload["commits"][-1]["branch"]
|
||||||
if branches is not None and branches.find(branch) == -1:
|
if branches is not None and branches.find(branch) == -1:
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
committer = payload.get("user")
|
committer = payload.get("user")
|
||||||
content = get_push_commits_event_message(
|
content = get_push_commits_event_message(
|
||||||
|
@ -53,4 +53,4 @@ def api_bitbucket_webhook(
|
||||||
subject = TOPIC_WITH_BRANCH_TEMPLATE.format(repo=repository["name"], branch=branch)
|
subject = TOPIC_WITH_BRANCH_TEMPLATE.format(repo=repository["name"], branch=branch)
|
||||||
|
|
||||||
check_send_webhook_message(request, user_profile, subject, content, unquote_url_parameters=True)
|
check_send_webhook_message(request, user_profile, subject, content, unquote_url_parameters=True)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
|
@ -87,11 +87,11 @@ def api_bitbucket2_webhook(
|
||||||
if type == "push":
|
if type == "push":
|
||||||
# ignore push events with no changes
|
# ignore push events with no changes
|
||||||
if not payload["push"]["changes"]:
|
if not payload["push"]["changes"]:
|
||||||
return json_success()
|
return json_success(request)
|
||||||
branch = get_branch_name_for_push_event(payload)
|
branch = get_branch_name_for_push_event(payload)
|
||||||
if branch and branches:
|
if branch and branches:
|
||||||
if branches.find(branch) == -1:
|
if branches.find(branch) == -1:
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
subject = get_subject_based_on_type(payload, type)
|
subject = get_subject_based_on_type(payload, type)
|
||||||
body_function = get_body_based_on_type(type)
|
body_function = get_body_based_on_type(type)
|
||||||
|
@ -113,7 +113,7 @@ def api_bitbucket2_webhook(
|
||||||
request, user_profile, s, b, type, unquote_url_parameters=True
|
request, user_profile, s, b, type, unquote_url_parameters=True
|
||||||
)
|
)
|
||||||
|
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
def get_subject_for_branch_specified_events(
|
def get_subject_for_branch_specified_events(
|
||||||
|
|
|
@ -416,4 +416,4 @@ def api_bitbucket3_webhook(
|
||||||
unquote_url_parameters=True,
|
unquote_url_parameters=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
|
@ -23,7 +23,7 @@ def api_buildbot_webhook(
|
||||||
topic = "general"
|
topic = "general"
|
||||||
body = get_message(payload)
|
body = get_message(payload)
|
||||||
check_send_webhook_message(request, user_profile, topic, body, payload["event"])
|
check_send_webhook_message(request, user_profile, topic, body, payload["event"])
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
def get_message(payload: Dict[str, Any]) -> str:
|
def get_message(payload: Dict[str, Any]) -> str:
|
||||||
|
|
|
@ -37,4 +37,4 @@ def api_canarytoken_webhook(
|
||||||
topic = user_specified_topic
|
topic = user_specified_topic
|
||||||
|
|
||||||
check_send_webhook_message(request, user_profile, topic, body)
|
check_send_webhook_message(request, user_profile, topic, body)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
|
@ -35,7 +35,7 @@ def api_circleci_webhook(
|
||||||
body,
|
body,
|
||||||
payload.get("status") if not payload.get("build_num") else payload.get("outcome"),
|
payload.get("status") if not payload.get("build_num") else payload.get("outcome"),
|
||||||
)
|
)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
def get_subject(payload: Dict[str, Any]) -> str:
|
def get_subject(payload: Dict[str, Any]) -> str:
|
||||||
|
|
|
@ -723,7 +723,7 @@ def api_clubhouse_webhook(
|
||||||
# such requests correspond to. So, it is best to ignore such
|
# such requests correspond to. So, it is best to ignore such
|
||||||
# requests for now.
|
# requests for now.
|
||||||
if payload is None:
|
if payload is None:
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
if payload.get("primary_id") is not None:
|
if payload.get("primary_id") is not None:
|
||||||
action = get_action_with_primary_id(payload)
|
action = get_action_with_primary_id(payload)
|
||||||
|
@ -743,4 +743,4 @@ def api_clubhouse_webhook(
|
||||||
else:
|
else:
|
||||||
send_stream_messages_for_actions(request, user_profile, payload, primary_action, event)
|
send_stream_messages_for_actions(request, user_profile, payload, primary_action, event)
|
||||||
|
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
|
@ -34,7 +34,7 @@ def api_codeship_webhook(
|
||||||
body = get_body_for_http_request(payload)
|
body = get_body_for_http_request(payload)
|
||||||
|
|
||||||
check_send_webhook_message(request, user_profile, subject, body)
|
check_send_webhook_message(request, user_profile, subject, body)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
def get_subject_for_http_request(payload: Dict[str, Any]) -> str:
|
def get_subject_for_http_request(payload: Dict[str, Any]) -> str:
|
||||||
|
|
|
@ -41,4 +41,4 @@ def api_crashlytics_webhook(
|
||||||
)
|
)
|
||||||
|
|
||||||
check_send_webhook_message(request, user_profile, subject, body)
|
check_send_webhook_message(request, user_profile, subject, body)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
|
@ -49,4 +49,4 @@ def api_delighted_webhook(
|
||||||
topic = "Survey response"
|
topic = "Survey response"
|
||||||
|
|
||||||
check_send_webhook_message(request, user_profile, topic, body)
|
check_send_webhook_message(request, user_profile, topic, body)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
|
@ -20,4 +20,4 @@ def api_deskdotcom_webhook(
|
||||||
) -> HttpResponse:
|
) -> HttpResponse:
|
||||||
topic = "Desk.com notification"
|
topic = "Desk.com notification"
|
||||||
check_send_webhook_message(request, user_profile, topic, data)
|
check_send_webhook_message(request, user_profile, topic, data)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
|
@ -38,4 +38,4 @@ def api_dialogflow_webhook(
|
||||||
client = RequestNotes.get_notes(request).client
|
client = RequestNotes.get_notes(request).client
|
||||||
assert client is not None
|
assert client is not None
|
||||||
check_send_private_message(user_profile, client, receiving_user, body)
|
check_send_private_message(user_profile, client, receiving_user, body)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
|
@ -21,7 +21,7 @@ def api_dropbox_webhook(
|
||||||
check_send_webhook_message(
|
check_send_webhook_message(
|
||||||
request, user_profile, topic, "File has been updated on Dropbox!"
|
request, user_profile, topic, "File has been updated on Dropbox!"
|
||||||
)
|
)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
else:
|
else:
|
||||||
if challenge is None:
|
if challenge is None:
|
||||||
raise RequestVariableMissingError("challenge")
|
raise RequestVariableMissingError("challenge")
|
||||||
|
|
|
@ -22,7 +22,7 @@ def api_errbit_webhook(
|
||||||
subject = get_subject(payload)
|
subject = get_subject(payload)
|
||||||
body = get_body(payload)
|
body = get_body(payload)
|
||||||
check_send_webhook_message(request, user_profile, subject, body)
|
check_send_webhook_message(request, user_profile, subject, body)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
def get_subject(payload: Dict[str, Any]) -> str:
|
def get_subject(payload: Dict[str, Any]) -> str:
|
||||||
|
|
|
@ -28,4 +28,4 @@ def api_flock_webhook(
|
||||||
|
|
||||||
check_send_webhook_message(request, user_profile, topic, body)
|
check_send_webhook_message(request, user_profile, topic, body)
|
||||||
|
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
|
@ -164,7 +164,7 @@ def api_freshdesk_webhook(
|
||||||
content = format_freshdesk_property_change_message(ticket, event_info)
|
content = format_freshdesk_property_change_message(ticket, event_info)
|
||||||
else:
|
else:
|
||||||
# Not an event we know handle; do nothing.
|
# Not an event we know handle; do nothing.
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
check_send_webhook_message(request, user_profile, subject, content)
|
check_send_webhook_message(request, user_profile, subject, content)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
|
@ -33,7 +33,7 @@ def api_freshping_webhook(
|
||||||
check_send_webhook_message(
|
check_send_webhook_message(
|
||||||
request, user_profile, subject, body, payload["webhook_event_data"]["check_state_name"]
|
request, user_profile, subject, body, payload["webhook_event_data"]["check_state_name"]
|
||||||
)
|
)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
def get_subject_for_http_request(payload: Dict[str, Any]) -> str:
|
def get_subject_for_http_request(payload: Dict[str, Any]) -> str:
|
||||||
|
|
|
@ -99,7 +99,7 @@ def api_freshstatus_webhook(
|
||||||
check_send_webhook_message(
|
check_send_webhook_message(
|
||||||
request, user_profile, subject, body, payload["event_data"]["event_type"]
|
request, user_profile, subject, body, payload["event_data"]["event_type"]
|
||||||
)
|
)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
def get_services_content(services_data: List[Dict[str, Any]]) -> str:
|
def get_services_content(services_data: List[Dict[str, Any]]) -> str:
|
||||||
|
|
|
@ -152,4 +152,4 @@ def api_front_webhook(
|
||||||
body = get_body_based_on_event(event)(payload)
|
body = get_body_based_on_event(event)(payload)
|
||||||
check_send_webhook_message(request, user_profile, topic, body, event)
|
check_send_webhook_message(request, user_profile, topic, body, event)
|
||||||
|
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
|
@ -144,7 +144,7 @@ def api_gci_webhook(
|
||||||
)
|
)
|
||||||
check_send_webhook_message(request, user_profile, subject, body, event)
|
check_send_webhook_message(request, user_profile, subject, body, event)
|
||||||
|
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
def get_event(payload: Dict[str, Any]) -> Optional[str]:
|
def get_event(payload: Dict[str, Any]) -> Optional[str]:
|
||||||
|
|
|
@ -733,7 +733,7 @@ def api_github_webhook(
|
||||||
# This is nothing to worry about--get_event() returns None
|
# This is nothing to worry about--get_event() returns None
|
||||||
# for events that are valid but not yet handled by us.
|
# for events that are valid but not yet handled by us.
|
||||||
# See IGNORED_EVENTS, for example.
|
# See IGNORED_EVENTS, for example.
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
subject = get_subject_based_on_type(payload, event)
|
subject = get_subject_based_on_type(payload, event)
|
||||||
|
|
||||||
|
@ -746,7 +746,7 @@ def api_github_webhook(
|
||||||
body = body_function(helper)
|
body = body_function(helper)
|
||||||
|
|
||||||
check_send_webhook_message(request, user_profile, subject, body, event)
|
check_send_webhook_message(request, user_profile, subject, body, event)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
def get_zulip_event_name(
|
def get_zulip_event_name(
|
||||||
|
|
|
@ -421,7 +421,7 @@ def api_gitlab_webhook(
|
||||||
|
|
||||||
topic = get_subject_based_on_event(event, payload, use_merge_request_title)
|
topic = get_subject_based_on_event(event, payload, use_merge_request_title)
|
||||||
check_send_webhook_message(request, user_profile, topic, body, event)
|
check_send_webhook_message(request, user_profile, topic, body, event)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
def get_body_based_on_event(event: str) -> Any:
|
def get_body_based_on_event(event: str) -> Any:
|
||||||
|
|
|
@ -53,4 +53,4 @@ def api_gocd_webhook(
|
||||||
|
|
||||||
check_send_webhook_message(request, user_profile, topic, body)
|
check_send_webhook_message(request, user_profile, topic, body)
|
||||||
|
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
|
@ -171,7 +171,7 @@ def gogs_webhook_main(
|
||||||
if event == "push":
|
if event == "push":
|
||||||
branch = payload["ref"].replace("refs/heads/", "")
|
branch = payload["ref"].replace("refs/heads/", "")
|
||||||
if branches is not None and branch not in branches.split(","):
|
if branches is not None and branch not in branches.split(","):
|
||||||
return json_success()
|
return json_success(request)
|
||||||
body = format_push_event(payload)
|
body = format_push_event(payload)
|
||||||
topic = TOPIC_WITH_BRANCH_TEMPLATE.format(
|
topic = TOPIC_WITH_BRANCH_TEMPLATE.format(
|
||||||
repo=repo,
|
repo=repo,
|
||||||
|
@ -231,4 +231,4 @@ def gogs_webhook_main(
|
||||||
raise UnsupportedWebhookEventType(event)
|
raise UnsupportedWebhookEventType(event)
|
||||||
|
|
||||||
check_send_webhook_message(request, user_profile, topic, body, event)
|
check_send_webhook_message(request, user_profile, topic, body, event)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
|
@ -61,4 +61,4 @@ def api_gosquared_webhook(
|
||||||
else:
|
else:
|
||||||
raise UnsupportedWebhookEventType("unknown_event")
|
raise UnsupportedWebhookEventType("unknown_event")
|
||||||
|
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
|
@ -71,4 +71,4 @@ def api_grafana_webhook(
|
||||||
# send the message
|
# send the message
|
||||||
check_send_webhook_message(request, user_profile, topic, body, payload.get("state"))
|
check_send_webhook_message(request, user_profile, topic, body, payload.get("state"))
|
||||||
|
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
|
@ -39,7 +39,7 @@ def api_greenhouse_webhook(
|
||||||
payload: Dict[str, Any] = REQ(argument_type="body"),
|
payload: Dict[str, Any] = REQ(argument_type="body"),
|
||||||
) -> HttpResponse:
|
) -> HttpResponse:
|
||||||
if payload["action"] == "ping":
|
if payload["action"] == "ping":
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
if payload["action"] == "update_candidate":
|
if payload["action"] == "update_candidate":
|
||||||
candidate = payload["payload"]["candidate"]
|
candidate = payload["payload"]["candidate"]
|
||||||
|
@ -61,4 +61,4 @@ def api_greenhouse_webhook(
|
||||||
topic = "{} - {}".format(action, str(candidate["id"]))
|
topic = "{} - {}".format(action, str(candidate["id"]))
|
||||||
|
|
||||||
check_send_webhook_message(request, user_profile, topic, body)
|
check_send_webhook_message(request, user_profile, topic, body)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
|
@ -109,7 +109,7 @@ def api_groove_webhook(
|
||||||
if body is not None:
|
if body is not None:
|
||||||
check_send_webhook_message(request, user_profile, topic, body, event)
|
check_send_webhook_message(request, user_profile, topic, body, event)
|
||||||
|
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
fixture_to_headers = get_http_headers_from_filename("HTTP_X_GROOVE_EVENT")
|
fixture_to_headers = get_http_headers_from_filename("HTTP_X_GROOVE_EVENT")
|
||||||
|
|
|
@ -106,7 +106,7 @@ def api_harbor_webhook(
|
||||||
topic = payload["event_data"]["repository"]["repo_full_name"]
|
topic = payload["event_data"]["repository"]["repo_full_name"]
|
||||||
|
|
||||||
if event in IGNORED_EVENTS:
|
if event in IGNORED_EVENTS:
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
content_func = EVENT_FUNCTION_MAPPER.get(event)
|
content_func = EVENT_FUNCTION_MAPPER.get(event)
|
||||||
|
|
||||||
|
@ -118,4 +118,4 @@ def api_harbor_webhook(
|
||||||
check_send_webhook_message(
|
check_send_webhook_message(
|
||||||
request, user_profile, topic, content, event, unquote_url_parameters=True
|
request, user_profile, topic, content, event, unquote_url_parameters=True
|
||||||
)
|
)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
|
@ -66,4 +66,4 @@ def api_hellosign_webhook(
|
||||||
topic = payload["signature_request"]["title"]
|
topic = payload["signature_request"]["title"]
|
||||||
check_send_webhook_message(request, user_profile, topic, body)
|
check_send_webhook_message(request, user_profile, topic, body)
|
||||||
|
|
||||||
return json_success({"msg": "Hello API Event Received"})
|
return json_success(request, data={"msg": "Hello API Event Received"})
|
||||||
|
|
|
@ -32,4 +32,4 @@ def api_helloworld_webhook(
|
||||||
# send the message
|
# send the message
|
||||||
check_send_webhook_message(request, user_profile, topic, body)
|
check_send_webhook_message(request, user_profile, topic, body)
|
||||||
|
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
|
@ -30,4 +30,4 @@ def api_heroku_webhook(
|
||||||
content = TEMPLATE.format(user=user, head=head, app=app, url=url, git_log=git_log)
|
content = TEMPLATE.format(user=user, head=head, app=app, url=url, git_log=git_log)
|
||||||
|
|
||||||
check_send_webhook_message(request, user_profile, app, content)
|
check_send_webhook_message(request, user_profile, app, content)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
|
@ -30,4 +30,4 @@ def api_homeassistant_webhook(
|
||||||
check_send_webhook_message(request, user_profile, topic, body)
|
check_send_webhook_message(request, user_profile, topic, body)
|
||||||
|
|
||||||
# return json result
|
# return json result
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
|
@ -36,4 +36,4 @@ def api_iftt_app_webhook(
|
||||||
raise JsonableError(_("Content must be a string"))
|
raise JsonableError(_("Content must be a string"))
|
||||||
|
|
||||||
check_send_webhook_message(request, user_profile, topic, content)
|
check_send_webhook_message(request, user_profile, topic, content)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
|
@ -45,4 +45,4 @@ def api_insping_webhook(
|
||||||
|
|
||||||
check_send_webhook_message(request, user_profile, topic, body)
|
check_send_webhook_message(request, user_profile, topic, body)
|
||||||
|
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
|
@ -313,7 +313,7 @@ def api_intercom_webhook(
|
||||||
) -> HttpResponse:
|
) -> HttpResponse:
|
||||||
event_type = payload["topic"]
|
event_type = payload["topic"]
|
||||||
if event_type == "ping":
|
if event_type == "ping":
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
handler = EVENT_TO_FUNCTION_MAPPER.get(event_type)
|
handler = EVENT_TO_FUNCTION_MAPPER.get(event_type)
|
||||||
if handler is None:
|
if handler is None:
|
||||||
|
@ -321,4 +321,4 @@ def api_intercom_webhook(
|
||||||
topic, body = handler(payload)
|
topic, body = handler(payload)
|
||||||
|
|
||||||
check_send_webhook_message(request, user_profile, topic, body, event_type)
|
check_send_webhook_message(request, user_profile, topic, body, event_type)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
|
@ -347,7 +347,7 @@ def api_jira_webhook(
|
||||||
|
|
||||||
event = get_event_type(payload)
|
event = get_event_type(payload)
|
||||||
if event in IGNORED_EVENTS:
|
if event in IGNORED_EVENTS:
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
if event is None:
|
if event is None:
|
||||||
raise AnomalousWebhookPayload()
|
raise AnomalousWebhookPayload()
|
||||||
|
@ -364,4 +364,4 @@ def api_jira_webhook(
|
||||||
check_send_webhook_message(
|
check_send_webhook_message(
|
||||||
request, user_profile, subject, content, event, unquote_url_parameters=True
|
request, user_profile, subject, content, event, unquote_url_parameters=True
|
||||||
)
|
)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
|
@ -28,4 +28,4 @@ def api_jotform_webhook(
|
||||||
message = form_response.strip()
|
message = form_response.strip()
|
||||||
|
|
||||||
check_send_webhook_message(request, user_profile, topic, message)
|
check_send_webhook_message(request, user_profile, topic, message)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
|
@ -28,7 +28,7 @@ def api_json_webhook(
|
||||||
subject = get_subject_for_http_request(payload)
|
subject = get_subject_for_http_request(payload)
|
||||||
|
|
||||||
check_send_webhook_message(request, user_profile, subject, body)
|
check_send_webhook_message(request, user_profile, subject, body)
|
||||||
return json_success()
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
def get_subject_for_http_request(payload: Dict[str, Any]) -> str:
|
def get_subject_for_http_request(payload: Dict[str, Any]) -> str:
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue