email: Convert accounts code to use delivery_email.

A key part of this is the new helper, get_user_by_delivery_email.  Its
verbose name is important for clarity; it should help avoid blind
copy-pasting of get_user (which we'll also want to rename).
Unfortunately, it requires detailed understanding of the context to
figure out which one to use; each is used in about half of call sites.

Another important note is that this PR doesn't migrate get_user calls
in the tests except where not doing so would cause the tests to fail.
This probably deserves a follow-up refactor to avoid bugs here.
This commit is contained in:
Tim Abbott
2018-12-06 15:05:57 -08:00
parent 67f0b1bbca
commit e603237010
22 changed files with 80 additions and 56 deletions

View File

@@ -48,7 +48,8 @@ def user_cache_items(items_for_remote_cache: Dict[str, Tuple[UserProfile]],
user_profile: UserProfile) -> None:
for api_key in get_all_api_keys(user_profile):
items_for_remote_cache[user_profile_by_api_key_cache_key(api_key)] = (user_profile,)
items_for_remote_cache[user_profile_cache_key(user_profile.email, user_profile.realm)] = (user_profile,)
items_for_remote_cache[user_profile_cache_key(user_profile.email,
user_profile.realm)] = (user_profile,)
# We have other user_profile caches, but none of them are on the
# core serving path for lots of requests.