mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 05:23:35 +00:00
users: Pass email_address_visibility as parameter to can_access_delivery_email.
This is a prep commit for adding user-level email visibility setting.
This commit is contained in:
@@ -394,12 +394,11 @@ def validate_user_custom_profile_data(
|
|||||||
raise JsonableError(error.message)
|
raise JsonableError(error.message)
|
||||||
|
|
||||||
|
|
||||||
def can_access_delivery_email(user_profile: UserProfile) -> bool:
|
def can_access_delivery_email(user_profile: UserProfile, email_address_visibility: int) -> bool:
|
||||||
realm = user_profile.realm
|
if email_address_visibility == Realm.EMAIL_ADDRESS_VISIBILITY_ADMINS:
|
||||||
if realm.email_address_visibility == Realm.EMAIL_ADDRESS_VISIBILITY_ADMINS:
|
|
||||||
return user_profile.is_realm_admin
|
return user_profile.is_realm_admin
|
||||||
|
|
||||||
if realm.email_address_visibility == Realm.EMAIL_ADDRESS_VISIBILITY_MODERATORS:
|
if email_address_visibility == Realm.EMAIL_ADDRESS_VISIBILITY_MODERATORS:
|
||||||
return user_profile.is_realm_admin or user_profile.is_moderator
|
return user_profile.is_realm_admin or user_profile.is_moderator
|
||||||
|
|
||||||
return False
|
return False
|
||||||
@@ -477,7 +476,9 @@ def format_user_row(
|
|||||||
client_gravatar=client_gravatar,
|
client_gravatar=client_gravatar,
|
||||||
)
|
)
|
||||||
|
|
||||||
if acting_user is not None and can_access_delivery_email(acting_user):
|
if acting_user is not None and can_access_delivery_email(
|
||||||
|
acting_user, realm.email_address_visibility
|
||||||
|
):
|
||||||
result["delivery_email"] = row["delivery_email"]
|
result["delivery_email"] = row["delivery_email"]
|
||||||
|
|
||||||
if is_bot:
|
if is_bot:
|
||||||
|
|||||||
Reference in New Issue
Block a user