@whyour/qinglong 2.19.0-2 → 2.19.0-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/docker/310.Dockerfile +1 -1
- package/docker/Dockerfile +1 -1
- package/package.json +2 -3
- package/sample/notify.js +54 -28
- package/static/build/api/dependence.js +0 -6
- package/static/build/config/http.js +48 -0
- package/static/build/config/util.js +2 -2
- package/static/build/services/config.js +3 -3
- package/static/build/services/dependence.js +6 -0
- package/static/build/services/notify.js +40 -81
- package/static/build/services/system.js +8 -4
- package/static/build/services/user.js +6 -3
package/docker/310.Dockerfile
CHANGED
|
@@ -75,7 +75,7 @@ ENV PNPM_HOME=${QL_DIR}/data/dep_cache/node \
|
|
|
75
75
|
PYTHON_HOME=${QL_DIR}/data/dep_cache/python3 \
|
|
76
76
|
PYTHONUSERBASE=${QL_DIR}/data/dep_cache/python3
|
|
77
77
|
|
|
78
|
-
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${PNPM_HOME} \
|
|
78
|
+
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${PNPM_HOME}:${PYTHON_HOME}/bin \
|
|
79
79
|
NODE_PATH=/usr/local/bin:/usr/local/lib/node_modules:${PNPM_HOME}/global/5/node_modules \
|
|
80
80
|
PIP_CACHE_DIR=${PYTHON_HOME}/pip \
|
|
81
81
|
PYTHONPATH=${PYTHON_HOME}:${PYTHON_HOME}/lib/python${PYTHON_SHORT_VERSION}:${PYTHON_HOME}/lib/python${PYTHON_SHORT_VERSION}/site-packages:${PYTHONPATH}
|
package/docker/Dockerfile
CHANGED
|
@@ -76,7 +76,7 @@ ENV PNPM_HOME=${QL_DIR}/data/dep_cache/node \
|
|
|
76
76
|
PYTHON_HOME=${QL_DIR}/data/dep_cache/python3 \
|
|
77
77
|
PYTHONUSERBASE=${QL_DIR}/data/dep_cache/python3
|
|
78
78
|
|
|
79
|
-
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${PNPM_HOME} \
|
|
79
|
+
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${PNPM_HOME}:${PYTHON_HOME}/bin \
|
|
80
80
|
NODE_PATH=/usr/local/bin:/usr/local/lib/node_modules:${PNPM_HOME}/global/5/node_modules \
|
|
81
81
|
PIP_CACHE_DIR=${PYTHON_HOME}/pip \
|
|
82
82
|
PYTHONPATH=${PYTHON_HOME}:${PYTHON_HOME}/lib/python${PYTHON_SHORT_VERSION}:${PYTHON_HOME}/lib/python${PYTHON_SHORT_VERSION}/site-packages:${PYTHONPATH}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@whyour/qinglong",
|
|
3
|
-
"version": "2.19.0-
|
|
3
|
+
"version": "2.19.0-4",
|
|
4
4
|
"description": "Timed task management platform supporting Python3, JavaScript, Shell, Typescript",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -86,8 +86,7 @@
|
|
|
86
86
|
"express-jwt": "^8.4.1",
|
|
87
87
|
"express-rate-limit": "^7.4.1",
|
|
88
88
|
"express-urlrewrite": "^2.0.3",
|
|
89
|
-
"
|
|
90
|
-
"got": "^11.8.2",
|
|
89
|
+
"undici": "^7.9.0",
|
|
91
90
|
"hpagent": "^1.2.0",
|
|
92
91
|
"http-proxy-middleware": "^3.0.3",
|
|
93
92
|
"iconv-lite": "^0.6.3",
|
package/sample/notify.js
CHANGED
|
@@ -1,7 +1,42 @@
|
|
|
1
1
|
const querystring = require('node:querystring');
|
|
2
|
-
const
|
|
2
|
+
const { request: undiciRequest, ProxyAgent, FormData } = require('undici');
|
|
3
3
|
const timeout = 15000;
|
|
4
4
|
|
|
5
|
+
async function request(url, options = {}) {
|
|
6
|
+
const { json, form, body, headers = {}, ...rest } = options;
|
|
7
|
+
|
|
8
|
+
const finalHeaders = { ...headers };
|
|
9
|
+
let finalBody = body;
|
|
10
|
+
|
|
11
|
+
if (json) {
|
|
12
|
+
finalHeaders['content-type'] = 'application/json';
|
|
13
|
+
finalBody = JSON.stringify(json);
|
|
14
|
+
} else if (form) {
|
|
15
|
+
finalBody = form;
|
|
16
|
+
delete finalHeaders['content-type'];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return undiciRequest(url, {
|
|
20
|
+
headers: finalHeaders,
|
|
21
|
+
body: finalBody,
|
|
22
|
+
...rest,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function post(url, options = {}) {
|
|
27
|
+
return request(url, { ...options, method: 'POST' });
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function get(url, options = {}) {
|
|
31
|
+
return request(url, { ...options, method: 'GET' });
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const httpClient = {
|
|
35
|
+
request,
|
|
36
|
+
post,
|
|
37
|
+
get,
|
|
38
|
+
};
|
|
39
|
+
|
|
5
40
|
const push_config = {
|
|
6
41
|
HITOKOTO: true, // 启用一言(随机句子)
|
|
7
42
|
|
|
@@ -123,9 +158,9 @@ for (const key in push_config) {
|
|
|
123
158
|
const $ = {
|
|
124
159
|
post: (params, callback) => {
|
|
125
160
|
const { url, ...others } = params;
|
|
126
|
-
|
|
127
|
-
(res) => {
|
|
128
|
-
let body = res.body;
|
|
161
|
+
httpClient.post(url, others).then(
|
|
162
|
+
async (res) => {
|
|
163
|
+
let body = await res.body.text();
|
|
129
164
|
try {
|
|
130
165
|
body = JSON.parse(body);
|
|
131
166
|
} catch (error) {}
|
|
@@ -138,9 +173,9 @@ const $ = {
|
|
|
138
173
|
},
|
|
139
174
|
get: (params, callback) => {
|
|
140
175
|
const { url, ...others } = params;
|
|
141
|
-
|
|
142
|
-
(res) => {
|
|
143
|
-
let body = res.body;
|
|
176
|
+
httpClient.get(url, others).then(
|
|
177
|
+
async (res) => {
|
|
178
|
+
let body = await res.body.text();
|
|
144
179
|
try {
|
|
145
180
|
body = JSON.parse(body);
|
|
146
181
|
} catch (error) {}
|
|
@@ -156,8 +191,8 @@ const $ = {
|
|
|
156
191
|
|
|
157
192
|
async function one() {
|
|
158
193
|
const url = 'https://v1.hitokoto.cn/';
|
|
159
|
-
const res = await
|
|
160
|
-
const body =
|
|
194
|
+
const res = await httpClient.request(url);
|
|
195
|
+
const body = await res.body.json();
|
|
161
196
|
return `${body.hitokoto} ----${body.from}`;
|
|
162
197
|
}
|
|
163
198
|
|
|
@@ -442,21 +477,11 @@ function tgBotNotify(text, desp) {
|
|
|
442
477
|
timeout,
|
|
443
478
|
};
|
|
444
479
|
if (TG_PROXY_HOST && TG_PROXY_PORT) {
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
maxFreeSockets: 256,
|
|
451
|
-
proxy: `http://${TG_PROXY_AUTH}${TG_PROXY_HOST}:${TG_PROXY_PORT}`,
|
|
452
|
-
};
|
|
453
|
-
const httpAgent = new HttpProxyAgent(_options);
|
|
454
|
-
const httpsAgent = new HttpsProxyAgent(_options);
|
|
455
|
-
const agent = {
|
|
456
|
-
http: httpAgent,
|
|
457
|
-
https: httpsAgent,
|
|
458
|
-
};
|
|
459
|
-
options.agent = agent;
|
|
480
|
+
let agent;
|
|
481
|
+
agent = new ProxyAgent({
|
|
482
|
+
uri: `http://${TG_PROXY_AUTH}${TG_PROXY_HOST}:${TG_PROXY_PORT}`,
|
|
483
|
+
});
|
|
484
|
+
options.dispatcher = agent;
|
|
460
485
|
}
|
|
461
486
|
$.post(options, (err, resp, data) => {
|
|
462
487
|
try {
|
|
@@ -1209,17 +1234,18 @@ function webhookNotify(text, desp) {
|
|
|
1209
1234
|
'$title',
|
|
1210
1235
|
encodeURIComponent(text),
|
|
1211
1236
|
).replaceAll('$content', encodeURIComponent(desp));
|
|
1212
|
-
|
|
1237
|
+
httpClient.request(formatUrl, options).then(async (resp) => {
|
|
1238
|
+
const body = await resp.body.text();
|
|
1213
1239
|
try {
|
|
1214
1240
|
if (resp.statusCode !== 200) {
|
|
1215
|
-
console.log(`自定义发送通知消息失败😞 ${
|
|
1241
|
+
console.log(`自定义发送通知消息失败😞 ${body}\n`);
|
|
1216
1242
|
} else {
|
|
1217
|
-
console.log(`自定义发送通知消息成功🎉 ${
|
|
1243
|
+
console.log(`自定义发送通知消息成功🎉 ${body}\n`);
|
|
1218
1244
|
}
|
|
1219
1245
|
} catch (e) {
|
|
1220
1246
|
$.logErr(e, resp);
|
|
1221
1247
|
} finally {
|
|
1222
|
-
resolve(
|
|
1248
|
+
resolve(body);
|
|
1223
1249
|
}
|
|
1224
1250
|
});
|
|
1225
1251
|
});
|
|
@@ -29,7 +29,6 @@ exports.default = (app) => {
|
|
|
29
29
|
remark: celebrate_1.Joi.string().optional().allow(''),
|
|
30
30
|
})),
|
|
31
31
|
}), async (req, res, next) => {
|
|
32
|
-
const logger = typedi_1.Container.get('logger');
|
|
33
32
|
try {
|
|
34
33
|
const dependenceService = typedi_1.Container.get(dependence_1.default);
|
|
35
34
|
const data = await dependenceService.create(req.body);
|
|
@@ -47,7 +46,6 @@ exports.default = (app) => {
|
|
|
47
46
|
remark: celebrate_1.Joi.string().optional().allow(''),
|
|
48
47
|
}),
|
|
49
48
|
}), async (req, res, next) => {
|
|
50
|
-
const logger = typedi_1.Container.get('logger');
|
|
51
49
|
try {
|
|
52
50
|
const dependenceService = typedi_1.Container.get(dependence_1.default);
|
|
53
51
|
const data = await dependenceService.update(req.body);
|
|
@@ -60,7 +58,6 @@ exports.default = (app) => {
|
|
|
60
58
|
route.delete('/', (0, celebrate_1.celebrate)({
|
|
61
59
|
body: celebrate_1.Joi.array().items(celebrate_1.Joi.number().required()),
|
|
62
60
|
}), async (req, res, next) => {
|
|
63
|
-
const logger = typedi_1.Container.get('logger');
|
|
64
61
|
try {
|
|
65
62
|
const dependenceService = typedi_1.Container.get(dependence_1.default);
|
|
66
63
|
const data = await dependenceService.remove(req.body);
|
|
@@ -73,7 +70,6 @@ exports.default = (app) => {
|
|
|
73
70
|
route.delete('/force', (0, celebrate_1.celebrate)({
|
|
74
71
|
body: celebrate_1.Joi.array().items(celebrate_1.Joi.number().required()),
|
|
75
72
|
}), async (req, res, next) => {
|
|
76
|
-
const logger = typedi_1.Container.get('logger');
|
|
77
73
|
try {
|
|
78
74
|
const dependenceService = typedi_1.Container.get(dependence_1.default);
|
|
79
75
|
const data = await dependenceService.remove(req.body, true);
|
|
@@ -88,7 +84,6 @@ exports.default = (app) => {
|
|
|
88
84
|
id: celebrate_1.Joi.number().required(),
|
|
89
85
|
}),
|
|
90
86
|
}), async (req, res, next) => {
|
|
91
|
-
const logger = typedi_1.Container.get('logger');
|
|
92
87
|
try {
|
|
93
88
|
const dependenceService = typedi_1.Container.get(dependence_1.default);
|
|
94
89
|
const data = await dependenceService.getDb({ id: req.params.id });
|
|
@@ -101,7 +96,6 @@ exports.default = (app) => {
|
|
|
101
96
|
route.put('/reinstall', (0, celebrate_1.celebrate)({
|
|
102
97
|
body: celebrate_1.Joi.array().items(celebrate_1.Joi.number().required()),
|
|
103
98
|
}), async (req, res, next) => {
|
|
104
|
-
const logger = typedi_1.Container.get('logger');
|
|
105
99
|
try {
|
|
106
100
|
const dependenceService = typedi_1.Container.get(dependence_1.default);
|
|
107
101
|
const data = await dependenceService.reInstall(req.body);
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.httpClient = void 0;
|
|
15
|
+
const undici_1 = require("undici");
|
|
16
|
+
async function request(url, options) {
|
|
17
|
+
const _a = options || {}, { json, form, body, headers = {} } = _a, rest = __rest(_a, ["json", "form", "body", "headers"]);
|
|
18
|
+
const finalHeaders = Object.assign({}, headers);
|
|
19
|
+
let finalBody = body;
|
|
20
|
+
if (json) {
|
|
21
|
+
finalHeaders['content-type'] = 'application/json';
|
|
22
|
+
finalBody = JSON.stringify(json);
|
|
23
|
+
}
|
|
24
|
+
else if (form) {
|
|
25
|
+
finalBody = form;
|
|
26
|
+
delete finalHeaders['content-type'];
|
|
27
|
+
}
|
|
28
|
+
const res = await (0, undici_1.request)(url, Object.assign({ method: 'POST', headers: finalHeaders, body: finalBody }, rest));
|
|
29
|
+
return res;
|
|
30
|
+
}
|
|
31
|
+
async function post(url, options) {
|
|
32
|
+
const resp = await request(url, Object.assign(Object.assign({}, options), { method: 'POST' }));
|
|
33
|
+
const rawText = await resp.body.text();
|
|
34
|
+
if ((options === null || options === void 0 ? void 0 : options.responseType) === 'text') {
|
|
35
|
+
return rawText;
|
|
36
|
+
}
|
|
37
|
+
try {
|
|
38
|
+
return JSON.parse(rawText);
|
|
39
|
+
}
|
|
40
|
+
catch (_a) {
|
|
41
|
+
return rawText;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.httpClient = {
|
|
45
|
+
post,
|
|
46
|
+
request,
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=http.js.map
|
|
@@ -33,7 +33,6 @@ exports.updateLinuxMirrorFile = exports.detectOS = exports.isDemoEnv = exports.g
|
|
|
33
33
|
const fs = __importStar(require("fs/promises"));
|
|
34
34
|
const path = __importStar(require("path"));
|
|
35
35
|
const child_process_1 = require("child_process");
|
|
36
|
-
const form_data_1 = __importDefault(require("form-data"));
|
|
37
36
|
const ps_tree_1 = __importDefault(require("ps-tree"));
|
|
38
37
|
const util_1 = require("util");
|
|
39
38
|
const js_yaml_1 = require("js-yaml");
|
|
@@ -42,6 +41,7 @@ const const_1 = require("./const");
|
|
|
42
41
|
const logger_1 = __importDefault(require("../loaders/logger"));
|
|
43
42
|
const utils_1 = require("../shared/utils");
|
|
44
43
|
const dependence_1 = require("../data/dependence");
|
|
44
|
+
const undici_1 = require("undici");
|
|
45
45
|
const os_1 = __importDefault(require("os"));
|
|
46
46
|
__exportStar(require("./share"), exports);
|
|
47
47
|
let osType;
|
|
@@ -354,7 +354,7 @@ function parseBody(body, contentType, valueFormatFn) {
|
|
|
354
354
|
return Object.keys(parsed).reduce((p, c) => {
|
|
355
355
|
p.append(c, parsed[c]);
|
|
356
356
|
return p;
|
|
357
|
-
}, new
|
|
357
|
+
}, new undici_1.FormData());
|
|
358
358
|
case 'application/x-www-form-urlencoded':
|
|
359
359
|
return Object.keys(parsed).reduce((p, c) => {
|
|
360
360
|
return p ? `${p}&${c}=${parsed[c]}` : `${c}=${parsed[c]}`;
|
|
@@ -39,7 +39,7 @@ const typedi_1 = require("typedi");
|
|
|
39
39
|
const path_1 = __importStar(require("path"));
|
|
40
40
|
const config_1 = __importDefault(require("../config"));
|
|
41
41
|
const util_1 = require("../config/util");
|
|
42
|
-
const
|
|
42
|
+
const undici_1 = require("undici");
|
|
43
43
|
let ConfigService = class ConfigService {
|
|
44
44
|
constructor() { }
|
|
45
45
|
async getFile(filePath, res) {
|
|
@@ -51,8 +51,8 @@ let ConfigService = class ConfigService {
|
|
|
51
51
|
return res.send({ code: 403, message: '文件无法访问' });
|
|
52
52
|
}
|
|
53
53
|
if (filePath.startsWith('sample/')) {
|
|
54
|
-
const res = await
|
|
55
|
-
content = res.body;
|
|
54
|
+
const res = await (0, undici_1.request)(`https://gitlab.com/whyour/qinglong/-/raw/master/${filePath}`);
|
|
55
|
+
content = await res.body.text();
|
|
56
56
|
}
|
|
57
57
|
else if (filePath.startsWith('data/scripts/')) {
|
|
58
58
|
content = await (0, util_1.getFileContentByName)((0, path_1.join)(config_1.default.rootPath, filePath));
|
|
@@ -70,6 +70,9 @@ let DependenceService = class DependenceService {
|
|
|
70
70
|
}
|
|
71
71
|
async remove(ids, force = false) {
|
|
72
72
|
const docs = await dependence_1.DependenceModel.findAll({ where: { id: ids } });
|
|
73
|
+
for (const doc of docs) {
|
|
74
|
+
pLimit_1.default.removeQueuedDependency(doc);
|
|
75
|
+
}
|
|
73
76
|
const unInstalledDeps = docs.filter((x) => x.status !== dependence_1.DependenceStatus.installed);
|
|
74
77
|
const installedDeps = docs.filter((x) => x.status === dependence_1.DependenceStatus.installed);
|
|
75
78
|
await this.removeDb(unInstalledDeps.map((x) => x.id));
|
|
@@ -114,6 +117,9 @@ let DependenceService = class DependenceService {
|
|
|
114
117
|
async reInstall(ids) {
|
|
115
118
|
await dependence_1.DependenceModel.update({ status: dependence_1.DependenceStatus.queued, log: [] }, { where: { id: ids } });
|
|
116
119
|
const docs = await dependence_1.DependenceModel.findAll({ where: { id: ids } });
|
|
120
|
+
for (const doc of docs) {
|
|
121
|
+
pLimit_1.default.removeQueuedDependency(doc);
|
|
122
|
+
}
|
|
117
123
|
this.installDependenceOneByOne(docs, true, true);
|
|
118
124
|
return docs;
|
|
119
125
|
}
|
|
@@ -24,12 +24,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
const crypto_1 = __importDefault(require("crypto"));
|
|
27
|
-
const got_1 = __importDefault(require("got"));
|
|
28
|
-
const hpagent_1 = require("hpagent");
|
|
29
27
|
const nodemailer_1 = __importDefault(require("nodemailer"));
|
|
30
28
|
const typedi_1 = require("typedi");
|
|
31
29
|
const util_1 = require("../config/util");
|
|
32
30
|
const user_1 = __importDefault(require("./user"));
|
|
31
|
+
const http_1 = require("../config/http");
|
|
32
|
+
const undici_1 = require("undici");
|
|
33
33
|
let NotificationService = class NotificationService {
|
|
34
34
|
constructor() {
|
|
35
35
|
this.modeMap = new Map([
|
|
@@ -92,11 +92,9 @@ let NotificationService = class NotificationService {
|
|
|
92
92
|
async gotify() {
|
|
93
93
|
const { gotifyUrl, gotifyToken, gotifyPriority = 1 } = this.params;
|
|
94
94
|
try {
|
|
95
|
-
const res = await
|
|
96
|
-
.post(`${gotifyUrl}/message?token=${gotifyToken}`, Object.assign(Object.assign({}, this.gotOption), { body: `title=${encodeURIComponent(this.title)}&message=${encodeURIComponent(this.content)}&priority=${gotifyPriority}`, headers: {
|
|
95
|
+
const res = await http_1.httpClient.post(`${gotifyUrl}/message?token=${gotifyToken}`, Object.assign(Object.assign({}, this.gotOption), { body: `title=${encodeURIComponent(this.title)}&message=${encodeURIComponent(this.content)}&priority=${gotifyPriority}`, headers: {
|
|
97
96
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
98
|
-
} }))
|
|
99
|
-
.json();
|
|
97
|
+
} }));
|
|
100
98
|
if (typeof res.id === 'number') {
|
|
101
99
|
return true;
|
|
102
100
|
}
|
|
@@ -111,9 +109,7 @@ let NotificationService = class NotificationService {
|
|
|
111
109
|
async goCqHttpBot() {
|
|
112
110
|
const { goCqHttpBotQq, goCqHttpBotToken, goCqHttpBotUrl } = this.params;
|
|
113
111
|
try {
|
|
114
|
-
const res = await
|
|
115
|
-
.post(`${goCqHttpBotUrl}?${goCqHttpBotQq}`, Object.assign(Object.assign({}, this.gotOption), { json: { message: `${this.title}\n${this.content}` }, headers: { Authorization: 'Bearer ' + goCqHttpBotToken } }))
|
|
116
|
-
.json();
|
|
112
|
+
const res = await http_1.httpClient.post(`${goCqHttpBotUrl}?${goCqHttpBotQq}`, Object.assign(Object.assign({}, this.gotOption), { json: { message: `${this.title}\n${this.content}` }, headers: { Authorization: 'Bearer ' + goCqHttpBotToken } }));
|
|
117
113
|
if (res.retcode === 0) {
|
|
118
114
|
return true;
|
|
119
115
|
}
|
|
@@ -132,9 +128,7 @@ let NotificationService = class NotificationService {
|
|
|
132
128
|
? `https://${matchResult[1]}.push.ft07.com/send/${serverChanKey}.send`
|
|
133
129
|
: `https://sctapi.ftqq.com/${serverChanKey}.send`;
|
|
134
130
|
try {
|
|
135
|
-
const res = await
|
|
136
|
-
.post(url, Object.assign(Object.assign({}, this.gotOption), { body: `title=${encodeURIComponent(this.title)}&desp=${encodeURIComponent(this.content)}`, headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }))
|
|
137
|
-
.json();
|
|
131
|
+
const res = await http_1.httpClient.post(url, Object.assign(Object.assign({}, this.gotOption), { body: `title=${encodeURIComponent(this.title)}&desp=${encodeURIComponent(this.content)}`, headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }));
|
|
138
132
|
if (res.errno === 0 || res.data.errno === 0) {
|
|
139
133
|
return true;
|
|
140
134
|
}
|
|
@@ -150,9 +144,7 @@ let NotificationService = class NotificationService {
|
|
|
150
144
|
const { pushDeerKey, pushDeerUrl } = this.params;
|
|
151
145
|
const url = pushDeerUrl || `https://api2.pushdeer.com/message/push`;
|
|
152
146
|
try {
|
|
153
|
-
const res = await
|
|
154
|
-
.post(url, Object.assign(Object.assign({}, this.gotOption), { body: `pushkey=${pushDeerKey}&text=${encodeURIComponent(this.title)}&desp=${encodeURIComponent(this.content)}&type=markdown`, headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }))
|
|
155
|
-
.json();
|
|
147
|
+
const res = await http_1.httpClient.post(url, Object.assign(Object.assign({}, this.gotOption), { body: `pushkey=${pushDeerKey}&text=${encodeURIComponent(this.title)}&desp=${encodeURIComponent(this.content)}&type=markdown`, headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }));
|
|
156
148
|
if (res.content.result.length !== undefined &&
|
|
157
149
|
res.content.result.length > 0) {
|
|
158
150
|
return true;
|
|
@@ -168,9 +160,7 @@ let NotificationService = class NotificationService {
|
|
|
168
160
|
async chat() {
|
|
169
161
|
const { synologyChatUrl } = this.params;
|
|
170
162
|
try {
|
|
171
|
-
const res = await
|
|
172
|
-
.post(synologyChatUrl, Object.assign(Object.assign({}, this.gotOption), { body: `payload={"text":"${this.title}\n${this.content}"}`, headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }))
|
|
173
|
-
.json();
|
|
163
|
+
const res = await http_1.httpClient.post(synologyChatUrl, Object.assign(Object.assign({}, this.gotOption), { body: `payload={"text":"${this.title}\n${this.content}"}`, headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }));
|
|
174
164
|
if (res.success) {
|
|
175
165
|
return true;
|
|
176
166
|
}
|
|
@@ -199,9 +189,7 @@ let NotificationService = class NotificationService {
|
|
|
199
189
|
url: barkUrl,
|
|
200
190
|
};
|
|
201
191
|
try {
|
|
202
|
-
const res = await
|
|
203
|
-
.post(url, Object.assign(Object.assign({}, this.gotOption), { json: body, headers: { 'Content-Type': 'application/json' } }))
|
|
204
|
-
.json();
|
|
192
|
+
const res = await http_1.httpClient.post(url, Object.assign(Object.assign({}, this.gotOption), { json: body, headers: { 'Content-Type': 'application/json' } }));
|
|
205
193
|
if (res.code === 200) {
|
|
206
194
|
return true;
|
|
207
195
|
}
|
|
@@ -219,24 +207,12 @@ let NotificationService = class NotificationService {
|
|
|
219
207
|
const url = `${telegramBotApiHost ? telegramBotApiHost : 'https://api.telegram.org'}/bot${telegramBotToken}/sendMessage`;
|
|
220
208
|
let agent;
|
|
221
209
|
if (telegramBotProxyHost && telegramBotProxyPort) {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
maxSockets: 256,
|
|
226
|
-
maxFreeSockets: 256,
|
|
227
|
-
proxy: `http://${authStr}${telegramBotProxyHost}:${telegramBotProxyPort}`,
|
|
228
|
-
};
|
|
229
|
-
const httpAgent = new hpagent_1.HttpProxyAgent(options);
|
|
230
|
-
const httpsAgent = new hpagent_1.HttpsProxyAgent(options);
|
|
231
|
-
agent = {
|
|
232
|
-
http: httpAgent,
|
|
233
|
-
https: httpsAgent,
|
|
234
|
-
};
|
|
210
|
+
agent = new undici_1.ProxyAgent({
|
|
211
|
+
uri: `http://${authStr}${telegramBotProxyHost}:${telegramBotProxyPort}`,
|
|
212
|
+
});
|
|
235
213
|
}
|
|
236
214
|
try {
|
|
237
|
-
const res = await
|
|
238
|
-
.post(url, Object.assign(Object.assign({}, this.gotOption), { body: `chat_id=${telegramBotUserId}&text=${this.title}\n\n${this.content}&disable_web_page_preview=true`, headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, agent }))
|
|
239
|
-
.json();
|
|
215
|
+
const res = await http_1.httpClient.post(url, Object.assign(Object.assign({}, this.gotOption), { body: `chat_id=${telegramBotUserId}&text=${this.title}\n\n${this.content}&disable_web_page_preview=true`, headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, dispatcher: agent }));
|
|
240
216
|
if (res.ok) {
|
|
241
217
|
return true;
|
|
242
218
|
}
|
|
@@ -260,14 +236,12 @@ let NotificationService = class NotificationService {
|
|
|
260
236
|
}
|
|
261
237
|
const url = `https://oapi.dingtalk.com/robot/send?access_token=${dingtalkBotToken}${secretParam}`;
|
|
262
238
|
try {
|
|
263
|
-
const res = await
|
|
264
|
-
.post(url, Object.assign(Object.assign({}, this.gotOption), { json: {
|
|
239
|
+
const res = await http_1.httpClient.post(url, Object.assign(Object.assign({}, this.gotOption), { json: {
|
|
265
240
|
msgtype: 'text',
|
|
266
241
|
text: {
|
|
267
242
|
content: ` ${this.title}\n\n${this.content}`,
|
|
268
243
|
},
|
|
269
|
-
} }))
|
|
270
|
-
.json();
|
|
244
|
+
} }));
|
|
271
245
|
if (res.errcode === 0) {
|
|
272
246
|
return true;
|
|
273
247
|
}
|
|
@@ -283,14 +257,12 @@ let NotificationService = class NotificationService {
|
|
|
283
257
|
const { weWorkBotKey, weWorkOrigin = 'https://qyapi.weixin.qq.com' } = this.params;
|
|
284
258
|
const url = `${weWorkOrigin}/cgi-bin/webhook/send?key=${weWorkBotKey}`;
|
|
285
259
|
try {
|
|
286
|
-
const res = await
|
|
287
|
-
.post(url, Object.assign(Object.assign({}, this.gotOption), { json: {
|
|
260
|
+
const res = await http_1.httpClient.post(url, Object.assign(Object.assign({}, this.gotOption), { json: {
|
|
288
261
|
msgtype: 'text',
|
|
289
262
|
text: {
|
|
290
263
|
content: ` ${this.title}\n\n${this.content}`,
|
|
291
264
|
},
|
|
292
|
-
} }))
|
|
293
|
-
.json();
|
|
265
|
+
} }));
|
|
294
266
|
if (res.errcode === 0) {
|
|
295
267
|
return true;
|
|
296
268
|
}
|
|
@@ -306,12 +278,10 @@ let NotificationService = class NotificationService {
|
|
|
306
278
|
const { weWorkAppKey, weWorkOrigin = 'https://qyapi.weixin.qq.com' } = this.params;
|
|
307
279
|
const [corpid, corpsecret, touser, agentid, thumb_media_id = '1'] = weWorkAppKey.split(',');
|
|
308
280
|
const url = `${weWorkOrigin}/cgi-bin/gettoken`;
|
|
309
|
-
const tokenRes = await
|
|
310
|
-
.post(url, Object.assign(Object.assign({}, this.gotOption), { json: {
|
|
281
|
+
const tokenRes = await http_1.httpClient.post(url, Object.assign(Object.assign({}, this.gotOption), { json: {
|
|
311
282
|
corpid,
|
|
312
283
|
corpsecret,
|
|
313
|
-
} }))
|
|
314
|
-
.json();
|
|
284
|
+
} }));
|
|
315
285
|
let options = {
|
|
316
286
|
msgtype: 'mpnews',
|
|
317
287
|
mpnews: {
|
|
@@ -349,10 +319,8 @@ let NotificationService = class NotificationService {
|
|
|
349
319
|
break;
|
|
350
320
|
}
|
|
351
321
|
try {
|
|
352
|
-
const res = await
|
|
353
|
-
|
|
354
|
-
agentid, safe: '0' }, options) }))
|
|
355
|
-
.json();
|
|
322
|
+
const res = await http_1.httpClient.post(`${weWorkOrigin}/cgi-bin/message/send?access_token=${tokenRes.access_token}`, Object.assign(Object.assign({}, this.gotOption), { json: Object.assign({ touser,
|
|
323
|
+
agentid, safe: '0' }, options) }));
|
|
356
324
|
if (res.errcode === 0) {
|
|
357
325
|
return true;
|
|
358
326
|
}
|
|
@@ -393,9 +361,7 @@ let NotificationService = class NotificationService {
|
|
|
393
361
|
break;
|
|
394
362
|
}
|
|
395
363
|
try {
|
|
396
|
-
const res = await
|
|
397
|
-
.post(url, Object.assign(Object.assign({}, this.gotOption), { json: Object.assign({}, json) }))
|
|
398
|
-
.json();
|
|
364
|
+
const res = await http_1.httpClient.post(url, Object.assign(Object.assign({}, this.gotOption), { json: Object.assign({}, json) }));
|
|
399
365
|
if (res.code === 0) {
|
|
400
366
|
return true;
|
|
401
367
|
}
|
|
@@ -411,9 +377,7 @@ let NotificationService = class NotificationService {
|
|
|
411
377
|
const { iGotPushKey } = this.params;
|
|
412
378
|
const url = `https://push.hellyw.com/${iGotPushKey.toLowerCase()}`;
|
|
413
379
|
try {
|
|
414
|
-
const res = await
|
|
415
|
-
.post(url, Object.assign(Object.assign({}, this.gotOption), { body: `title=${this.title}&content=${this.content}`, headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }))
|
|
416
|
-
.json();
|
|
380
|
+
const res = await http_1.httpClient.post(url, Object.assign(Object.assign({}, this.gotOption), { body: `title=${this.title}&content=${this.content}`, headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }));
|
|
417
381
|
if (res.ret === 0) {
|
|
418
382
|
return true;
|
|
419
383
|
}
|
|
@@ -440,7 +404,7 @@ let NotificationService = class NotificationService {
|
|
|
440
404
|
callbackUrl: `${pushplusCallbackUrl || ''}`,
|
|
441
405
|
to: `${pushplusTo || ''}`,
|
|
442
406
|
} });
|
|
443
|
-
const res = await
|
|
407
|
+
const res = await http_1.httpClient.post(url, body);
|
|
444
408
|
if (res.code === 200) {
|
|
445
409
|
return true;
|
|
446
410
|
}
|
|
@@ -462,16 +426,14 @@ let NotificationService = class NotificationService {
|
|
|
462
426
|
}
|
|
463
427
|
const url = `https://www.weplusbot.com/send`;
|
|
464
428
|
try {
|
|
465
|
-
const res = await
|
|
466
|
-
.post(url, Object.assign(Object.assign({}, this.gotOption), { json: {
|
|
429
|
+
const res = await http_1.httpClient.post(url, Object.assign(Object.assign({}, this.gotOption), { json: {
|
|
467
430
|
token: `${wePlusBotToken}`,
|
|
468
431
|
title: `${this.title}`,
|
|
469
432
|
template: `${template}`,
|
|
470
433
|
content: `${content}`,
|
|
471
434
|
receiver: `${wePlusBotReceiver || ''}`,
|
|
472
435
|
version: `${wePlusBotVersion || 'pro'}`,
|
|
473
|
-
} }))
|
|
474
|
-
.json();
|
|
436
|
+
} }));
|
|
475
437
|
if (res.code === 200) {
|
|
476
438
|
return true;
|
|
477
439
|
}
|
|
@@ -489,12 +451,10 @@ let NotificationService = class NotificationService {
|
|
|
489
451
|
larkKey = `https://open.feishu.cn/open-apis/bot/v2/hook/${larkKey}`;
|
|
490
452
|
}
|
|
491
453
|
try {
|
|
492
|
-
const res = await
|
|
493
|
-
.post(larkKey, Object.assign(Object.assign({}, this.gotOption), { json: {
|
|
454
|
+
const res = await http_1.httpClient.post(larkKey, Object.assign(Object.assign({}, this.gotOption), { json: {
|
|
494
455
|
msg_type: 'text',
|
|
495
456
|
content: { text: `${this.title}\n\n${this.content}` },
|
|
496
|
-
}, headers: { 'Content-Type': 'application/json' } }))
|
|
497
|
-
.json();
|
|
457
|
+
}, headers: { 'Content-Type': 'application/json' } }));
|
|
498
458
|
if (res.StatusCode === 0 || res.code === 0) {
|
|
499
459
|
return true;
|
|
500
460
|
}
|
|
@@ -537,16 +497,16 @@ let NotificationService = class NotificationService {
|
|
|
537
497
|
async pushMe() {
|
|
538
498
|
const { pushMeKey, pushMeUrl } = this.params;
|
|
539
499
|
try {
|
|
540
|
-
const res = await
|
|
500
|
+
const res = await http_1.httpClient.post(pushMeUrl || 'https://push.i-i.me/', Object.assign(Object.assign({}, this.gotOption), { json: {
|
|
541
501
|
push_key: pushMeKey,
|
|
542
502
|
title: this.title,
|
|
543
503
|
content: this.content,
|
|
544
504
|
}, headers: { 'Content-Type': 'application/json' } }));
|
|
545
|
-
if (res
|
|
505
|
+
if (res === 'success') {
|
|
546
506
|
return true;
|
|
547
507
|
}
|
|
548
508
|
else {
|
|
549
|
-
throw new Error(res
|
|
509
|
+
throw new Error(res);
|
|
550
510
|
}
|
|
551
511
|
}
|
|
552
512
|
catch (error) {
|
|
@@ -562,12 +522,12 @@ let NotificationService = class NotificationService {
|
|
|
562
522
|
};
|
|
563
523
|
try {
|
|
564
524
|
const encodedTitle = encodeRfc2047(this.title);
|
|
565
|
-
const res = await
|
|
525
|
+
const res = await http_1.httpClient.request(`${ntfyUrl || 'https://ntfy.sh'}/${ntfyTopic}`, Object.assign(Object.assign({}, this.gotOption), { body: `${this.content}`, headers: { Title: encodedTitle, Priority: `${ntfyPriority || '3'}` }, method: 'POST' }));
|
|
566
526
|
if (res.statusCode === 200) {
|
|
567
527
|
return true;
|
|
568
528
|
}
|
|
569
529
|
else {
|
|
570
|
-
throw new Error(
|
|
530
|
+
throw new Error(await res.body.text());
|
|
571
531
|
}
|
|
572
532
|
}
|
|
573
533
|
catch (error) {
|
|
@@ -597,8 +557,7 @@ let NotificationService = class NotificationService {
|
|
|
597
557
|
}
|
|
598
558
|
const url = `https://wxpusher.zjiecode.com/api/send/message`;
|
|
599
559
|
try {
|
|
600
|
-
const res = await
|
|
601
|
-
.post(url, Object.assign(Object.assign({}, this.gotOption), { json: {
|
|
560
|
+
const res = await http_1.httpClient.post(url, Object.assign(Object.assign({}, this.gotOption), { json: {
|
|
602
561
|
appToken: wxPusherBotAppToken,
|
|
603
562
|
content: `<h1>${this.title}</h1><br/><div style='white-space: pre-wrap;'>${this.content}</div>`,
|
|
604
563
|
summary: this.title,
|
|
@@ -606,8 +565,7 @@ let NotificationService = class NotificationService {
|
|
|
606
565
|
topicIds: topicIds,
|
|
607
566
|
uids: uids,
|
|
608
567
|
verifyPayType: 0,
|
|
609
|
-
} }))
|
|
610
|
-
.json();
|
|
568
|
+
} }));
|
|
611
569
|
if (res.code === 1000) {
|
|
612
570
|
return true;
|
|
613
571
|
}
|
|
@@ -655,12 +613,12 @@ let NotificationService = class NotificationService {
|
|
|
655
613
|
},
|
|
656
614
|
],
|
|
657
615
|
};
|
|
658
|
-
const res = await
|
|
616
|
+
const res = await http_1.httpClient.request(url, Object.assign(Object.assign({}, this.gotOption), { json: data, headers, method: 'POST' }));
|
|
659
617
|
if (res.statusCode === 200) {
|
|
660
618
|
return true;
|
|
661
619
|
}
|
|
662
620
|
else {
|
|
663
|
-
throw new Error(res.body);
|
|
621
|
+
throw new Error(await res.body.text());
|
|
664
622
|
}
|
|
665
623
|
}
|
|
666
624
|
}
|
|
@@ -682,12 +640,13 @@ let NotificationService = class NotificationService {
|
|
|
682
640
|
const options = Object.assign(Object.assign(Object.assign({ method: webhookMethod, headers }, this.gotOption), { allowGetBody: true }), bodyParam);
|
|
683
641
|
try {
|
|
684
642
|
const formatUrl = (_a = webhookUrl === null || webhookUrl === void 0 ? void 0 : webhookUrl.replaceAll('$title', encodeURIComponent(this.title))) === null || _a === void 0 ? void 0 : _a.replaceAll('$content', encodeURIComponent(this.content));
|
|
685
|
-
const res = await
|
|
643
|
+
const res = await http_1.httpClient.request(formatUrl, options);
|
|
644
|
+
const text = await res.body.text();
|
|
686
645
|
if (String(res.statusCode).startsWith('20')) {
|
|
687
646
|
return true;
|
|
688
647
|
}
|
|
689
648
|
else {
|
|
690
|
-
throw new Error(
|
|
649
|
+
throw new Error(await res.body.text());
|
|
691
650
|
}
|
|
692
651
|
}
|
|
693
652
|
catch (error) {
|
|
@@ -28,7 +28,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
const cross_spawn_1 = require("cross-spawn");
|
|
30
30
|
const fs_1 = __importDefault(require("fs"));
|
|
31
|
-
const
|
|
31
|
+
const undici_1 = require("undici");
|
|
32
32
|
const sum_1 = __importDefault(require("lodash/sum"));
|
|
33
33
|
const path_1 = __importDefault(require("path"));
|
|
34
34
|
const typedi_1 = require("typedi");
|
|
@@ -212,10 +212,14 @@ let SystemService = class SystemService {
|
|
|
212
212
|
const currentVersionContent = await (0, util_1.parseVersion)(config_1.default.versionFile);
|
|
213
213
|
let lastVersionContent;
|
|
214
214
|
try {
|
|
215
|
-
const
|
|
216
|
-
|
|
215
|
+
const { body } = await (0, undici_1.request)(`${config_1.default.lastVersionFile}?t=${Date.now()}`, {
|
|
216
|
+
dispatcher: new undici_1.Agent({
|
|
217
|
+
keepAliveTimeout: 30000,
|
|
218
|
+
keepAliveMaxTimeout: 30000,
|
|
219
|
+
}),
|
|
217
220
|
});
|
|
218
|
-
|
|
221
|
+
const text = await body.text();
|
|
222
|
+
lastVersionContent = (0, util_1.parseContentVersion)(text);
|
|
219
223
|
}
|
|
220
224
|
catch (error) { }
|
|
221
225
|
if (!lastVersionContent) {
|
|
@@ -29,6 +29,8 @@ const dayjs_1 = __importDefault(require("dayjs"));
|
|
|
29
29
|
const ip2region_1 = __importDefault(require("ip2region"));
|
|
30
30
|
const request_ip_1 = __importDefault(require("request-ip"));
|
|
31
31
|
const uniq_1 = __importDefault(require("lodash/uniq"));
|
|
32
|
+
const pickBy_1 = __importDefault(require("lodash/pickBy"));
|
|
33
|
+
const isNil_1 = __importDefault(require("lodash/isNil"));
|
|
32
34
|
const store_1 = require("../shared/store");
|
|
33
35
|
let UserService = class UserService {
|
|
34
36
|
constructor(logger, scheduleService, sockService) {
|
|
@@ -300,12 +302,13 @@ let UserService = class UserService {
|
|
|
300
302
|
async resetAuthInfo(info) {
|
|
301
303
|
const { retries, twoFactorActivated, password, username } = info;
|
|
302
304
|
const authInfo = await this.getAuthInfo();
|
|
303
|
-
|
|
305
|
+
const payload = (0, pickBy_1.default)({
|
|
304
306
|
retries,
|
|
305
307
|
twoFactorActivated,
|
|
306
308
|
password,
|
|
307
|
-
username
|
|
308
|
-
});
|
|
309
|
+
username,
|
|
310
|
+
}, (x) => !(0, isNil_1.default)(x));
|
|
311
|
+
await this.updateAuthInfo(authInfo, payload);
|
|
309
312
|
}
|
|
310
313
|
};
|
|
311
314
|
__decorate([
|