File tree 1 file changed +14
-1
lines changed
1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change 17
17
from rest_framework .status import HTTP_400_BAD_REQUEST
18
18
from rest_framework .views import APIView
19
19
20
+ from readthedocs .core .permissions import AdminPermission
20
21
from readthedocs .core .signals import (
21
22
webhook_bitbucket ,
22
23
webhook_github ,
@@ -464,7 +465,19 @@ def handle_webhook(self):
464
465
provider = GitHubProvider .id ,
465
466
uid = uid ,
466
467
)
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 )
468
481
469
482
return None
470
483
You can’t perform that action at this time.
0 commit comments