@iflyrpa/actions 4.0.0-beta.1 → 4.0.0-beta.4
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/bundle.js +103 -39
- package/dist/bundle.js.map +1 -1
- package/dist/index.js +103 -39
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +103 -39
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5489,7 +5489,7 @@ var __webpack_exports__ = {};
|
|
|
5489
5489
|
});
|
|
5490
5490
|
const package_json_namespaceObject = require("@iflyrpa/share/package.json");
|
|
5491
5491
|
var package_json_default = /*#__PURE__*/ __webpack_require__.n(package_json_namespaceObject);
|
|
5492
|
-
var package_namespaceObject = JSON.parse('{"i8":"3.0.
|
|
5492
|
+
var package_namespaceObject = JSON.parse('{"i8":"3.0.7-beta.3"}');
|
|
5493
5493
|
const share_namespaceObject = require("@iflyrpa/share");
|
|
5494
5494
|
const external_node_fs_namespaceObject = require("node:fs");
|
|
5495
5495
|
var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
|
|
@@ -14595,19 +14595,25 @@ var __webpack_exports__ = {};
|
|
|
14595
14595
|
task.logger.info("========== api调用完成 ==========");
|
|
14596
14596
|
task.logger.info(`decision值: ${JSON.stringify(decision)}, needsVerification(decision): ${needsVerification(decision)}`);
|
|
14597
14597
|
if (needsVerification(decision)) {
|
|
14598
|
+
const details = [
|
|
14599
|
+
publishResult.status_msg,
|
|
14600
|
+
decision?.verify_title,
|
|
14601
|
+
decision?.verify_desc
|
|
14602
|
+
].filter(Boolean).join(" ");
|
|
14603
|
+
const message = `图文发布失败,原因:${details}${task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
14598
14604
|
task.logger.warn(`TaskId:${task.taskId},检测到需要验证,准备返回验证信息`);
|
|
14599
|
-
|
|
14600
|
-
state: share_namespaceObject.TaskState.
|
|
14605
|
+
const mockData = {
|
|
14606
|
+
state: share_namespaceObject.TaskState.FAILED,
|
|
14607
|
+
error: message,
|
|
14601
14608
|
result: {
|
|
14602
|
-
|
|
14609
|
+
data: decision,
|
|
14610
|
+
uploadedImgList: JSON.stringify(publishData.item.common.images)
|
|
14603
14611
|
}
|
|
14604
|
-
}
|
|
14605
|
-
|
|
14612
|
+
};
|
|
14613
|
+
await updateTaskState?.(mockData);
|
|
14606
14614
|
return {
|
|
14607
14615
|
code: 0,
|
|
14608
|
-
data:
|
|
14609
|
-
result: decision
|
|
14610
|
-
},
|
|
14616
|
+
data: mockData,
|
|
14611
14617
|
message: "操作成功"
|
|
14612
14618
|
};
|
|
14613
14619
|
}
|
|
@@ -15307,15 +15313,41 @@ var __webpack_exports__ = {};
|
|
|
15307
15313
|
}
|
|
15308
15314
|
task.logger?.info("准备发布...");
|
|
15309
15315
|
await page.waitForTimeout(1000);
|
|
15310
|
-
const
|
|
15316
|
+
const result = await new Promise((resolve, reject)=>{
|
|
15311
15317
|
const handleResponse = async (res)=>{
|
|
15312
15318
|
if (res.url().includes("/web/api/media/aweme/create_v2")) {
|
|
15313
15319
|
task.logger?.info("匹配到发布接口响应");
|
|
15320
|
+
let decision = null;
|
|
15321
|
+
try {
|
|
15322
|
+
const headers = await res.allHeaders();
|
|
15323
|
+
decision = parseVerifyPassportDecision(headers["x-tt-verify-passport-decision"]);
|
|
15324
|
+
} catch (error) {
|
|
15325
|
+
task.logger?.warn(`解析验证决策头失败: ${error}`);
|
|
15326
|
+
}
|
|
15314
15327
|
const jsonResponse = await res.json();
|
|
15315
15328
|
task.logger?.info(`发布接口响应数据: ${JSON.stringify(jsonResponse)}`);
|
|
15316
15329
|
page.off("response", handleResponse);
|
|
15317
|
-
if (
|
|
15318
|
-
|
|
15330
|
+
if (needsVerification(decision)) {
|
|
15331
|
+
task.logger?.warn("检测到需要二次验证,文章未真正发布");
|
|
15332
|
+
resolve({
|
|
15333
|
+
itemId: "",
|
|
15334
|
+
decision
|
|
15335
|
+
});
|
|
15336
|
+
return;
|
|
15337
|
+
}
|
|
15338
|
+
if (jsonResponse?.status_code !== 0) {
|
|
15339
|
+
reject(new Error(jsonResponse?.status_msg || "发布失败"));
|
|
15340
|
+
return;
|
|
15341
|
+
}
|
|
15342
|
+
const itemId = jsonResponse?.data?.item_id || jsonResponse?.item_id || "";
|
|
15343
|
+
if (!itemId) {
|
|
15344
|
+
reject(new Error(jsonResponse?.status_msg || "发布异常:未返回作品ID,文章可能未真正发布"));
|
|
15345
|
+
return;
|
|
15346
|
+
}
|
|
15347
|
+
resolve({
|
|
15348
|
+
itemId,
|
|
15349
|
+
decision: null
|
|
15350
|
+
});
|
|
15319
15351
|
}
|
|
15320
15352
|
};
|
|
15321
15353
|
page.on("response", handleResponse);
|
|
@@ -15337,20 +15369,42 @@ var __webpack_exports__ = {};
|
|
|
15337
15369
|
await page.close();
|
|
15338
15370
|
return null;
|
|
15339
15371
|
});
|
|
15340
|
-
if (!
|
|
15372
|
+
if (!result) return {
|
|
15341
15373
|
code: 414,
|
|
15342
15374
|
message: "发布失败",
|
|
15343
15375
|
data: ""
|
|
15344
15376
|
};
|
|
15345
|
-
|
|
15377
|
+
if (needsVerification(result.decision)) {
|
|
15378
|
+
const decision = result.decision;
|
|
15379
|
+
const details = [
|
|
15380
|
+
decision?.verify_title,
|
|
15381
|
+
decision?.verify_desc
|
|
15382
|
+
].filter(Boolean).join(" ");
|
|
15383
|
+
const message = `发布失败,需要二次验证${details ? `:${details}` : ""}`;
|
|
15384
|
+
task.logger?.warn(message);
|
|
15385
|
+
await updateTaskState?.({
|
|
15386
|
+
state: share_namespaceObject.TaskState.FAILED,
|
|
15387
|
+
error: message,
|
|
15388
|
+
result: {
|
|
15389
|
+
data: decision
|
|
15390
|
+
}
|
|
15391
|
+
});
|
|
15392
|
+
await page.close();
|
|
15393
|
+
return {
|
|
15394
|
+
code: 414,
|
|
15395
|
+
message,
|
|
15396
|
+
data: ""
|
|
15397
|
+
};
|
|
15398
|
+
}
|
|
15399
|
+
task.logger?.info(`✓ 发布成功,item_id: ${result.itemId}`);
|
|
15346
15400
|
await updateTaskState?.({
|
|
15347
15401
|
state: share_namespaceObject.TaskState.SUCCESS,
|
|
15348
15402
|
result: {
|
|
15349
|
-
response
|
|
15403
|
+
response: result.itemId
|
|
15350
15404
|
}
|
|
15351
15405
|
});
|
|
15352
15406
|
await page.close();
|
|
15353
|
-
return (0, share_namespaceObject.success)(
|
|
15407
|
+
return (0, share_namespaceObject.success)(result.itemId);
|
|
15354
15408
|
};
|
|
15355
15409
|
const DouyinPublishParamsSchema = ActionCommonParamsSchema.extend({
|
|
15356
15410
|
title: schemas_string(),
|
|
@@ -16130,26 +16184,26 @@ var __webpack_exports__ = {};
|
|
|
16130
16184
|
const http = new Http({
|
|
16131
16185
|
headers: {
|
|
16132
16186
|
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
16133
|
-
referer: "https://mp.toutiao.com/profile_v4/graphic/publish"
|
|
16187
|
+
referer: "https://mp.toutiao.com/profile_v4/graphic/publish",
|
|
16188
|
+
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36"
|
|
16189
|
+
}
|
|
16190
|
+
});
|
|
16191
|
+
const totalData = await http.api({
|
|
16192
|
+
method: "get",
|
|
16193
|
+
url: "https://mp.toutiao.com/mp/fe_api/home/merge_v2",
|
|
16194
|
+
params: {
|
|
16195
|
+
app_id: 1231
|
|
16196
|
+
}
|
|
16197
|
+
});
|
|
16198
|
+
await new Promise((r)=>setTimeout(r, 1000));
|
|
16199
|
+
const contentDataYesterday = await http.api({
|
|
16200
|
+
method: "get",
|
|
16201
|
+
url: "https://mp.toutiao.com/mp/agw/statistic/v2/content_stat",
|
|
16202
|
+
params: {
|
|
16203
|
+
type: 0,
|
|
16204
|
+
app_id: 1231
|
|
16134
16205
|
}
|
|
16135
16206
|
});
|
|
16136
|
-
const [totalData, contentDataYesterday] = await Promise.all([
|
|
16137
|
-
http.api({
|
|
16138
|
-
method: "get",
|
|
16139
|
-
url: "https://mp.toutiao.com/mp/fe_api/home/merge_v2",
|
|
16140
|
-
params: {
|
|
16141
|
-
app_id: 1231
|
|
16142
|
-
}
|
|
16143
|
-
}),
|
|
16144
|
-
http.api({
|
|
16145
|
-
method: "get",
|
|
16146
|
-
url: "https://mp.toutiao.com/mp/agw/statistic/v2/content_stat",
|
|
16147
|
-
params: {
|
|
16148
|
-
type: 0,
|
|
16149
|
-
app_id: 1231
|
|
16150
|
-
}
|
|
16151
|
-
})
|
|
16152
|
-
]);
|
|
16153
16207
|
const isSuccess = !!(totalData?.data?.statistic && contentDataYesterday?.author_stat);
|
|
16154
16208
|
if (!isSuccess || !totalData?.data || !contentDataYesterday?.author_stat) return types_errorResponse(totalData?.message || contentDataYesterday?.message || "头条号数据获取失败,请检查Cookie是否有效", 414);
|
|
16155
16209
|
const ttData = {
|
|
@@ -20326,8 +20380,10 @@ var __webpack_exports__ = {};
|
|
|
20326
20380
|
tuwen_wtt_trans_flag: params.settingInfo?.toutiaoTransWtt ? "2" : "0",
|
|
20327
20381
|
info_source: sourceData,
|
|
20328
20382
|
...location ? {
|
|
20329
|
-
|
|
20330
|
-
|
|
20383
|
+
manual_selected_city: JSON.stringify({
|
|
20384
|
+
city: location.label,
|
|
20385
|
+
city_code: location.value
|
|
20386
|
+
})
|
|
20331
20387
|
} : null,
|
|
20332
20388
|
...params.settingInfo?.toutiaoCollectionId ? {
|
|
20333
20389
|
want_join_collection_id: params.settingInfo.toutiaoCollectionId
|
|
@@ -20377,6 +20433,12 @@ var __webpack_exports__ = {};
|
|
|
20377
20433
|
claim_exclusive: toutiaoExclusive ? toutiaoExclusive : toutiaoOriginal?.includes("exclusive") ? 1 : 0
|
|
20378
20434
|
};
|
|
20379
20435
|
task._timerRecord.PrePublish = Date.now();
|
|
20436
|
+
task.logger.info(`[toutiaoPublish] ${"draft" === params.saveType ? "同步草稿" : "发布文章"}参数`, {
|
|
20437
|
+
saveType: params.saveType,
|
|
20438
|
+
title: params.title,
|
|
20439
|
+
extra: extraData,
|
|
20440
|
+
publishData
|
|
20441
|
+
});
|
|
20380
20442
|
const msToken = params.cookies.find((it)=>"msToken" === it.name)?.value;
|
|
20381
20443
|
let publishOption = {};
|
|
20382
20444
|
if (msToken) {
|
|
@@ -21572,8 +21634,8 @@ var __webpack_exports__ = {};
|
|
|
21572
21634
|
headers
|
|
21573
21635
|
});
|
|
21574
21636
|
const proxyHttp = new Http(...args);
|
|
21575
|
-
|
|
21576
|
-
const responseData = response
|
|
21637
|
+
const baseRespFinder = (response)=>{
|
|
21638
|
+
const responseData = response?.data;
|
|
21577
21639
|
const msgType = "draft" === params.saveType ? "同步" : "发布";
|
|
21578
21640
|
if (response && responseData?.base_resp && 0 !== responseData.base_resp.ret && !ignoreErrno.includes(responseData.base_resp.ret)) {
|
|
21579
21641
|
const errmsg = weixinPublish_mock_errnoMap[responseData.base_resp.ret] || response.config.defaultErrorMsg || responseData.base_resp.err_msg || `文章${msgType}异常,请稍后重试。`;
|
|
@@ -21583,7 +21645,9 @@ var __webpack_exports__ = {};
|
|
|
21583
21645
|
data: responseData
|
|
21584
21646
|
};
|
|
21585
21647
|
}
|
|
21586
|
-
}
|
|
21648
|
+
};
|
|
21649
|
+
http.addResponseInterceptor(baseRespFinder);
|
|
21650
|
+
proxyHttp.addResponseInterceptor(baseRespFinder);
|
|
21587
21651
|
await http.api({
|
|
21588
21652
|
method: "get",
|
|
21589
21653
|
url: "https://mp.weixin.qq.com/cgi-bin/appmsgpublish",
|