mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 13:03:29 +00:00
management: Add library for getting a client object.
This is to be used in some analytics features we're adding in the near future.
This commit is contained in:
@@ -8,7 +8,7 @@ from django.core.exceptions import MultipleObjectsReturned
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
from typing import Any, Dict, Optional, List
|
||||
|
||||
from zerver.models import Realm, UserProfile
|
||||
from zerver.models import Realm, UserProfile, Client, get_client
|
||||
|
||||
def is_integer_string(val: str) -> bool:
|
||||
try:
|
||||
@@ -120,3 +120,7 @@ You can use the command list_realms to find ID of the realms in this server."""
|
||||
"to specify which one to modify.")
|
||||
except UserProfile.DoesNotExist:
|
||||
raise CommandError("This Zulip server does not contain a user with email '%s'" % (email,))
|
||||
|
||||
def get_client(self) -> Client:
|
||||
"""Returns a Zulip Client object to be used for things done in management commands"""
|
||||
return get_client("ZulipServer")
|
||||
|
||||
Reference in New Issue
Block a user