@jeik/dingtalk-connector 0.8.27-fix2 → 0.8.27-fix3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as initDingtalkPluginConfigSchema, i as dingtalkPlugin, n as setDingtalkRuntime } from "./runtime-
|
|
1
|
+
import { a as initDingtalkPluginConfigSchema, i as dingtalkPlugin, n as setDingtalkRuntime } from "./runtime-8WBX1FSq.mjs";
|
|
2
2
|
import { t as registerGatewayMethods } from "./gateway-methods-CfTm9PW_.mjs";
|
|
3
3
|
//#region index.ts
|
|
4
4
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as resolveDingtalkAccount } from "./accounts-BAzdqkAV.mjs";
|
|
2
|
-
import { r as CHANNEL_ID, t as getDingtalkRuntime } from "./runtime-
|
|
2
|
+
import { r as CHANNEL_ID, t as getDingtalkRuntime } from "./runtime-8WBX1FSq.mjs";
|
|
3
3
|
import { n as createLoggerFromConfig } from "./logger-mZ9OSbmD.mjs";
|
|
4
4
|
import { t as dingtalkHttp } from "./http-client-DFWZgO1n.mjs";
|
|
5
5
|
import { i as getOapiAccessToken } from "./utils-CIfI_3Jh.mjs";
|
|
@@ -2265,30 +2265,29 @@ async function handleDingTalkMessageInternal(params) {
|
|
|
2265
2265
|
}
|
|
2266
2266
|
} catch (err) {
|
|
2267
2267
|
log?.error?.(`SDK dispatch 失败: ${err.message}`);
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
log?.error?.(`错误消息发送也失败: ${fallbackErr.message}`);
|
|
2268
|
+
if (replyOptions?.onError) {
|
|
2269
|
+
log?.info?.(`[DingTalk] 统一错误定稿:调用 replyOptions.onError 处理同步异常`);
|
|
2270
|
+
await replyOptions.onError(err, { kind: "invoke" });
|
|
2271
|
+
} else {
|
|
2272
|
+
const errorText = matchModelErrorText(err.message, { includeCatchAll: true }) ?? `⚠️ 抱歉,处理请求时出错: ${err.message}`;
|
|
2273
|
+
log?.warn?.(`[DingTalk] replyOptions.onError 不存在,走极端兜底纯文本发送`);
|
|
2274
|
+
try {
|
|
2275
|
+
const token = await getAccessToken(config);
|
|
2276
|
+
const body = {
|
|
2277
|
+
msgtype: "text",
|
|
2278
|
+
text: { content: errorText }
|
|
2279
|
+
};
|
|
2280
|
+
if (!isDirect) body.at = {
|
|
2281
|
+
atUserIds: [senderId],
|
|
2282
|
+
isAtAll: false
|
|
2283
|
+
};
|
|
2284
|
+
await dingtalkHttp.post(sessionWebhook, body, { headers: {
|
|
2285
|
+
"x-acs-dingtalk-access-token": token,
|
|
2286
|
+
"Content-Type": "application/json"
|
|
2287
|
+
} });
|
|
2288
|
+
} catch (fallbackErr) {
|
|
2289
|
+
log?.error?.(`错误消息发送也失败: ${fallbackErr.message}`);
|
|
2290
|
+
}
|
|
2292
2291
|
}
|
|
2293
2292
|
}
|
|
2294
2293
|
try {
|
|
@@ -955,7 +955,7 @@ async function monitorDingtalkProvider(opts = {}) {
|
|
|
955
955
|
const log = createLogger(cfg.channels?.["dingtalk-connector"]?.debug ?? false);
|
|
956
956
|
const [accountsModule, monitorAccountModule, monitorSingleModule] = await Promise.all([
|
|
957
957
|
import("./accounts-BQptOmgB.mjs"),
|
|
958
|
-
import("./message-handler-
|
|
958
|
+
import("./message-handler-CCbPqctq.mjs"),
|
|
959
959
|
import("./connection-fc6B4z4G.mjs")
|
|
960
960
|
]);
|
|
961
961
|
const { resolveDingtalkAccount, listEnabledDingtalkAccounts } = accountsModule;
|
package/package.json
CHANGED
|
@@ -1906,22 +1906,14 @@ export async function handleDingTalkMessageInternal(params: HandleMessageParams)
|
|
|
1906
1906
|
} catch (err: any) {
|
|
1907
1907
|
log?.error?.(`SDK dispatch 失败: ${err.message}`);
|
|
1908
1908
|
|
|
1909
|
-
//
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
cardSuccess = true;
|
|
1918
|
-
} catch (cardErr: any) {
|
|
1919
|
-
log?.error?.(`更新错误卡片失败: ${cardErr.message}`);
|
|
1920
|
-
}
|
|
1921
|
-
}
|
|
1922
|
-
|
|
1923
|
-
if (!cardSuccess) {
|
|
1924
|
-
// 降级:发送错误文本消息
|
|
1909
|
+
// 使用与正常回放相同的底层逻辑统一处理错误定稿
|
|
1910
|
+
if (replyOptions?.onError) {
|
|
1911
|
+
log?.info?.(`[DingTalk] 统一错误定稿:调用 replyOptions.onError 处理同步异常`);
|
|
1912
|
+
await replyOptions.onError(err, { kind: 'invoke' });
|
|
1913
|
+
} else {
|
|
1914
|
+
// 极端兜底(理论上必有 onError)
|
|
1915
|
+
const errorText = matchModelErrorText(err.message, { includeCatchAll: true }) ?? `⚠️ 抱歉,处理请求时出错: ${err.message}`;
|
|
1916
|
+
log?.warn?.(`[DingTalk] replyOptions.onError 不存在,走极端兜底纯文本发送`);
|
|
1925
1917
|
try {
|
|
1926
1918
|
const token = await getAccessToken(config);
|
|
1927
1919
|
const body: any = {
|