Skip to content

Commit 05904e1

Browse files
committed
Re-sync all users for all the organizations the user belongs to
1 parent f143538 commit 05904e1

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

readthedocs/api/v2/views/integrations.py

+14-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from rest_framework.status import HTTP_400_BAD_REQUEST
1818
from rest_framework.views import APIView
1919

20+
from readthedocs.core.permissions import AdminPermission
2021
from readthedocs.core.signals import (
2122
webhook_bitbucket,
2223
webhook_github,
@@ -464,7 +465,19 @@ def handle_webhook(self):
464465
provider=GitHubProvider.id,
465466
uid=uid,
466467
)
467-
sync_remote_repositories.delay(socialaccount.user.pk)
468+
469+
# Retrieve all organization the user belongs to
470+
organization_slugs = set(
471+
AdminPermission.projects(
472+
socialaccount.user,
473+
admin=True,
474+
member=True,
475+
).values_list('organizations__slug', flat=True)
476+
)
477+
if organization_slugs:
478+
sync_remote_repositories_organizations(organization_slugs=organization_slugs)
479+
else:
480+
sync_remote_repositories.delay(socialaccount.user.pk)
468481

469482
return None
470483

0 commit comments

Comments
 (0)