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.

management: Provide a way to deactivate the push registration.

Alex Vandiver511cc4d8f7b7
diff --git a/docs/production/mobile-push-notifications.md b/docs/production/mobile-push-notifications.md
index 6112f1c9919..e96a5dd3c09 100644
--- a/docs/production/mobile-push-notifications.md
+++ b/docs/production/mobile-push-notifications.md
@@ -287,10 +287,50 @@ If you'd like to rotate your server's API key for this service
generate a new `zulip_org_key` and store that new key in
`/etc/zulip/zulip-secrets.conf`.
+## Deactivating your server's registration
+
+If you are deleting your Zulip server or otherwise no longer want to
+use the Mobile Push Notification Service, you can deactivate your server's
+registration.
+
+1. [Cancel any paid
+ plans](https://zulip.com/help/self-hosted-billing#cancel-paid-plan)
+ associated with your server.
+
+1. Run the deregistration command. If you installed Zulip directly on
+ the server (without Docker), run as root:
+
+ ```
+ su zulip -c '/home/zulip/deployments/current/manage.py register_server --deactivate'
+ ```
+
+ Or if you're using Docker, run:
+
+ ```
+ docker exec -it -u zulip <container_name> /home/zulip/deployments/current/manage.py register_server --deactivate
+ ```
+
+1. Comment out the
+ `PUSH_NOTIFICATION_BOUNCER_URL = 'https://push.zulipchat.com'` line
+ in your `/etc/zulip/settings.py` file (i.e., add `# ` at the
+ start of the line), and [restart your Zulip
+ server](settings.md#making-changes).
+
+If you ever need to reactivate your server's registration, [contact Zulip
+support](https://zulip.com/help/contact-support).
+
+### Pausing use of the Mobile Push Notification Service
+
+You can temporarily stop using the Mobile Push Notification Service. Comment out
+the `PUSH_NOTIFICATION_BOUNCER_URL = 'https://push.zulipchat.com'` line in your
+`/etc/zulip/settings.py` file (i.e., add `# ` at the start of the line), and
+[restart your Zulip server](settings.md#making-changes). This approach makes it
+easy to start using the service again by uncommenting the same line.
+
## Sending push notifications directly from your server
This section documents an alternative way to send push notifications
-that does not involve using the Mobile Push Notifications Service at
+that does not involve using the Mobile Push Notification Service at
the cost of needing to compile and distribute modified versions of the
Zulip mobile apps.
diff --git a/zerver/management/commands/register_server.py b/zerver/management/commands/register_server.py
index ec565cda250..a2acc9f6e53 100644
--- a/zerver/management/commands/register_server.py
+++ b/zerver/management/commands/register_server.py
@@ -10,7 +10,11 @@ from requests.models import Response
from typing_extensions import override
from zerver.lib.management import ZulipBaseCommand, check_config
-from zerver.lib.remote_server import PushBouncerSession, send_server_data_to_push_bouncer
+from zerver.lib.remote_server import (
+ PushBouncerSession,
+ send_json_to_push_bouncer,
+ send_server_data_to_push_bouncer,
+)
if settings.DEVELOPMENT:
SECRETS_FILENAME = "zproject/dev-secrets.conf"
@@ -28,11 +32,17 @@ class Command(ZulipBaseCommand):
action="store_true",
help="Agree to the Zulipchat Terms of Service: https://zulip.com/policies/terms.",
)
- parser.add_argument(
+ action = parser.add_mutually_exclusive_group()
+ action.add_argument(
"--rotate-key",
action="store_true",
help="Automatically rotate your server's zulip_org_key",
)
+ action.add_argument(
+ "--deactivate",
+ action="store_true",
+ help="Deregister the server; this will stop mobile push notifications",
+ )
@override
def handle(self, *args: Any, **options: Any) -> None:
@@ -58,6 +68,11 @@ class Command(ZulipBaseCommand):
"in /etc/zulip/settings.py (remove the '#')"
)
+ if options["deactivate"]:
+ send_json_to_push_bouncer("POST", "server/deactivate", {})
+ print("Mobile Push Notification Service registration successfully deactivated!")
+ return
+
request = {
"zulip_org_id": settings.ZULIP_ORG_ID,
"zulip_org_key": settings.ZULIP_ORG_KEY,