mirror of
https://github.com/zulip/zulip.git
synced 2025-11-07 07:23:22 +00:00
Send user_id to the client in more places.
This commit touches:
realm_bot/add
realm_user/add
page_params.bot_list
page_params.people_list
This commit is contained in:
@@ -269,6 +269,7 @@ def notify_created_user(user_profile):
|
|||||||
# type: (UserProfile) -> None
|
# type: (UserProfile) -> None
|
||||||
event = dict(type="realm_user", op="add",
|
event = dict(type="realm_user", op="add",
|
||||||
person=dict(email=user_profile.email,
|
person=dict(email=user_profile.email,
|
||||||
|
user_id=user_profile.id,
|
||||||
is_admin=user_profile.is_realm_admin,
|
is_admin=user_profile.is_realm_admin,
|
||||||
full_name=user_profile.full_name,
|
full_name=user_profile.full_name,
|
||||||
is_bot=user_profile.is_bot))
|
is_bot=user_profile.is_bot))
|
||||||
@@ -288,6 +289,7 @@ def notify_created_bot(user_profile):
|
|||||||
|
|
||||||
event = dict(type="realm_bot", op="add",
|
event = dict(type="realm_bot", op="add",
|
||||||
bot=dict(email=user_profile.email,
|
bot=dict(email=user_profile.email,
|
||||||
|
user_id=user_profile.id,
|
||||||
full_name=user_profile.full_name,
|
full_name=user_profile.full_name,
|
||||||
api_key=user_profile.api_key,
|
api_key=user_profile.api_key,
|
||||||
default_sending_stream=default_sending_stream_name,
|
default_sending_stream=default_sending_stream_name,
|
||||||
@@ -2784,6 +2786,7 @@ def get_status_dict(requesting_user_profile):
|
|||||||
def get_realm_user_dicts(user_profile):
|
def get_realm_user_dicts(user_profile):
|
||||||
# type: (UserProfile) -> List[Dict[str, text_type]]
|
# type: (UserProfile) -> List[Dict[str, text_type]]
|
||||||
return [{'email' : userdict['email'],
|
return [{'email' : userdict['email'],
|
||||||
|
'user_id' : userdict['id'],
|
||||||
'is_admin' : userdict['is_realm_admin'],
|
'is_admin' : userdict['is_realm_admin'],
|
||||||
'is_bot' : userdict['is_bot'],
|
'is_bot' : userdict['is_bot'],
|
||||||
'full_name' : userdict['full_name']}
|
'full_name' : userdict['full_name']}
|
||||||
|
|||||||
@@ -1065,6 +1065,7 @@ def get_owned_bot_dicts(user_profile, include_all_realm_bots_if_admin=True):
|
|||||||
from zerver.lib.avatar import get_avatar_url
|
from zerver.lib.avatar import get_avatar_url
|
||||||
|
|
||||||
return [{'email': botdict['email'],
|
return [{'email': botdict['email'],
|
||||||
|
'user_id': botdict['id'],
|
||||||
'full_name': botdict['full_name'],
|
'full_name': botdict['full_name'],
|
||||||
'api_key': botdict['api_key'],
|
'api_key': botdict['api_key'],
|
||||||
'default_sending_stream': botdict['default_sending_stream__name'],
|
'default_sending_stream': botdict['default_sending_stream__name'],
|
||||||
|
|||||||
@@ -624,6 +624,7 @@ class EventsRegisterTest(ZulipTestCase):
|
|||||||
('op', equals('add')),
|
('op', equals('add')),
|
||||||
('bot', check_dict([
|
('bot', check_dict([
|
||||||
('email', check_string),
|
('email', check_string),
|
||||||
|
('user_id', check_int),
|
||||||
('full_name', check_string),
|
('full_name', check_string),
|
||||||
('api_key', check_string),
|
('api_key', check_string),
|
||||||
('default_sending_stream', check_none_or(check_string)),
|
('default_sending_stream', check_none_or(check_string)),
|
||||||
|
|||||||
@@ -772,12 +772,15 @@ class BotTest(ZulipTestCase):
|
|||||||
result = self.create_bot()
|
result = self.create_bot()
|
||||||
self.assert_num_bots_equal(1)
|
self.assert_num_bots_equal(1)
|
||||||
|
|
||||||
|
bot = get_user_profile_by_email('hambot-bot@zulip.com')
|
||||||
|
|
||||||
event = [e for e in events if e['event']['type'] == 'realm_bot'][0]
|
event = [e for e in events if e['event']['type'] == 'realm_bot'][0]
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
dict(
|
dict(
|
||||||
type='realm_bot',
|
type='realm_bot',
|
||||||
op='add',
|
op='add',
|
||||||
bot=dict(email='hambot-bot@zulip.com',
|
bot=dict(email='hambot-bot@zulip.com',
|
||||||
|
user_id=bot.id,
|
||||||
full_name='The Bot of Hamlet',
|
full_name='The Bot of Hamlet',
|
||||||
api_key=result['api_key'],
|
api_key=result['api_key'],
|
||||||
avatar_url=result['avatar_url'],
|
avatar_url=result['avatar_url'],
|
||||||
@@ -931,6 +934,7 @@ class BotTest(ZulipTestCase):
|
|||||||
type='realm_bot',
|
type='realm_bot',
|
||||||
op='add',
|
op='add',
|
||||||
bot=dict(email='hambot-bot@zulip.com',
|
bot=dict(email='hambot-bot@zulip.com',
|
||||||
|
user_id=profile.id,
|
||||||
full_name='The Bot of Hamlet',
|
full_name='The Bot of Hamlet',
|
||||||
api_key=result['api_key'],
|
api_key=result['api_key'],
|
||||||
avatar_url=result['avatar_url'],
|
avatar_url=result['avatar_url'],
|
||||||
@@ -984,8 +988,8 @@ class BotTest(ZulipTestCase):
|
|||||||
self.assert_num_bots_equal(1)
|
self.assert_num_bots_equal(1)
|
||||||
self.assertEqual(result['default_events_register_stream'], 'Denmark')
|
self.assertEqual(result['default_events_register_stream'], 'Denmark')
|
||||||
|
|
||||||
profile = get_user_profile_by_email('hambot-bot@zulip.com')
|
bot_profile = get_user_profile_by_email('hambot-bot@zulip.com')
|
||||||
self.assertEqual(profile.default_events_register_stream.name, 'Denmark')
|
self.assertEqual(bot_profile.default_events_register_stream.name, 'Denmark')
|
||||||
|
|
||||||
event = [e for e in events if e['event']['type'] == 'realm_bot'][0]
|
event = [e for e in events if e['event']['type'] == 'realm_bot'][0]
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
@@ -994,6 +998,7 @@ class BotTest(ZulipTestCase):
|
|||||||
op='add',
|
op='add',
|
||||||
bot=dict(email='hambot-bot@zulip.com',
|
bot=dict(email='hambot-bot@zulip.com',
|
||||||
full_name='The Bot of Hamlet',
|
full_name='The Bot of Hamlet',
|
||||||
|
user_id=bot_profile.id,
|
||||||
api_key=result['api_key'],
|
api_key=result['api_key'],
|
||||||
avatar_url=result['avatar_url'],
|
avatar_url=result['avatar_url'],
|
||||||
default_sending_stream=None,
|
default_sending_stream=None,
|
||||||
@@ -1962,6 +1967,19 @@ class HomeTest(ZulipTestCase):
|
|||||||
page_params = self._get_page_params(result)
|
page_params = self._get_page_params(result)
|
||||||
self.assertEqual(page_params['notifications_stream'], 'Denmark')
|
self.assertEqual(page_params['notifications_stream'], 'Denmark')
|
||||||
|
|
||||||
|
def test_people(self):
|
||||||
|
# type: () -> None
|
||||||
|
email = 'hamlet@zulip.com'
|
||||||
|
self.login(email)
|
||||||
|
result = self._get_home_page()
|
||||||
|
page_params = self._get_page_params(result)
|
||||||
|
for params in ['people_list', 'bot_list']:
|
||||||
|
users = page_params['people_list']
|
||||||
|
self.assertTrue(len(users) >= 3)
|
||||||
|
for user in users:
|
||||||
|
self.assertEqual(user['user_id'],
|
||||||
|
get_user_profile_by_email(user['email']).id)
|
||||||
|
|
||||||
def test_new_stream(self):
|
def test_new_stream(self):
|
||||||
# type: () -> None
|
# type: () -> None
|
||||||
email = 'hamlet@zulip.com'
|
email = 'hamlet@zulip.com'
|
||||||
|
|||||||
Reference in New Issue
Block a user