mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	refactor: Extract email_for_user_settings.
We want to be able to unit test this value,
since it's conditional on several factors:
    - am I an admin?
    - can non-admins view emails?
    - do we have delivery_email for the user?
I'm mocking show_email in the tests, since the
show_email code is in `settings_org` and
kind of hard to unit test.  It's not impossible,
but it's too much for this commit.  (Either
we need to extract it out to a nice file or
deal with mocking jQuery.  That module is
mostly data-oriented, so it would be nice
to have something like `settings_config` that
is actually pure data.)
			
			
This commit is contained in:
		@@ -995,6 +995,18 @@ exports.matches_user_settings_search = function (person, value) {
 | 
			
		||||
    );
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
exports.email_for_user_settings = function (person) {
 | 
			
		||||
    if (!settings_org.show_email()) {
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (page_params.is_admin && person.delivery_email) {
 | 
			
		||||
        return person.delivery_email;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return person.email;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
exports.maybe_incr_recipient_count = function (message) {
 | 
			
		||||
    if (message.type !== 'private') {
 | 
			
		||||
        return;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user