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.

remote-support: Add push notification status information.

Lauryn Menarde4e65074dfbb
diff --git a/corporate/lib/support.py b/corporate/lib/support.py
index f0d4b67373d..4078c87d003 100644
--- a/corporate/lib/support.py
+++ b/corporate/lib/support.py
@@ -11,9 +11,11 @@ from django.utils.timezone import now as timezone_now
from corporate.lib.stripe import (
BillingSession,
+ PushNotificationsEnabledStatus,
RemoteRealmBillingSession,
RemoteServerBillingSession,
get_configured_fixed_price_plan_offer,
+ get_push_status_for_remote_request,
start_of_next_billing_cycle,
)
from corporate.models import (
@@ -86,6 +88,7 @@ class PlanData:
@dataclass
class MobilePushData:
total_mobile_users: int
+ push_notification_status: PushNotificationsEnabledStatus
uncategorized_mobile_users: Optional[int] = None
mobile_pushes_forwarded: Optional[int] = None
last_mobile_push_sent: str = ""
@@ -304,8 +307,12 @@ def get_mobile_push_data(remote_entity: Union[RemoteZulipServer, RemoteRealm]) -
).strftime("%Y-%m-%d")
else:
push_forwarded_interval_start = "None"
+ push_notification_status = get_push_status_for_remote_request(
+ remote_server=remote_entity, remote_realm=None
+ )
return MobilePushData(
total_mobile_users=total_users,
+ push_notification_status=push_notification_status,
uncategorized_mobile_users=uncategorized_users,
mobile_pushes_forwarded=mobile_pushes["total_forwarded"],
last_mobile_push_sent=push_forwarded_interval_start,
@@ -334,8 +341,12 @@ def get_mobile_push_data(remote_entity: Union[RemoteZulipServer, RemoteRealm]) -
).strftime("%Y-%m-%d")
else:
push_forwarded_interval_start = "None"
+ push_notification_status = get_push_status_for_remote_request(
+ remote_entity.server, remote_entity
+ )
return MobilePushData(
total_mobile_users=mobile_users,
+ push_notification_status=push_notification_status,
uncategorized_mobile_users=None,
mobile_pushes_forwarded=mobile_pushes["total_forwarded"],
last_mobile_push_sent=push_forwarded_interval_start,
diff --git a/corporate/tests/test_support_views.py b/corporate/tests/test_support_views.py
index f0ad1f4705b..50091a0ea13 100644
--- a/corporate/tests/test_support_views.py
+++ b/corporate/tests/test_support_views.py
@@ -174,6 +174,7 @@ class TestRemoteServerSupportEndpoint(ZulipTestCase):
"<b>Plan type</b>: Free<br />",
"<b>Non-guest user count</b>: 0<br />",
"<b>Guest user count</b>: 0<br />",
+ "📶 Push notification status:",
],
html_response,
)
@@ -190,6 +191,7 @@ class TestRemoteServerSupportEndpoint(ZulipTestCase):
"<b>Date created</b>: 01 December 2023",
"<b>Org type</b>: Unspecified<br />",
"<b>Has remote realms</b>: True<br />",
+ "📶 Push notification status:",
],
html_response,
)
diff --git a/templates/corporate/support/push_status_details.html b/templates/corporate/support/push_status_details.html
new file mode 100644
index 00000000000..e0df02be48d
--- /dev/null
+++ b/templates/corporate/support/push_status_details.html
@@ -0,0 +1,6 @@
+<div class="push-notification-status">
+ <p class="support-section-header">📶 Push notification status:</p>
+ <b>Can push</b>: {{ status.can_push }}<br />
+ <b>Expected end</b>: {{ format_optional_datetime(status.expected_end_timestamp, True) }}<br />
+ <b>Message</b>: {{ status.message }}<br />
+</div>
diff --git a/templates/corporate/support/remote_realm_details.html b/templates/corporate/support/remote_realm_details.html
index 6e339222029..d8c2cef7f87 100644
--- a/templates/corporate/support/remote_realm_details.html
+++ b/templates/corporate/support/remote_realm_details.html
@@ -29,6 +29,12 @@
<b>Last push notification date</b>: {{ support_data[remote_realm.id].mobile_push_data.last_mobile_push_sent }}<br />
</div>
+ {% with %}
+ {% set status = support_data[remote_realm.id].mobile_push_data.push_notification_status %}
+ {% include 'corporate/support/push_status_details.html' %}
+ {% endwith %}
+
+
{% if remote_realm.plan_type != SPONSORED_PLAN_TYPE %}
<div class="remote-support-sponsorship-container">
{% with %}
diff --git a/templates/corporate/support/remote_server_support.html b/templates/corporate/support/remote_server_support.html
index b0f5e3f1929..93fa7729bbd 100644
--- a/templates/corporate/support/remote_server_support.html
+++ b/templates/corporate/support/remote_server_support.html
@@ -68,6 +68,11 @@
<b>Last push notification date</b>: {{ remote_servers_support_data[remote_server.id].mobile_push_data.last_mobile_push_sent }}<br />
</div>
+ {% with %}
+ {% set status = remote_servers_support_data[remote_server.id].mobile_push_data.push_notification_status %}
+ {% include 'corporate/support/push_status_details.html' %}
+ {% endwith %}
+
{% if remote_server.plan_type != SPONSORED_PLAN_TYPE %}
<div class="remote-support-sponsorship-container">
{% with %}
diff --git a/web/styles/portico/activity.css b/web/styles/portico/activity.css
index d6804b1a3ca..3e26a52b241 100644
--- a/web/styles/portico/activity.css
+++ b/web/styles/portico/activity.css
@@ -396,16 +396,28 @@ tr.admin td:first-child {
padding-bottom: 25px;
}
+.push-notification-status,
.realm-form-container,
.next-plan-container,
.current-plan-container,
.remote-support-sponsorship-container {
- border: 2px solid hsl(33deg 99% 60%);
border-radius: 4px;
padding: 10px;
margin: 10px 0;
}
+.push-notification-status {
+ border: 2px solid hsl(186deg 76% 36%);
+ background-color: hsl(188deg 35% 87%);
+}
+
+.realm-form-container,
+.next-plan-container,
+.current-plan-container,
+.remote-support-sponsorship-container {
+ border: 2px solid hsl(33deg 99% 60%);
+}
+
.realm-form-container,
.remote-support-sponsorship-container {
background-color: hsl(30deg 100% 96%);