actions: Split out zerver.actions.video_calls.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2022-04-14 14:29:39 -07:00
parent c136eebb33
commit 90cae59ea6
5 changed files with 17 additions and 13 deletions

View File

@ -0,0 +1,14 @@
from typing import Dict, Optional
from zerver.models import UserProfile
from zerver.tornado.django_api import send_event
def do_set_zoom_token(user: UserProfile, token: Optional[Dict[str, object]]) -> None:
user.zoom_token = token
user.save(update_fields=["zoom_token"])
send_event(
user.realm,
dict(type="has_zoom_token", value=token is not None),
[user.id],
)

View File

@ -8742,16 +8742,6 @@ def do_send_realm_reactivation_email(realm: Realm, *, acting_user: Optional[User
)
def do_set_zoom_token(user: UserProfile, token: Optional[Dict[str, object]]) -> None:
user.zoom_token = token
user.save(update_fields=["zoom_token"])
send_event(
user.realm,
dict(type="has_zoom_token", value=token is not None),
[user.id],
)
def notify_realm_export(user_profile: UserProfile) -> None:
# In the future, we may want to send this event to all realm admins.
event = dict(type="realm_export", exports=get_realm_exports_serialized(user_profile))

View File

@ -107,7 +107,7 @@ def clear_zoom_token_on_logout(
sender: object, *, user: Optional[UserProfile], **kwargs: object
) -> None:
# Loaded lazily so django.setup() succeeds before static asset generation
from zerver.lib.actions import do_set_zoom_token
from zerver.actions.video_calls import do_set_zoom_token
if user is not None and user.zoom_token is not None:
do_set_zoom_token(user, None)

View File

@ -13,6 +13,7 @@ from unittest import mock
import orjson
from django.utils.timezone import now as timezone_now
from zerver.actions.video_calls import do_set_zoom_token
from zerver.lib.actions import (
bulk_add_members_to_user_group,
bulk_add_subscriptions,
@ -83,7 +84,6 @@ from zerver.lib.actions import (
do_set_realm_property,
do_set_realm_signup_notifications_stream,
do_set_realm_user_default_setting,
do_set_zoom_token,
do_unmute_topic,
do_unmute_user,
do_update_embedded_data,

View File

@ -22,8 +22,8 @@ from django.views.decorators.http import require_POST
from oauthlib.oauth2 import OAuth2Error
from requests_oauthlib import OAuth2Session
from zerver.actions.video_calls import do_set_zoom_token
from zerver.decorator import zulip_login_required
from zerver.lib.actions import do_set_zoom_token
from zerver.lib.exceptions import ErrorCode, JsonableError
from zerver.lib.outgoing_http import OutgoingSession
from zerver.lib.pysa import mark_sanitized