@@ -299,8 +299,32 @@ def get_comments(self, repo, obj) -> list[Comment]:
299299
300300 return result
301301
302- def get_invites (self , repo : Repository ) -> list [Invite ]:
303- return []
302+ def get_invites (self , repo : Repository , users : list [User ] = None ) -> list [Invite ]:
303+ if users is None :
304+ return []
305+
306+ try :
307+ collaborators = self .client .repository .repo_list_collaborators (
308+ owner = repo .owner .login , repo = repo .name
309+ )
310+ collab_logins = {c .login for c in collaborators }
311+
312+ invites = []
313+ for user in users :
314+ if user .login not in collab_logins :
315+ invites .append (
316+ Invite (
317+ _id = 0 ,
318+ invitee = user ,
319+ created_at = None ,
320+ html_url = user .html_url ,
321+ )
322+ )
323+ return invites
324+
325+ except Exception as e :
326+ logging .error (f"Failed to simulate invites for Forgejo repo { repo .name } : { e } " )
327+ return []
304328
305329 def get_rate_limiting (self ) -> tuple [int , int ]:
306330 return sys .maxsize , sys .maxsize
@@ -352,3 +376,17 @@ def get_rate_limiting(self) -> tuple[int, int]:
352376 print (
353377 f"Branch: { branch .name } , Last Commit: { branch .last_commit ._id if branch .last_commit else 'None' } "
354378 )
379+
380+ # Получение приглашений
381+ test_users = [
382+ User (login = "user1" , username = "User One" , email = "" , html_url = "" , node_id = "" ,
383+ type = "" , bio = "" , site_admin = False , _id = "" ),
384+ User (login = "user2" , username = "User Two" , email = "" , html_url = "" , node_id = "" ,
385+ type = "" , bio = "" , site_admin = False , _id = "" ),
386+ ]
387+
388+ invites = api .get_invites (repo , users = test_users )
389+ print (f"Total Invites: { len (invites )} " )
390+
391+ for invite in invites :
392+ print (f"Invitee: { invite .invitee .username } , URL: { invite .html_url } " )
0 commit comments