Skip to content

Commit

Permalink
Re-sync all users for all the organizations the user belongs to
Browse files Browse the repository at this point in the history
  • Loading branch information
humitos committed Oct 21, 2021
1 parent f143538 commit 05904e1
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion readthedocs/api/v2/views/integrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from rest_framework.status import HTTP_400_BAD_REQUEST
from rest_framework.views import APIView

from readthedocs.core.permissions import AdminPermission
from readthedocs.core.signals import (
webhook_bitbucket,
webhook_github,
Expand Down Expand Up @@ -464,7 +465,19 @@ def handle_webhook(self):
provider=GitHubProvider.id,
uid=uid,
)
sync_remote_repositories.delay(socialaccount.user.pk)

# Retrieve all organization the user belongs to
organization_slugs = set(
AdminPermission.projects(
socialaccount.user,
admin=True,
member=True,
).values_list('organizations__slug', flat=True)
)
if organization_slugs:
sync_remote_repositories_organizations(organization_slugs=organization_slugs)
else:
sync_remote_repositories.delay(socialaccount.user.pk)

return None

Expand Down

0 comments on commit 05904e1

Please sign in to comment.