From 372e9740acadd03380dd59f5a3f424c15881afbd Mon Sep 17 00:00:00 2001 From: Vishnu Ks Date: Tue, 15 May 2018 11:00:52 +0000 Subject: [PATCH] events: Add date_joined to user_dict. --- zerver/lib/actions.py | 1 + zerver/lib/cache.py | 4 +++- zerver/lib/events.py | 1 + zerver/tests/test_events.py | 1 + 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py index 0f32e0a2bd..d0c1e3d70f 100644 --- a/zerver/lib/actions.py +++ b/zerver/lib/actions.py @@ -431,6 +431,7 @@ def notify_created_user(user_profile: UserProfile) -> None: full_name=user_profile.full_name, avatar_url=avatar_url(user_profile), timezone=user_profile.timezone, + date_joined=user_profile.date_joined.isoformat(), is_bot=user_profile.is_bot)) send_event(event, active_user_ids(user_profile.realm_id)) diff --git a/zerver/lib/cache.py b/zerver/lib/cache.py index 1181ee87fa..e7ff7e6f0f 100644 --- a/zerver/lib/cache.py +++ b/zerver/lib/cache.py @@ -321,7 +321,9 @@ def user_profile_by_api_key_cache_key(api_key: str) -> str: realm_user_dict_fields = [ 'id', 'full_name', 'short_name', 'email', 'avatar_source', 'avatar_version', 'is_active', - 'is_realm_admin', 'is_bot', 'realm_id', 'timezone'] # type: List[str] + 'is_realm_admin', 'is_bot', 'realm_id', 'timezone', + 'date_joined' +] # type: List[str] def realm_user_dicts_cache_key(realm_id: int) -> str: return "realm_user_dicts:%s" % (realm_id,) diff --git a/zerver/lib/events.py b/zerver/lib/events.py index 50f7b6e40c..3e0cc5ce42 100644 --- a/zerver/lib/events.py +++ b/zerver/lib/events.py @@ -82,6 +82,7 @@ def get_raw_user_data(realm_id: int, client_gravatar: bool) -> Dict[int, Dict[st full_name=row['full_name'], timezone=row['timezone'], is_active = row['is_active'], + date_joined = row['date_joined'].isoformat(), ) if not is_bot: result['profile_data'] = profiles_by_user_id.get(row['id'], {}) diff --git a/zerver/tests/test_events.py b/zerver/tests/test_events.py index e3a8e1d1ee..ad9fbcf463 100644 --- a/zerver/tests/test_events.py +++ b/zerver/tests/test_events.py @@ -1061,6 +1061,7 @@ class EventsRegisterTest(ZulipTestCase): ('is_admin', check_bool), ('is_bot', check_bool), ('timezone', check_string), + ('date_joined', check_string), ])), ])