Ticket #336: tracblog-rss-0.3.patch

File tracblog-rss-0.3.patch, 1.6 kB (added by kindlund@mitre.org, 2 years ago)

fix: RSS <author> fields now properly list email addresses from different blog posters

  • web_ui.py

    old new  
    255255        macro_bl = self.env.config.get('blog', 'macro_blacklist', '').split(',') 
    256256        macro_bl = [name.strip() for name in macro_bl if name.strip()] 
    257257        macro_bl.append('BlogShow') 
     258 
     259        # Get the email addresses of all known users 
     260        email_map = {} 
     261        for username, name, email in self.env.get_known_users(): 
     262            if email: 
     263                email_map[username] = email 
    258264                        
    259265        num_posts = self._choose_value('num_posts', req, kwargs, convert=int) 
    260266        if num_posts and default_times: 
     
    331337                    # For RSS, author must be an email address 
    332338                    if author.find('@') != -1: 
    333339                        data['author.email'] = author 
    334                     elif self._user2email(author) is not None
    335                         data['author.email'] = self._user2email(author) 
     340                    elif email_map.has_key(author)
     341                        data['author.email'] = email_map[author] 
    336342                 
    337343                if (modified != post_time) and mark_updated: 
    338344                    data['modified'] = 1 
     
    356362        req.hdf['blog.hidecal'] = hidecal 
    357363        pass 
    358364 
    359     def _user2email(self, user): 
    360         for username, name, email in self.env.get_known_users(): 
    361             if email: 
    362                 return email 
    363         return None 
    364  
    365365    def _generate_calendar(self, req, tallies): 
    366366        """Generate data necessary for the calendar 
    367367