File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change 1717from rest_framework .status import HTTP_400_BAD_REQUEST
1818from rest_framework .views import APIView
1919
20+ from readthedocs .core .permissions import AdminPermission
2021from 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 organizations :
478+ sync_remote_repositories_organizations (organization_slugs = organization_slugs )
479+ else :
480+ sync_remote_repositories .delay (socialaccount .user .pk )
468481
469482 return None
470483
You can’t perform that action at this time.
0 commit comments