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