예제 #1
0
  def __init__(self, user, is_group=False):
    self.user = user
    self.is_group = is_group
    email = user.email or ''
    self.user_id = user.user_id
    self.email = email
    if user.obscure_email:
      self.profile_url = '/u/%s/' % user.user_id
    else:
      self.profile_url = '/u/%s/' % email
    self.obscure_email = user.obscure_email
    self.banned = ''

    (self.username, self.domain,
     self.obscured_username) = ParseAndObscureAddress(email)
    # No need to obfuscate or reveal client email.
    # Instead display a human-readable username.
    if self.user_id == framework_constants.DELETED_USER_ID:
      self.display_name = framework_constants.DELETED_USER_NAME
      self.obscure_email = ''
      self.profile_url = ''
    elif self.email in client_config_svc.GetServiceAccountMap():
      self.display_name = client_config_svc.GetServiceAccountMap()[self.email]
    elif not self.obscure_email:
      self.display_name = email
    else:
      self.display_name = '%s...@%s' % (self.obscured_username, self.domain)

    self.avail_message, self.avail_state = (
        framework_helpers.GetUserAvailability(user, is_group))
    self.avail_message_short = template_helpers.FitUnsafeText(
        self.avail_message, 35)
예제 #2
0
 def RevealEmail(self):
   if not self.email:
     return
   if self.email not in client_config_svc.GetServiceAccountMap():
     self.obscure_email = False
     self.display_name = self.email
     self.profile_url = '/u/%s/' % self.email
예제 #3
0
def FormatFriendly(commenter_view, sender, reveal_addr):
  """Format the From: line to include the commenter's friendly name if given."""
  if commenter_view:
    site_name = settings.site_name.lower()
    if commenter_view.email in client_config_svc.GetServiceAccountMap():
      friendly = commenter_view.display_name
    elif reveal_addr:
      friendly = commenter_view.email
    else:
      friendly = u'%s\u2026@%s' % (
          commenter_view.obscured_username, commenter_view.domain)
    if '@' in sender:
      sender_username, sender_domain = sender.split('@', 1)
      sender = '%s+v2.%d@%s' % (
          sender_username, commenter_view.user_id, sender_domain)
      friendly = friendly.split('@')[0]
    return '%s via %s <%s>' % (friendly, site_name, sender)
  else:
    return sender
예제 #4
0
 def testGetServiceAccountMap(self):
     service_account_map = client_config_svc.GetServiceAccountMap()
     self.assertIn(self.client_email, service_account_map)
     self.assertEqual('*****@*****.**',
                      service_account_map[self.client_email])
     self.assertNotIn('*****@*****.**', service_account_map)