-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: handle the uninstall action (#572)
- Loading branch information
1 parent
a38c4dc
commit 5401bef
Showing
3 changed files
with
46 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from typing import Any | ||
from github import Github, Auth | ||
from github import GithubException | ||
from core.dao.repositoryConfigDAO import RepositoryConfigDAO | ||
|
||
|
||
class InstallEventHandler: | ||
event: Any | ||
auth: Auth.AppAuth | ||
g: Github | ||
|
||
def __init__(self, payload: Any, auth: Auth.AppAuth, installation_id: int) -> None: | ||
self.event: Any = payload | ||
self.auth: Auth.AppAuth = auth | ||
self.g: Github = Github(auth=auth) | ||
|
||
def delete_config(self): | ||
repositories = self.event["repositories"] | ||
repo_ids = [str(repo["id"]) for repo in repositories] | ||
repository_config = RepositoryConfigDAO() | ||
repository_config.delete_by_repo_ids(repo_ids) | ||
|
||
async def execute(self): | ||
try: | ||
action = self.event["action"] | ||
if action == "deleted": | ||
self.delete_config() | ||
return {"success": True} | ||
except GithubException as e: | ||
print(f"处理 GitHub 请求时出错:{e}") | ||
return {"success": False, "error": str(e)} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters