From b550974f7d6c08429aa43e04b270bf04aaf82293 Mon Sep 17 00:00:00 2001 From: freeziyou <80776877@qq.com> Date: Tue, 27 Feb 2024 18:33:13 +0800 Subject: [PATCH 1/3] hotfix os import --- server/tasks/lark/chat.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/tasks/lark/chat.py b/server/tasks/lark/chat.py index 64e08ae6..5486311d 100644 --- a/server/tasks/lark/chat.py +++ b/server/tasks/lark/chat.py @@ -292,11 +292,11 @@ def create_issue( # 这里连三个表查询,所以一次性都查出来 code_users = get_code_users_by_openid([openid] + users) - import tasks - if openid not in code_users: host = os.environ.get("DOMAIN") + import tasks + return tasks.send_manage_fail_message( f"[请点击绑定 GitHub 账号后重试]({host}/api/github/oauth)", app_id, From 1654af7c396db2047da48db76db0416b496a1fb5 Mon Sep 17 00:00:00 2001 From: freeziyou <80776877@qq.com> Date: Tue, 27 Feb 2024 18:39:52 +0800 Subject: [PATCH 2/3] hotfix os import --- server/tasks/lark/chat.py | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/server/tasks/lark/chat.py b/server/tasks/lark/chat.py index 5486311d..e7c6c2ac 100644 --- a/server/tasks/lark/chat.py +++ b/server/tasks/lark/chat.py @@ -5,23 +5,13 @@ from urllib.parse import urlparse from celery_app import app, celery -from model.schema import ( - ChatGroup, - CodeApplication, - CodeUser, - IMUser, - Repo, - Team, - TeamMember, - db, -) +from model.schema import ChatGroup, CodeApplication, Repo, Team, db from model.team import get_code_users_by_openid -from sqlalchemy.orm import aliased from tasks.lark.issue import replace_im_name_to_github_name +from tasks.lark.manage import send_manage_fail_message from utils.github.repo import GitHubAppRepo from utils.lark.chat_manual import ChatManual, ChatView from utils.lark.chat_tip_failed import ChatTipFailed -from utils.lark.issue_card import IssueCard from utils.lark.post_message import post_content_to_markdown from .base import ( @@ -295,9 +285,7 @@ def create_issue( if openid not in code_users: host = os.environ.get("DOMAIN") - import tasks - - return tasks.send_manage_fail_message( + return send_manage_fail_message( f"[请点击绑定 GitHub 账号后重试]({host}/api/github/oauth)", app_id, message_id, @@ -455,12 +443,10 @@ def sync_issue( # 这里连三个表查询,所以一次性都查出来 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( + return send_manage_fail_message( f"[请点击绑定 GitHub 账号后重试]({host}/api/github/oauth)", app_id, message_id, From ebc08147ad4f74298eeca849d4d5b9a33585998d Mon Sep 17 00:00:00 2001 From: freeziyou <80776877@qq.com> Date: Tue, 27 Feb 2024 18:42:03 +0800 Subject: [PATCH 3/3] hotfix os import --- server/tasks/lark/chat.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/server/tasks/lark/chat.py b/server/tasks/lark/chat.py index e7c6c2ac..16e72f55 100644 --- a/server/tasks/lark/chat.py +++ b/server/tasks/lark/chat.py @@ -7,6 +7,8 @@ from celery_app import app, celery from model.schema import ChatGroup, CodeApplication, Repo, Team, db from model.team import get_code_users_by_openid +from tasks.github.issue import on_issue_opened +from tasks.github.pull_request import on_pull_request_opened from tasks.lark.issue import replace_im_name_to_github_name from tasks.lark.manage import send_manage_fail_message from utils.github.repo import GitHubAppRepo @@ -468,7 +470,7 @@ def sync_issue( if is_pr: pull_request = github_app.get_one_pull_request(team.name, repo.name, issue_id) logging.debug("get_one_pull_requrst %r", pull_request) - return tasks.on_pull_request_opened( + return on_pull_request_opened( { "action": "opened", "sender": pull_request["user"], @@ -479,7 +481,7 @@ def sync_issue( else: issue = github_app.get_one_issue(team.name, repo.name, issue_id) logging.debug("get_one_issue %r", issue) - return tasks.on_issue_opened( + return on_issue_opened( { "action": "opened", "sender": issue["user"],