mirror of
				https://github.com/zulip/zulip.git
				synced 2025-10-31 03:53:50 +00:00 
			
		
		
		
	models: Allow realm_id to be blank.
We cannot provide realm_id for some remote session logs.
This commit is contained in:
		| @@ -2340,7 +2340,11 @@ class RemoteRealmBillingSession(BillingSession):  # nocoverage | ||||
|         *, | ||||
|         extra_data: Optional[Dict[str, Any]] = None, | ||||
|     ) -> None: | ||||
|         # BUG: This doesn't have a way to pass realm_id ! | ||||
|         # These audit logs don't use all the fields of `RemoteRealmAuditLog`: | ||||
|         # | ||||
|         # * remote_id is None because this is not synced from a remote table. | ||||
|         # * realm_id is None because we do not aim to store both remote_realm | ||||
|         #   and the legacy realm_id field. | ||||
|         audit_log_event = self.get_audit_log_event(event_type) | ||||
|         log_data = { | ||||
|             "server": self.remote_realm.server, | ||||
|   | ||||
| @@ -0,0 +1,17 @@ | ||||
| # Generated by Django 4.2.7 on 2023-11-30 11:24 | ||||
|  | ||||
| from django.db import migrations, models | ||||
|  | ||||
|  | ||||
| class Migration(migrations.Migration): | ||||
|     dependencies = [ | ||||
|         ("zilencer", "0041_remotezulipserver_org_type"), | ||||
|     ] | ||||
|  | ||||
|     operations = [ | ||||
|         migrations.AlterField( | ||||
|             model_name="remoterealmauditlog", | ||||
|             name="realm_id", | ||||
|             field=models.IntegerField(blank=True, null=True), | ||||
|         ), | ||||
|     ] | ||||
| @@ -169,10 +169,13 @@ class RemoteRealmAuditLog(AbstractRealmAuditLog): | ||||
|  | ||||
|     server = models.ForeignKey(RemoteZulipServer, on_delete=models.CASCADE) | ||||
|  | ||||
|     # For pre-8.0 servers, we might only have the realm ID. | ||||
|     realm_id = models.IntegerField() | ||||
|     # With newer servers, we can link to the RemoteRealm object. | ||||
|     # With modern Zulip servers, we can link to the RemoteRealm object. | ||||
|     remote_realm = models.ForeignKey(RemoteRealm, on_delete=models.CASCADE, null=True) | ||||
|     # For pre-8.0 servers, we might only have the realm ID and thus no | ||||
|     # RemoteRealm object yet. We will eventually be able to drop this | ||||
|     # column once all self-hosted servers have upgraded in favor of | ||||
|     # just using the foreign key everywhere. | ||||
|     realm_id = models.IntegerField(null=True, blank=True) | ||||
|     # The remote_id field lets us deduplicate data from the remote server | ||||
|     remote_id = models.IntegerField(null=True) | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user