# HG changeset patch # User Marcin Lulek # Date 2017-09-01 14:05:06 # Node ID 263f1c18b3934775d5f79ebec1ac29dfe2b4c8e1 # Parent 7939c6bfd1509cb8a818908d64bb05c6d790bbd2 feeds: generate entries with proper unique ids. - fixes #5379 diff --git a/rhodecode/apps/journal/views.py b/rhodecode/apps/journal/views.py --- a/rhodecode/apps/journal/views.py +++ b/rhodecode/apps/journal/views.py @@ -37,7 +37,7 @@ import rhodecode.lib.helpers as h from rhodecode.lib.helpers import Page from rhodecode.lib.user_log_filter import user_log_filter from rhodecode.lib.auth import LoginRequired, NotAnonymous, CSRFRequired -from rhodecode.lib.utils2 import safe_int, AttributeDict +from rhodecode.lib.utils2 import safe_int, AttributeDict, md5_safe from rhodecode.model.scm import ScmModel log = logging.getLogger(__name__) @@ -121,6 +121,9 @@ class JournalView(BaseAppView): return journal + def feed_uid(self, entry_id): + return '{}:{}'.format('journal', md5_safe(entry_id)) + def _atom_feed(self, repos, search_term, public=True): _ = self.request.translate journal = self._get_journal_data(repos, search_term) @@ -152,12 +155,14 @@ class JournalView(BaseAppView): _url = h.route_url('repo_changelog', repo_name=entry.repository.repo_name) - feed.add_item(title=title, - pubdate=entry.action_date, - link=_url, - author_email=user.email, - author_name=user.full_contact, - description=desc) + feed.add_item( + unique_id=self.feed_uid(entry.user_log_id), + title=title, + pubdate=entry.action_date, + link=_url, + author_email=user.email, + author_name=user.full_contact, + description=desc) response = Response(feed.writeString('utf-8')) response.content_type = feed.mime_type @@ -195,12 +200,14 @@ class JournalView(BaseAppView): _url = h.route_url('repo_changelog', repo_name=entry.repository.repo_name) - feed.add_item(title=title, - pubdate=entry.action_date, - link=_url, - author_email=user.email, - author_name=user.full_contact, - description=desc) + feed.add_item( + unique_id=self.feed_uid(entry.user_log_id), + title=title, + pubdate=entry.action_date, + link=_url, + author_email=user.email, + author_name=user.full_contact, + description=desc) response = Response(feed.writeString('utf-8')) response.content_type = feed.mime_type diff --git a/rhodecode/apps/repository/views/repo_feed.py b/rhodecode/apps/repository/views/repo_feed.py --- a/rhodecode/apps/repository/views/repo_feed.py +++ b/rhodecode/apps/repository/views/repo_feed.py @@ -32,7 +32,7 @@ from rhodecode.lib import helpers as h from rhodecode.lib.auth import ( LoginRequired, HasRepoPermissionAnyDecorator) from rhodecode.lib.diffs import DiffProcessor, LimitedDiffContainer -from rhodecode.lib.utils2 import str2bool, safe_int +from rhodecode.lib.utils2 import str2bool, safe_int, md5_safe from rhodecode.model.db import UserApiKeys, CacheKey log = logging.getLogger(__name__) @@ -109,6 +109,9 @@ class RepoFeedView(RepoAppView): def _get_commits(self): return list(self.rhodecode_vcs_repo[-self.feed_items_per_page:]) + def uid(self, repo_id, commit_id): + return '{}:{}'.format(md5_safe(repo_id), md5_safe(commit_id)) + @LoginRequired(auth_token_access=[UserApiKeys.ROLE_FEED]) @HasRepoPermissionAnyDecorator( 'repository.read', 'repository.write', 'repository.admin') @@ -134,6 +137,7 @@ class RepoFeedView(RepoAppView): for commit in reversed(self._get_commits()): date = self._set_timezone(commit.date) feed.add_item( + unique_id=self.uid(self.db_repo.repo_id, commit.raw_id), title=self._get_title(commit), author_name=commit.author, description=self._get_description(commit), @@ -180,6 +184,7 @@ class RepoFeedView(RepoAppView): for commit in reversed(self._get_commits()): date = self._set_timezone(commit.date) feed.add_item( + unique_id=self.uid(self.db_repo.repo_id, commit.raw_id), title=self._get_title(commit), author_name=commit.author, description=self._get_description(commit),