Use user's full name even when email is not configured
Change-Id: If29a9fc1e479c1c0413a43272c9f154dd59e8aba
This commit is contained in:
		
				
					committed by
					
						
						Shawn Pearce
					
				
			
			
				
	
			
			
			
						parent
						
							253611e965
						
					
				
				
					commit
					c3c6e478c5
				
			@@ -98,10 +98,11 @@ public class FromAddressGeneratorProvider implements
 | 
			
		||||
    @Override
 | 
			
		||||
    public Address from(final Account.Id fromId) {
 | 
			
		||||
      if (fromId != null) {
 | 
			
		||||
        final Account a = accountCache.get(fromId).getAccount();
 | 
			
		||||
        if (a.getPreferredEmail() != null) {
 | 
			
		||||
          return new Address(a.getFullName(), a.getPreferredEmail());
 | 
			
		||||
        }
 | 
			
		||||
        Account a = accountCache.get(fromId).getAccount();
 | 
			
		||||
        String userEmail = a.getPreferredEmail();
 | 
			
		||||
        return new Address(
 | 
			
		||||
            a.getFullName(),
 | 
			
		||||
            userEmail != null ? userEmail : srvAddr.getEmail());
 | 
			
		||||
      }
 | 
			
		||||
      return srvAddr;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -102,12 +102,13 @@ public class FromAddressGeneratorProviderTest extends TestCase {
 | 
			
		||||
  public void testUSER_NoPreferredEmailUser() {
 | 
			
		||||
    setFrom("USER");
 | 
			
		||||
 | 
			
		||||
    final Account.Id user = user("A U. Thor", null);
 | 
			
		||||
    final String name = "A U. Thor";
 | 
			
		||||
    final Account.Id user = user(name, null);
 | 
			
		||||
 | 
			
		||||
    replay(accountCache);
 | 
			
		||||
    final Address r = create().from(user);
 | 
			
		||||
    assertNotNull(r);
 | 
			
		||||
    assertEquals(ident.getName(), r.name);
 | 
			
		||||
    assertEquals(name, r.name);
 | 
			
		||||
    assertEquals(ident.getEmailAddress(), r.email);
 | 
			
		||||
    verify(accountCache);
 | 
			
		||||
  }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user