adjust event data
continuous-integration/drone/push Build is passing

This commit is contained in:
jianxin committed 2024-04-10 14:38:04 +08:00
1 parent 240ebff657
commit d3af172a77
3 files changed
+28 -32

No files matched your search

+2
View File
@@ -120,6 +120,8 @@ def do_bitable_record_add(data) -> None:
print(f"target_action: {target_action.get('action')}")
print(action_data)
process_new_demand.delay(app_id, app_secret, action_data)
handler = (
lark.EventDispatcherHandler.builder(
+23
View File
@@ -8,6 +8,7 @@ from celery import Task
from app.utils.utils import *
from app.utils.yd_utils import get_token, get_activity_info
from app.utils.feishu import create_doc, get_doc_block, create_doc_block
@shared_task(include_result=False)
@@ -123,3 +124,25 @@ def sync_xbot_activity_info():
)
print(f"新增的数量: {len(handle_list)}")
print("新增的uuid: ", handle_list)
@shared_task(include_result=False)
def process_new_demand(app_id, app_secret, data):
title = data.get("title")
background = data.get("background")
features = data.get("features")
client = (
lark.Client.builder()
.app_id(app_id)
.app_secret(app_secret)
.log_level(lark.LogLevel.DEBUG)
.build()
)
space_id = "7268552249415319554"
parent_node_token = "ADkFwlLhmiLcqAk3QXLcZnHAnHf"
doc_id = create_doc(client, space_id, parent_node_token, title)
block_id = get_doc_block(client, doc_id)
create_doc_block(client, doc_id, block_id, background, features)
+3 -32
View File
@@ -111,8 +111,7 @@ def create_doc(client, space_id, parent_node_token, title):
)
return
# 处理业务结果
lark.logger.info(lark.JSON.marshal(response.data, indent=4))
return response.data.node.obj_token
def get_doc_block(client, document_id):
@@ -145,7 +144,7 @@ def get_doc_block(client, document_id):
return
# 处理业务结果
lark.logger.info(lark.JSON.marshal(response.data, indent=4))
return response.data.items[0].block_id
def create_doc_block(
@@ -254,35 +253,7 @@ def create_doc_block(
if __name__ == "__main__":
app_id = os.environ["APP_ID"]
app_secret = os.environ["APP_SECRET"]
data = {
"title": '[{"type":"text","text":"测试"}]',
"background": '[{"type":"text","text":"测试"}]',
"features": '[{"type":"text","text":"测试"}]',
}
client = (
lark.Client.builder()
.app_id(app_id)
.app_secret(app_secret)
.log_level(lark.LogLevel.DEBUG)
.build()
)
# folder_token = "ADkFwlLhmiLcqAk3QXLcZnHAnHf"
title = "测试"
space_id = "7268552249415319554"
parent_node_token = "ADkFwlLhmiLcqAk3QXLcZnHAnHf"
# create_doc(client, space_id, parent_node_token, title)
doc_id = "N81ldXDuuoxtXZxUz55coxApnOh"
# get_doc_block(client, doc_id)
block_id = "N81ldXDuuoxtXZxUz55coxApnOh"
create_doc_block(client, doc_id, block_id)
pass