mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-04-25 11:18:22 +00:00
feat(feishu): add configurable domain for Lark international support (#1535)
The lark-oapi SDK defaults to open.feishu.cn (China), but apps on the international Lark platform (open.larksuite.com) fail to connect with error 1000040351 'Incorrect domain name'. Changes: - Add 'domain' config option to feishu channel (default: open.feishu.cn) - Pass domain to both API client and WebSocket client - Update config.example.yaml and all README files
This commit is contained in:
parent
9bcdba6038
commit
7db95926b0
@ -323,6 +323,8 @@ channels:
|
|||||||
enabled: true
|
enabled: true
|
||||||
app_id: $FEISHU_APP_ID
|
app_id: $FEISHU_APP_ID
|
||||||
app_secret: $FEISHU_APP_SECRET
|
app_secret: $FEISHU_APP_SECRET
|
||||||
|
# domain: https://open.feishu.cn # China (default)
|
||||||
|
# domain: https://open.larksuite.com # International
|
||||||
|
|
||||||
slack:
|
slack:
|
||||||
enabled: true
|
enabled: true
|
||||||
|
|||||||
@ -314,6 +314,8 @@ channels:
|
|||||||
enabled: true
|
enabled: true
|
||||||
app_id: $FEISHU_APP_ID
|
app_id: $FEISHU_APP_ID
|
||||||
app_secret: $FEISHU_APP_SECRET
|
app_secret: $FEISHU_APP_SECRET
|
||||||
|
# domain: https://open.feishu.cn # China (default)
|
||||||
|
# domain: https://open.larksuite.com # International
|
||||||
|
|
||||||
slack:
|
slack:
|
||||||
enabled: true
|
enabled: true
|
||||||
|
|||||||
@ -267,6 +267,8 @@ channels:
|
|||||||
enabled: true
|
enabled: true
|
||||||
app_id: $FEISHU_APP_ID
|
app_id: $FEISHU_APP_ID
|
||||||
app_secret: $FEISHU_APP_SECRET
|
app_secret: $FEISHU_APP_SECRET
|
||||||
|
# domain: https://open.feishu.cn # China (default)
|
||||||
|
# domain: https://open.larksuite.com # International
|
||||||
|
|
||||||
slack:
|
slack:
|
||||||
enabled: true
|
enabled: true
|
||||||
|
|||||||
@ -265,6 +265,8 @@ channels:
|
|||||||
enabled: true
|
enabled: true
|
||||||
app_id: $FEISHU_APP_ID
|
app_id: $FEISHU_APP_ID
|
||||||
app_secret: $FEISHU_APP_SECRET
|
app_secret: $FEISHU_APP_SECRET
|
||||||
|
# domain: https://open.feishu.cn # China (default)
|
||||||
|
# domain: https://open.larksuite.com # International
|
||||||
|
|
||||||
slack:
|
slack:
|
||||||
enabled: true
|
enabled: true
|
||||||
|
|||||||
@ -255,6 +255,8 @@ channels:
|
|||||||
enabled: true
|
enabled: true
|
||||||
app_id: $FEISHU_APP_ID
|
app_id: $FEISHU_APP_ID
|
||||||
app_secret: $FEISHU_APP_SECRET
|
app_secret: $FEISHU_APP_SECRET
|
||||||
|
# domain: https://open.feishu.cn # 国内版(默认)
|
||||||
|
# domain: https://open.larksuite.com # 国际版
|
||||||
|
|
||||||
slack:
|
slack:
|
||||||
enabled: true
|
enabled: true
|
||||||
|
|||||||
@ -92,12 +92,14 @@ class FeishuChannel(Channel):
|
|||||||
|
|
||||||
app_id = self.config.get("app_id", "")
|
app_id = self.config.get("app_id", "")
|
||||||
app_secret = self.config.get("app_secret", "")
|
app_secret = self.config.get("app_secret", "")
|
||||||
|
domain = self.config.get("domain", "https://open.feishu.cn")
|
||||||
|
|
||||||
if not app_id or not app_secret:
|
if not app_id or not app_secret:
|
||||||
logger.error("Feishu channel requires app_id and app_secret")
|
logger.error("Feishu channel requires app_id and app_secret")
|
||||||
return
|
return
|
||||||
|
|
||||||
self._api_client = lark.Client.builder().app_id(app_id).app_secret(app_secret).build()
|
self._api_client = lark.Client.builder().app_id(app_id).app_secret(app_secret).domain(domain).build()
|
||||||
|
logger.info("[Feishu] using domain: %s", domain)
|
||||||
self._main_loop = asyncio.get_event_loop()
|
self._main_loop = asyncio.get_event_loop()
|
||||||
|
|
||||||
self._running = True
|
self._running = True
|
||||||
@ -109,13 +111,13 @@ class FeishuChannel(Channel):
|
|||||||
# which conflicts with an already-running uvloop.
|
# which conflicts with an already-running uvloop.
|
||||||
self._thread = threading.Thread(
|
self._thread = threading.Thread(
|
||||||
target=self._run_ws,
|
target=self._run_ws,
|
||||||
args=(app_id, app_secret),
|
args=(app_id, app_secret, domain),
|
||||||
daemon=True,
|
daemon=True,
|
||||||
)
|
)
|
||||||
self._thread.start()
|
self._thread.start()
|
||||||
logger.info("Feishu channel started")
|
logger.info("Feishu channel started")
|
||||||
|
|
||||||
def _run_ws(self, app_id: str, app_secret: str) -> None:
|
def _run_ws(self, app_id: str, app_secret: str, domain: str) -> None:
|
||||||
"""Construct and run the lark WS client in a thread with a fresh event loop.
|
"""Construct and run the lark WS client in a thread with a fresh event loop.
|
||||||
|
|
||||||
The lark-oapi SDK captures a module-level event loop at import time
|
The lark-oapi SDK captures a module-level event loop at import time
|
||||||
@ -145,6 +147,7 @@ class FeishuChannel(Channel):
|
|||||||
app_secret=app_secret,
|
app_secret=app_secret,
|
||||||
event_handler=event_handler,
|
event_handler=event_handler,
|
||||||
log_level=lark.LogLevel.INFO,
|
log_level=lark.LogLevel.INFO,
|
||||||
|
domain=domain,
|
||||||
)
|
)
|
||||||
ws_client.start()
|
ws_client.start()
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|||||||
@ -617,6 +617,8 @@ checkpointer:
|
|||||||
# enabled: false
|
# enabled: false
|
||||||
# app_id: $FEISHU_APP_ID
|
# app_id: $FEISHU_APP_ID
|
||||||
# app_secret: $FEISHU_APP_SECRET
|
# app_secret: $FEISHU_APP_SECRET
|
||||||
|
# # domain: https://open.feishu.cn # China (default)
|
||||||
|
# # domain: https://open.larksuite.com # International
|
||||||
#
|
#
|
||||||
# slack:
|
# slack:
|
||||||
# enabled: false
|
# enabled: false
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user