diff --git a/zerver/lib/remote_server.py b/zerver/lib/remote_server.py index 9f41768b0a..5ee884efca 100644 --- a/zerver/lib/remote_server.py +++ b/zerver/lib/remote_server.py @@ -7,7 +7,7 @@ import requests from django.conf import settings from django.forms.models import model_to_dict from django.utils.translation import gettext as _ -from pydantic import UUID4, BaseModel, ConfigDict, field_validator +from pydantic import UUID4, BaseModel, ConfigDict, Field, field_validator from analytics.models import InstallationCount, RealmCount from version import ZULIP_VERSION @@ -36,10 +36,13 @@ class RealmDataForAnalytics(BaseModel): id: int host: str url: str + name: str = "" org_type: int = 0 date_created: float deactivated: bool + authentication_methods: Dict[str, bool] = Field(default_factory=dict) + uuid: UUID4 uuid_owner_secret: str @@ -224,6 +227,8 @@ def get_realms_info_for_push_bouncer(realm_id: Optional[int] = None) -> List[Rea deactivated=realm.deactivated, date_created=realm.date_created.timestamp(), org_type=realm.org_type, + name=realm.name, + authentication_methods=realm.authentication_methods_dict(), ) for realm in realms ] diff --git a/zerver/tests/test_push_notifications.py b/zerver/tests/test_push_notifications.py index da4ddca7c0..762b9a2b1a 100644 --- a/zerver/tests/test_push_notifications.py +++ b/zerver/tests/test_push_notifications.py @@ -984,7 +984,9 @@ class AnalyticsBouncerTest(BouncerTestCase): "uuid", "uuid_owner_secret", "host", + "name", "org_type", + "authentication_methods", "realm_date_created", "registration_deactivated", "realm_deactivated", @@ -997,7 +999,9 @@ class AnalyticsBouncerTest(BouncerTestCase): "uuid": realm.uuid, "uuid_owner_secret": realm.uuid_owner_secret, "host": realm.host, + "name": realm.name, "org_type": realm.org_type, + "authentication_methods": realm.authentication_methods_dict(), "realm_date_created": realm.date_created, "registration_deactivated": False, "realm_deactivated": False, diff --git a/zilencer/migrations/0040_remoterealm_authentication_methods_remoterealm_name.py b/zilencer/migrations/0040_remoterealm_authentication_methods_remoterealm_name.py new file mode 100644 index 0000000000..684a6ec2cd --- /dev/null +++ b/zilencer/migrations/0040_remoterealm_authentication_methods_remoterealm_name.py @@ -0,0 +1,22 @@ +# Generated by Django 4.2.7 on 2023-11-29 22:43 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("zilencer", "0039_remoterealm_org_type"), + ] + + operations = [ + migrations.AddField( + model_name="remoterealm", + name="authentication_methods", + field=models.JSONField(default=dict), + ), + migrations.AddField( + model_name="remoterealm", + name="name", + field=models.TextField(default=""), + ), + ] diff --git a/zilencer/models.py b/zilencer/models.py index ece1bc1c98..f4229f5312 100644 --- a/zilencer/models.py +++ b/zilencer/models.py @@ -104,6 +104,10 @@ class RemoteRealm(models.Model): # Value obtained's from the remote server's realm.host. host = models.TextField() + name = models.TextField(default="") + + authentication_methods = models.JSONField(default=dict) + org_type = models.PositiveSmallIntegerField( default=Realm.ORG_TYPES["unspecified"]["id"], choices=[(t["id"], t["name"]) for t in Realm.ORG_TYPES.values()], diff --git a/zilencer/views.py b/zilencer/views.py index 324ec7b085..90e221c931 100644 --- a/zilencer/views.py +++ b/zilencer/views.py @@ -543,6 +543,8 @@ def update_remote_realm_data_for_server( realm_deactivated=realm.deactivated, realm_date_created=timestamp_to_datetime(realm.date_created), org_type=realm.org_type, + name=realm.name, + authentication_methods=realm.authentication_methods, ) for realm in server_realms_info if realm.uuid not in already_registered_uuids