Merge pull request #470 from mouse-reeve/duplicate-replies-in-feed

Fixes replies showing up twice in feed
This commit is contained in:
Mouse Reeve 2021-01-03 08:32:01 -08:00 committed by GitHub
commit 18e0347077
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -46,7 +46,8 @@ def is_api_request(request):
def is_bookworm_request(request):
''' check if the request is coming from another bookworm instance '''
user_agent = request.headers.get('User-Agent')
if user_agent is None or re.search(regex.bookwyrm_user_agent, user_agent) is None:
if user_agent is None or \
re.search(regex.bookwyrm_user_agent, user_agent) is None:
return False
return True
@ -181,7 +182,7 @@ def get_activity_feed(user, filter_level, model=models.Status):
return activities.filter(
Q(user=user) | Q(mention_users=user),
privacy='direct'
)
).distinct()
# never show DMs in the regular feed
activities = activities.filter(~Q(privacy='direct'))
@ -196,7 +197,7 @@ def get_activity_feed(user, filter_level, model=models.Status):
Q(user__in=following, privacy__in=[
'public', 'unlisted', 'followers'
]) | Q(mention_users=user) | Q(user=user)
)
).distinct()
elif filter_level == 'self':
activities = activities.filter(user=user, privacy='public')
elif filter_level == 'local':
@ -516,7 +517,8 @@ def status_page(request, username, status_id):
return HttpResponseNotFound()
if is_api_request(request):
return ActivitypubResponse(status.to_activity(pure=not is_bookworm_request(request)))
return ActivitypubResponse(
status.to_activity(pure=not is_bookworm_request(request)))
data = {
'title': 'Status by %s' % user.username,