feeds: generate entries with proper unique ids.

- fixes #5379
This commit is contained in:
Marcin Lulek 2017-09-01 16:05:06 +02:00
parent 8f02ca668c
commit a307f2677c
2 changed files with 26 additions and 14 deletions

View file

@ -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

View file

@ -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),