@@ -82,7 +82,7 @@ def get_user_access_token(request, code, redirect_uri):
8282 return success ({"token" : token })
8383
8484
85- def build_card_content (chat_id , message_id , message , upvote = False , downvote = False ):
85+ def build_card_content (chat_id , message_id , message , feedback_type = None ):
8686 return {
8787 "config" : {
8888 "wide_screen_mode" : True
@@ -101,9 +101,9 @@ def build_card_content(chat_id, message_id, message, upvote=False, downvote=Fals
101101 "tag" : "plain_text" ,
102102 "content" : "赞"
103103 },
104- "type" : "primary" if upvote else "default" ,
104+ "type" : "primary" if feedback_type == "good" else "default" ,
105105 "value" : {
106- "upvote " : True ,
106+ "type " : "good" ,
107107 "message_id" : f"{ message_id } " ,
108108 "chat_id" : f"{ chat_id } " ,
109109 }
@@ -114,9 +114,9 @@ def build_card_content(chat_id, message_id, message, upvote=False, downvote=Fals
114114 "tag" : "plain_text" ,
115115 "content" : "踩"
116116 },
117- "type" : "primary" if downvote else "default" ,
117+ "type" : "primary" if feedback_type == "bad" else "default" ,
118118 "value" : {
119- "downvote " : True ,
119+ "type " : "bad" ,
120120 "message_id" : f"{ message_id } " ,
121121 "chat_id" : f"{ chat_id } " ,
122122 }
@@ -128,10 +128,10 @@ def build_card_content(chat_id, message_id, message, upvote=False, downvote=Fals
128128 }
129129
130130
131- def build_card_data (chat_id , message_id , message , upvote = False , downvote = False ):
131+ def build_card_data (chat_id , message_id , message , feedback_type = None ):
132132 return {
133133 "msg_type" : "interactive" ,
134- "content" : json .dumps (build_card_content (chat_id , message_id , message , upvote , downvote )),
134+ "content" : json .dumps (build_card_content (chat_id , message_id , message , feedback_type )),
135135 }
136136
137137
@@ -173,9 +173,8 @@ async def feishu_response_card_update(user, bot_id, data):
173173 value = action ["value" ]
174174 chat_id = value ["chat_id" ]
175175 msg_id = value ["message_id" ]
176- upvote = value .get ("upvote" , None )
177- downvote = value .get ("downvote" , None )
178- await aperag .chat .message .feedback_message (user , chat_id , msg_id , upvote , downvote , "" )
176+ feedback_type = value .get ("type" , None )
177+ await aperag .chat .message .feedback_message (user , chat_id , msg_id , feedback_type , None , None )
179178
180179 bot = await query_bot (user , bot_id )
181180 bot_config = json .loads (bot .config )
@@ -192,7 +191,7 @@ async def feishu_response_card_update(user, bot_id, data):
192191 }
193192 client = FeishuClient (ctx )
194193 token = data ["token" ]
195- card = build_card_content (chat_id , msg_id , msg_cache [msg_id ], upvote , downvote )
194+ card = build_card_content (chat_id , msg_id , msg_cache [msg_id ], feedback_type )
196195 card ["open_ids" ] = [data ["open_id" ]]
197196 data = {
198197 "token" : token ,
0 commit comments