Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

webhooks/stripe: Use datetime_to_global_time and ISO 8601 syntax.

Niloth Pead790d74149
diff --git a/zerver/webhooks/stripe/tests.py b/zerver/webhooks/stripe/tests.py
index c9f38e0c868..c622e8f1354 100644
--- a/zerver/webhooks/stripe/tests.py
+++ b/zerver/webhooks/stripe/tests.py
@@ -141,13 +141,13 @@ Billing method: send invoice"""
expected_topic_name = "cus_00000000000000"
expected_message = """\
[Subscription](https://dashboard.stripe.com/subscriptions/sub_E6STM5w5EX3K28) updated
-* Billing cycle anchor is now <time:Nov 01, 2019, 12:00:00 UTC>
-* Current period end is now <time:Nov 01, 2019, 12:00:00 UTC>
-* Current period start is now <time:Dec 06, 2018, 05:53:55 UTC>
-* Start is now <time:Dec 06, 2018, 05:53:55 UTC>
+* Billing cycle anchor is now <time:2019-11-01T12:00:00+00:00>
+* Current period end is now <time:2019-11-01T12:00:00+00:00>
+* Current period start is now <time:2018-12-06T05:53:55+00:00>
+* Start is now <time:2018-12-06T05:53:55+00:00>
* Status is now trialing
-* Trial end is now <time:Nov 01, 2019, 12:00:00 UTC>
-* Trial start is now <time:Dec 06, 2018, 05:53:55 UTC>"""
+* Trial end is now <time:2019-11-01T12:00:00+00:00>
+* Trial start is now <time:2018-12-06T05:53:55+00:00>"""
self.check_webhook(
"customer_subscription_updated",
expected_topic_name,
diff --git a/zerver/webhooks/stripe/view.py b/zerver/webhooks/stripe/view.py
index 34ecdc5596b..fdf651bd24e 100644
--- a/zerver/webhooks/stripe/view.py
+++ b/zerver/webhooks/stripe/view.py
@@ -7,7 +7,7 @@ from django.http import HttpRequest, HttpResponse
from zerver.decorator import webhook_view
from zerver.lib.exceptions import UnsupportedWebhookEventTypeError
from zerver.lib.response import json_success
-from zerver.lib.timestamp import timestamp_to_datetime
+from zerver.lib.timestamp import datetime_to_global_time, timestamp_to_datetime
from zerver.lib.typed_endpoint import JsonBodyPayload, typed_endpoint
from zerver.lib.validator import WildValue, check_bool, check_int, check_none_or, check_string
from zerver.lib.webhooks.common import check_send_webhook_message
@@ -363,6 +363,5 @@ def linkified_id(object_id: str, lower: bool = False) -> str:
def stringify(value: object) -> str:
if isinstance(value, int) and value > 1500000000 and value < 2000000000:
- datetime_value = timestamp_to_datetime(value).strftime("%b %d, %Y, %H:%M:%S %Z")
- return f"<time:{datetime_value}>"
+ return datetime_to_global_time(timestamp_to_datetime(value))
return str(value)