Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 40 additions & 2 deletions ForgejoRepoAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,32 @@ def get_comments(self, repo, obj) -> list[Comment]:

return result

def get_invites(self, repo: Repository) -> list[Invite]:
return []
def get_invites(self, repo: Repository, users: list[User] = None) -> list[Invite]:
if users is None:
return []

try:
collaborators = self.client.repository.repo_list_collaborators(
owner=repo.owner.login, repo=repo.name
)
collab_logins = {c.login for c in collaborators}

invites = []
for user in users:
if user.login not in collab_logins:
invites.append(
Invite(
_id=0,
invitee=user,
created_at=None,
html_url=user.html_url,
)
)
return invites

except Exception as e:
logging.error(f"Failed to simulate invites for Forgejo repo {repo.name}: {e}")
return []

def get_rate_limiting(self) -> tuple[int, int]:
return sys.maxsize, sys.maxsize
Expand Down Expand Up @@ -352,3 +376,17 @@ def get_rate_limiting(self) -> tuple[int, int]:
print(
f"Branch: {branch.name}, Last Commit: {branch.last_commit._id if branch.last_commit else 'None'}"
)

# Получение приглашений
test_users = [
User(login="user1", username="User One", email="", html_url="", node_id="",
type="", bio="", site_admin=False, _id=""),
User(login="user2", username="User Two", email="", html_url="", node_id="",
type="", bio="", site_admin=False, _id=""),
]

invites = api.get_invites(repo, users=test_users)
print(f"Total Invites: {len(invites)}")

for invite in invites:
print(f"Invitee: {invite.invitee.username}, URL: {invite.html_url}")
2 changes: 1 addition & 1 deletion interface_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class PullRequest:
class Invite:
_id: int
invitee: User
created_at: datetime
created_at: datetime | None
html_url: str


Expand Down