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.

realm_playgrounds events: Use RealmPlaygroundsEvent pydantic type.

Evy Kassirer9ee6738bccd5
diff --git a/zerver/actions/realm_playgrounds.py b/zerver/actions/realm_playgrounds.py
index f2d92d84105..addcacdab0f 100644
--- a/zerver/actions/realm_playgrounds.py
+++ b/zerver/actions/realm_playgrounds.py
@@ -2,6 +2,8 @@ from django.core.exceptions import ValidationError
from django.db import transaction
from django.utils.timezone import now as timezone_now
+from zerver.lib.event_types import RealmPlayground as RealmPlaygroundData
+from zerver.lib.event_types import RealmPlaygroundsEvent
from zerver.lib.exceptions import ValidationFailureError
from zerver.lib.types import RealmPlaygroundDict
from zerver.models import Realm, RealmAuditLog, RealmPlayground, UserProfile
@@ -12,7 +14,9 @@ from zerver.tornado.django_api import send_event_on_commit
def notify_realm_playgrounds(realm: Realm, realm_playgrounds: list[RealmPlaygroundDict]) -> None:
- event = dict(type="realm_playgrounds", realm_playgrounds=realm_playgrounds)
+ event = RealmPlaygroundsEvent(
+ realm_playgrounds=[RealmPlaygroundData(**p) for p in realm_playgrounds],
+ )
send_event_on_commit(realm, event, active_user_ids(realm.id))
diff --git a/zerver/lib/event_types.py b/zerver/lib/event_types.py
index 39713de707d..a00fbb69f56 100644
--- a/zerver/lib/event_types.py
+++ b/zerver/lib/event_types.py
@@ -551,7 +551,7 @@ class RealmPlayground(BaseModel):
class RealmPlaygroundsEvent(BaseEvent):
- type: Literal["realm_playgrounds"]
+ type: Literal["realm_playgrounds"] = "realm_playgrounds"
realm_playgrounds: list[RealmPlayground]