users: Always pass "delivery_email" field in user objects.

Previously, user objects contained delivery_email field
only when user had access to real email. Also, delivery_email
was not present if visibility setting is set to "everyone"
as email field was itself set to real email.

This commit changes the code to pass "delivery_email" field
always in the user objects with its value being "None" if
user does not have access to real email and real email otherwise.
The "delivery_email" field value is None for logged-out users.
For bots, the "delivery_email" is always set to real email
irrespective of email_address_visibility setting.

Also, since user has access to real email if visibility is set
to "everyone", "delivery_email" field is passed in that case
too.

There is no change in email field and it is same as before.

This commit also adds code to send event to update delivery_email
field when email_address_visibility setting changes to all the
users whose access to emails changes and also changes the code to
send event on changing delivery_email to users who have access
to email.
This commit is contained in:
Sahil Batra
2022-05-25 16:43:31 +05:30
committed by Tim Abbott
parent a2bcf3a77c
commit 2396e6858f
13 changed files with 210 additions and 48 deletions

View File

@@ -1085,6 +1085,7 @@ realm_user_type = DictType(
("profile_data", StringDictType(dict)),
("timezone", str),
("date_joined", str),
("delivery_email", OptionalType(str)),
]
)
@@ -1157,7 +1158,7 @@ realm_user_person_types = dict(
required_keys=[
# vertical formatting
("user_id", int),
("delivery_email", str),
("delivery_email", OptionalType(str)),
],
),
email=DictType(