Skip to content

Commit

Permalink
Merge pull request #200 from ConnectAI-E/feature-lloyd-2024020201
Browse files Browse the repository at this point in the history
创建issue 失败
  • Loading branch information
lloydzhou authored Feb 2, 2024
2 parents a80eb69 + ad04c32 commit 6062419
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
6 changes: 6 additions & 0 deletions server/tasks/github/issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ def on_issue_opened(event_dict: dict | None) -> list:
issue_info = event.issue

repo = db.session.query(Repo).filter(Repo.repo_id == event.repository.id).first()
if not repo:
app.logger.error(f"Failed to find repo: {event_dict}")
return []
# 检查是否已经创建过 issue
issue = (
db.session.query(Issue)
Expand Down Expand Up @@ -177,6 +180,9 @@ def on_issue_updated(event_dict: dict) -> list:
issue_info = event.issue

repo = db.session.query(Repo).filter(Repo.repo_id == event.repository.id).first()
if not repo:
app.logger.error(f"Failed to find repo: {event_dict}")
return []
# 修改 issue
issue = (
db.session.query(Issue)
Expand Down
3 changes: 3 additions & 0 deletions server/tasks/github/pull_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ def on_pull_request_opened(event_dict: dict | list | None) -> list:
pr_info = event.pull_request

repo = db.session.query(Repo).filter(Repo.repo_id == event.repository.id).first()
if not repo:
app.logger.error(f"Failed to find repo: {event_dict}")
return []
# 检查是否已经创建过 pullrequest
pr = (
db.session.query(PullRequest)
Expand Down
34 changes: 32 additions & 2 deletions server/tasks/lark/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,22 @@ def create_issue(
openid = data["event"]["sender"]["sender_id"]["open_id"]
# 这里连三个表查询,所以一次性都查出来
code_users = get_code_users_by_openid([openid] + users)

import tasks

if openid not in code_users:
host = os.environ.get("DOMAIN")

return tasks.send_manage_fail_message(
f"[请点击绑定 GitHub 账号后重试]({host}/api/github/oauth)",
app_id,
message_id,
content,
data,
*args,
**kwargs,
)

# 当前操作的用户
current_code_user_id = code_users[openid][0]

Expand Down Expand Up @@ -353,15 +369,29 @@ def sync_issue(
openid = data["event"]["sender"]["sender_id"]["open_id"]
# 这里连三个表查询,所以一次性都查出来
code_users = get_code_users_by_openid([openid])

import tasks

if openid not in code_users:
host = os.environ.get("DOMAIN")

return tasks.send_manage_fail_message(
f"[请点击绑定 GitHub 账号后重试]({host}/api/github/oauth)",
app_id,
message_id,
content,
data,
*args,
**kwargs,
)

# 当前操作的用户
current_code_user_id = code_users[openid][0]

github_app = GitHubAppRepo(
code_application.installation_id, user_id=current_code_user_id
)

import tasks

# 后面需要插入记录,再发卡片,创建话题
repository = github_app.get_repo_info_by_name(team.name, repo.name)
if is_pr:
Expand Down

0 comments on commit 6062419

Please sign in to comment.