mirror of
https://github.com/zulip/zulip.git
synced 2025-10-30 19:43:47 +00:00
support: Use datetime for push notification data in remote support.
This commit is contained in:
committed by
Tim Abbott
parent
6dcd4c4ca6
commit
7a40462aed
@@ -7,7 +7,6 @@ from django.utils.timezone import now as timezone_now
|
|||||||
|
|
||||||
from corporate.lib.stripe import (
|
from corporate.lib.stripe import (
|
||||||
BillingSession,
|
BillingSession,
|
||||||
PushNotificationsEnabledStatus,
|
|
||||||
RealmBillingSession,
|
RealmBillingSession,
|
||||||
RemoteRealmBillingSession,
|
RemoteRealmBillingSession,
|
||||||
RemoteServerBillingSession,
|
RemoteServerBillingSession,
|
||||||
@@ -25,6 +24,7 @@ from corporate.models import (
|
|||||||
ZulipSponsorshipRequest,
|
ZulipSponsorshipRequest,
|
||||||
get_current_plan_by_customer,
|
get_current_plan_by_customer,
|
||||||
)
|
)
|
||||||
|
from zerver.lib.timestamp import timestamp_to_datetime
|
||||||
from zerver.models import Realm
|
from zerver.models import Realm
|
||||||
from zerver.models.realm_audit_logs import AuditLogEventType
|
from zerver.models.realm_audit_logs import AuditLogEventType
|
||||||
from zerver.models.realms import get_org_type_display_name
|
from zerver.models.realms import get_org_type_display_name
|
||||||
@@ -91,10 +91,17 @@ class PlanData:
|
|||||||
estimated_next_plan_revenue: int | None = None
|
estimated_next_plan_revenue: int | None = None
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class PushNotificationsStatus:
|
||||||
|
can_push: bool
|
||||||
|
expected_end: datetime | None
|
||||||
|
message: str
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class MobilePushData:
|
class MobilePushData:
|
||||||
total_mobile_users: int
|
total_mobile_users: int
|
||||||
push_notification_status: PushNotificationsEnabledStatus
|
push_notification_status: PushNotificationsStatus
|
||||||
uncategorized_mobile_users: int | None = None
|
uncategorized_mobile_users: int | None = None
|
||||||
mobile_pushes_forwarded: int | None = None
|
mobile_pushes_forwarded: int | None = None
|
||||||
last_mobile_push_sent: str = ""
|
last_mobile_push_sent: str = ""
|
||||||
@@ -350,9 +357,16 @@ def get_mobile_push_data(remote_entity: RemoteZulipServer | RemoteRealm) -> Mobi
|
|||||||
).strftime("%Y-%m-%d")
|
).strftime("%Y-%m-%d")
|
||||||
else:
|
else:
|
||||||
push_forwarded_interval_start = "None"
|
push_forwarded_interval_start = "None"
|
||||||
push_notification_status = get_push_status_for_remote_request(
|
push_status = get_push_status_for_remote_request(
|
||||||
remote_server=remote_entity, remote_realm=None
|
remote_server=remote_entity, remote_realm=None
|
||||||
)
|
)
|
||||||
|
push_notification_status = PushNotificationsStatus(
|
||||||
|
can_push=push_status.can_push,
|
||||||
|
expected_end=timestamp_to_datetime(push_status.expected_end_timestamp)
|
||||||
|
if push_status.expected_end_timestamp
|
||||||
|
else None,
|
||||||
|
message=push_status.message,
|
||||||
|
)
|
||||||
return MobilePushData(
|
return MobilePushData(
|
||||||
total_mobile_users=total_users,
|
total_mobile_users=total_users,
|
||||||
push_notification_status=push_notification_status,
|
push_notification_status=push_notification_status,
|
||||||
@@ -386,8 +400,13 @@ def get_mobile_push_data(remote_entity: RemoteZulipServer | RemoteRealm) -> Mobi
|
|||||||
).strftime("%Y-%m-%d")
|
).strftime("%Y-%m-%d")
|
||||||
else:
|
else:
|
||||||
push_forwarded_interval_start = "None"
|
push_forwarded_interval_start = "None"
|
||||||
push_notification_status = get_push_status_for_remote_request(
|
push_status = get_push_status_for_remote_request(remote_entity.server, remote_entity)
|
||||||
remote_entity.server, remote_entity
|
push_notification_status = PushNotificationsStatus(
|
||||||
|
can_push=push_status.can_push,
|
||||||
|
expected_end=timestamp_to_datetime(push_status.expected_end_timestamp)
|
||||||
|
if push_status.expected_end_timestamp
|
||||||
|
else None,
|
||||||
|
message=push_status.message,
|
||||||
)
|
)
|
||||||
return MobilePushData(
|
return MobilePushData(
|
||||||
total_mobile_users=mobile_users,
|
total_mobile_users=mobile_users,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<div class="push-notification-status">
|
<div class="push-notification-status">
|
||||||
<p class="support-section-header">📶 Push notification status:</p>
|
<p class="support-section-header">📶 Push notification status:</p>
|
||||||
<b>Can push</b>: {{ status.can_push }}<br />
|
<b>Can push</b>: {{ status.can_push }}<br />
|
||||||
<b>Expected end</b>: {{ format_optional_datetime(status.expected_end_timestamp, True) }}<br />
|
<b>Expected end</b>: {{ format_optional_datetime(status.expected_end, True) }}<br />
|
||||||
<b>Message</b>: {{ status.message }}<br />
|
<b>Message</b>: {{ status.message }}<br />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user