@whyour/qinglong 0.19.8 → 0.20.0

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/README-en.md CHANGED
@@ -54,62 +54,6 @@ The npm version supports `debian/ubuntu/centos/alpine` systems and requires `nod
54
54
  npm i @whyour/qinglong
55
55
  ```
56
56
 
57
- ## Built-in commands
58
-
59
- - task
60
-
61
- ```bash
62
- # Execute in sequence, if a random delay is set, it will be randomly delayed by a certain number of seconds
63
- task <file_path>
64
- # Execute in sequence, regardless of whether a random delay is set, all run immediately,
65
- # and the foreground will output the day, while recorded in the log file
66
- task <file_path> now
67
- # Concurrent execution, regardless of whether a random delay is set, are run immediately,
68
- # the foreground does not generate the day, directly recorded in the log file, and can be specified account execution
69
- task <file_path> conc <env_name> <account_number>(Optional)
70
- # Specify the account to execute and run immediately regardless of whether a random delay is set
71
- task <file_path> desi <env_name> <account_number>
72
- # Set task timeout
73
- task -m <max_time> <file_path>
74
- # Use -- to split, -- followed by a parameter that is passed to the script, as in the following example, the script receives the parameter -u whyour -p password
75
- task <file_path> -- -u whyour -p password
76
- ```
77
-
78
- - ql
79
-
80
- ```bash
81
- # Update and restart Green Dragon
82
- ql update
83
- # Run custom scripts extra.sh
84
- ql extra
85
- # Adding a single script file
86
- ql raw <file_url>
87
- # Add a specific script for a single repository
88
- ql repo <repo_url> <whitelist> <blacklist> <dependence> <branch>
89
- # Delete old logs
90
- ql rmlog <days>
91
- # Start bot
92
- ql bot
93
- # Detecting the Green Dragon environment and repairing it
94
- ql check
95
- # Reset the number of login errors
96
- ql resetlet
97
- # Disable two-step login
98
- ql resettfa
99
- ```
100
-
101
- | **Parameter** | **Description** |
102
- |---|---|
103
- | file_url | Script address |
104
- | repo_url | Repository address |
105
- | whitelist | The whitelist when pulling the repository, i.e., the string contained in the path of the script to be pulled |
106
- | blacklist | Blacklisting when pulling repositories, i.e. strings that are not included in the path of the script to be pulled |
107
- | dependence | Pulling the dependencies needed for the repository will be copied directly from the repository to the repository directory under scripts, regardless of the blacklist |
108
- | extensions | Pull the branch of the repository |
109
- | branch | Number of days of logs to be kept |
110
- | days | File path for task execution |
111
- | file_path | The name of the environment variable that needs to be concurrent or specified at the time of task execution |
112
-
113
57
  ## Deployment
114
58
 
115
59
  ### Docker (Recommended)
@@ -183,16 +127,72 @@ export QL_DATA_DIR=""
183
127
  qinglong
184
128
  ```
185
129
 
130
+ ## Built-in commands
131
+
132
+ - task
133
+
134
+ ```bash
135
+ # Execute in sequence, if a random delay is set, it will be randomly delayed by a certain number of seconds
136
+ task <file_path>
137
+ # Execute in sequence, regardless of whether a random delay is set, all run immediately,
138
+ # and the foreground will output the day, while recorded in the log file
139
+ task <file_path> now
140
+ # Concurrent execution, regardless of whether a random delay is set, are run immediately,
141
+ # the foreground does not generate the day, directly recorded in the log file, and can be specified account execution
142
+ task <file_path> conc <env_name> <account_number>(Optional)
143
+ # Specify the account to execute and run immediately regardless of whether a random delay is set
144
+ task <file_path> desi <env_name> <account_number>
145
+ # Set task timeout
146
+ task -m <max_time> <file_path>
147
+ # Use -- to split, -- followed by a parameter that is passed to the script, as in the following example, the script receives the parameter -u whyour -p password
148
+ task <file_path> -- -u whyour -p password
149
+ ```
150
+
151
+ - ql
152
+
153
+ ```bash
154
+ # Update and restart Green Dragon
155
+ ql update
156
+ # Run custom scripts extra.sh
157
+ ql extra
158
+ # Adding a single script file
159
+ ql raw <file_url>
160
+ # Add a specific script for a single repository
161
+ ql repo <repo_url> <whitelist> <blacklist> <dependence> <branch>
162
+ # Delete old logs
163
+ ql rmlog <days>
164
+ # Start bot
165
+ ql bot
166
+ # Detecting the Green Dragon environment and repairing it
167
+ ql check
168
+ # Reset the number of login errors
169
+ ql resetlet
170
+ # Disable two-step login
171
+ ql resettfa
172
+ ```
173
+
174
+ | **Parameter** | **Description** |
175
+ |---|---|
176
+ | file_url | Script address |
177
+ | repo_url | Repository address |
178
+ | whitelist | The whitelist when pulling the repository, i.e., the string contained in the path of the script to be pulled |
179
+ | blacklist | Blacklisting when pulling repositories, i.e. strings that are not included in the path of the script to be pulled |
180
+ | dependence | Pulling the dependencies needed for the repository will be copied directly from the repository to the repository directory under scripts, regardless of the blacklist |
181
+ | extensions | Pull the branch of the repository |
182
+ | branch | Number of days of logs to be kept |
183
+ | days | File path for task execution |
184
+ | file_path | The name of the environment variable that needs to be concurrent or specified at the time of task execution |
185
+
186
186
  ## Development
187
187
 
188
188
  ```bash
189
- $ git clone https://github.com/whyour/qinglong.git
190
- $ cd qinglong
191
- $ cp .env.example .env
189
+ git clone https://github.com/whyour/qinglong.git
190
+ cd qinglong
191
+ cp .env.example .env
192
192
  # Recommended use pnpm https://pnpm.io/zh/installation
193
- $ npm install -g pnpm@8.3.1
194
- $ pnpm install
195
- $ pnpm start
193
+ npm install -g pnpm@8.3.1
194
+ pnpm install
195
+ pnpm start
196
196
  ```
197
197
 
198
198
  Open your browser and visit <http://127.0.0.1:5700>
package/README.md CHANGED
@@ -56,60 +56,6 @@ npm 版本支持 `debian/ubuntu/centos/alpine` 系统,需要自行安装 `node
56
56
  npm i @whyour/qinglong
57
57
  ```
58
58
 
59
- ## 内置命令
60
-
61
- - task
62
-
63
- ```bash
64
- # 依次执行,如果设置了随机延迟,将随机延迟一定秒数
65
- task <file_path>
66
- # 依次执行,无论是否设置了随机延迟,均立即运行,前台会输出日,同时记录在日志文件中
67
- task <file_path> now
68
- # 并发执行,无论是否设置了随机延迟,均立即运行,前台不产生日,直接记录在日志文件中,且可指定账号执行
69
- task <file_path> conc <env_name> <account_number>(可选的)
70
- # 指定账号执行,无论是否设置了随机延迟,均立即运行
71
- task <file_path> desi <env_name> <account_number>
72
- # 设置任务超时时间
73
- task -m <max_time> <file_path>
74
- # 使用 -- 分割,-- 后面的参数会传给脚本,下面的例子,脚本就可接收到参数 -u whyour -p password
75
- task <file_path> -- -u whyour -p password
76
- ```
77
-
78
- - ql
79
-
80
- ```bash
81
- # 更新并重启青龙
82
- ql update
83
- # 运行自定义脚本extra.sh
84
- ql extra
85
- # 添加单个脚本文件
86
- ql raw <file_url>
87
- # 添加单个仓库的指定脚本
88
- ql repo <repo_url> <whitelist> <blacklist> <dependence> <branch> <extensions>
89
- # 删除旧日志
90
- ql rmlog <days>
91
- # 启动tg-bot
92
- ql bot
93
- # 检测青龙环境并修复
94
- ql check
95
- # 重置登录错误次数
96
- ql resetlet
97
- # 禁用两步登录
98
- ql resettfa
99
- ```
100
-
101
- | **参数** | **说明** |
102
- |------------|---------------------------------------------------------------------------------------------|
103
- | file_url | 脚本地址 |
104
- | repo_url | 仓库地址 |
105
- | whitelist | 拉取仓库时的白名单,即就是需要拉取的脚本的路径包含的字符串,多个竖线分割 |
106
- | blacklist | 拉取仓库时的黑名单,即就是需要拉取的脚本的路径不包含的字符串,多个竖线分割 |
107
- | dependence | 拉取仓库需要的依赖文件,会直接从仓库拷贝到scripts下的仓库目录,不受黑名单影响,多个竖线分割 |
108
- | extensions | 拉取仓库的文件后缀,多个竖线分割 |
109
- | branch | 拉取仓库的分支 |
110
- | days | 需要保留的日志的天数 |
111
- | file_path | 任务执行时的文件路径 |
112
-
113
59
  ## 部署
114
60
 
115
61
  ### docker (推荐)
@@ -183,16 +129,70 @@ export QL_DATA_DIR=""
183
129
  qinglong
184
130
  ```
185
131
 
132
+ ## 内置命令
133
+
134
+ - task
135
+
136
+ ```bash
137
+ # 依次执行,如果设置了随机延迟,将随机延迟一定秒数
138
+ task <file_path>
139
+ # 依次执行,无论是否设置了随机延迟,均立即运行,前台会输出日,同时记录在日志文件中
140
+ task <file_path> now
141
+ # 并发执行,无论是否设置了随机延迟,均立即运行,前台不产生日,直接记录在日志文件中,且可指定账号执行
142
+ task <file_path> conc <env_name> <account_number>(可选的)
143
+ # 指定账号执行,无论是否设置了随机延迟,均立即运行
144
+ task <file_path> desi <env_name> <account_number>
145
+ # 设置任务超时时间
146
+ task -m <max_time> <file_path>
147
+ # 使用 -- 分割,-- 后面的参数会传给脚本,下面的例子,脚本就可接收到参数 -u whyour -p password
148
+ task <file_path> -- -u whyour -p password
149
+ ```
150
+
151
+ - ql
152
+
153
+ ```bash
154
+ # 更新并重启青龙
155
+ ql update
156
+ # 运行自定义脚本extra.sh
157
+ ql extra
158
+ # 添加单个脚本文件
159
+ ql raw <file_url>
160
+ # 添加单个仓库的指定脚本
161
+ ql repo <repo_url> <whitelist> <blacklist> <dependence> <branch> <extensions>
162
+ # 删除旧日志
163
+ ql rmlog <days>
164
+ # 启动tg-bot
165
+ ql bot
166
+ # 检测青龙环境并修复
167
+ ql check
168
+ # 重置登录错误次数
169
+ ql resetlet
170
+ # 禁用两步登录
171
+ ql resettfa
172
+ ```
173
+
174
+ | **参数** | **说明** |
175
+ |------------|---------------------------------------------------------------------------------------------|
176
+ | file_url | 脚本地址 |
177
+ | repo_url | 仓库地址 |
178
+ | whitelist | 拉取仓库时的白名单,即就是需要拉取的脚本的路径包含的字符串,多个竖线分割 |
179
+ | blacklist | 拉取仓库时的黑名单,即就是需要拉取的脚本的路径不包含的字符串,多个竖线分割 |
180
+ | dependence | 拉取仓库需要的依赖文件,会直接从仓库拷贝到scripts下的仓库目录,不受黑名单影响,多个竖线分割 |
181
+ | extensions | 拉取仓库的文件后缀,多个竖线分割 |
182
+ | branch | 拉取仓库的分支 |
183
+ | days | 需要保留的日志的天数 |
184
+ | file_path | 任务执行时的文件路径 |
185
+
186
186
  ## 开发
187
187
 
188
188
  ```bash
189
- $ git clone https://github.com/whyour/qinglong.git
190
- $ cd qinglong
191
- $ cp .env.example .env
189
+ git clone https://github.com/whyour/qinglong.git
190
+ cd qinglong
191
+ cp .env.example .env
192
192
  # 推荐使用 pnpm https://pnpm.io/zh/installation
193
- $ npm install -g pnpm@8.3.1
194
- $ pnpm install
195
- $ pnpm start
193
+ npm install -g pnpm@8.3.1
194
+ pnpm install
195
+ pnpm start
196
196
  ```
197
197
 
198
198
  打开你的浏览器,访问 <http://127.0.0.1:5700>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whyour/qinglong",
3
- "version": "0.19.8",
3
+ "version": "0.20.0",
4
4
  "description": "Timed task management platform supporting Python3, JavaScript, Shell, Typescript",
5
5
  "repository": {
6
6
  "type": "git",
package/sample/notify.js CHANGED
@@ -358,17 +358,24 @@ function barkNotify(text, desp, params = {}) {
358
358
  BARK_PUSH = `https://api.day.app/${BARK_PUSH}`;
359
359
  }
360
360
  const options = {
361
- url: `${BARK_PUSH}/${encodeURIComponent(text)}/${encodeURIComponent(
362
- desp,
363
- )}?icon=${BARK_ICON}&sound=${BARK_SOUND}&group=${BARK_GROUP}&isArchive=${BARK_ARCHIVE}&level=${BARK_LEVEL}&url=${BARK_URL}&${querystring.stringify(
364
- params,
365
- )}`,
361
+ url: `${BARK_PUSH}`,
362
+ json: {
363
+ title: text,
364
+ body: desp,
365
+ icon: BARK_ICON,
366
+ sound: BARK_SOUND,
367
+ group: BARK_GROUP,
368
+ isArchive: BARK_ARCHIVE,
369
+ level: BARK_LEVEL,
370
+ url: BARK_URL,
371
+ ...params,
372
+ },
366
373
  headers: {
367
- 'Content-Type': 'application/x-www-form-urlencoded',
374
+ 'Content-Type': 'application/json',
368
375
  },
369
376
  timeout,
370
377
  };
371
- $.get(options, (err, resp, data) => {
378
+ $.post(options, (err, resp, data) => {
372
379
  try {
373
380
  if (err) {
374
381
  console.log('Bark APP 发送通知调用API失败😞\n', err);
package/sample/notify.py CHANGED
@@ -137,9 +137,9 @@ def bark(title: str, content: str) -> None:
137
137
  print("bark 服务启动")
138
138
 
139
139
  if push_config.get("BARK_PUSH").startswith("http"):
140
- url = f'{push_config.get("BARK_PUSH")}/{urllib.parse.quote_plus(title)}/{urllib.parse.quote_plus(content)}'
140
+ url = f'{push_config.get("BARK_PUSH")}'
141
141
  else:
142
- url = f'https://api.day.app/{push_config.get("BARK_PUSH")}/{urllib.parse.quote_plus(title)}/{urllib.parse.quote_plus(content)}'
142
+ url = f'https://api.day.app/{push_config.get("BARK_PUSH")}'
143
143
 
144
144
  bark_params = {
145
145
  "BARK_ARCHIVE": "isArchive",
@@ -149,7 +149,10 @@ def bark(title: str, content: str) -> None:
149
149
  "BARK_LEVEL": "level",
150
150
  "BARK_URL": "url",
151
151
  }
152
- params = ""
152
+ data = {
153
+ "title": title,
154
+ "body": content,
155
+ }
153
156
  for pair in filter(
154
157
  lambda pairs: pairs[0].startswith("BARK_")
155
158
  and pairs[0] != "BARK_PUSH"
@@ -157,10 +160,11 @@ def bark(title: str, content: str) -> None:
157
160
  and bark_params.get(pairs[0]),
158
161
  push_config.items(),
159
162
  ):
160
- params += f"{bark_params.get(pair[0])}={pair[1]}&"
161
- if params:
162
- url = url + "?" + params.rstrip("&")
163
- response = requests.get(url).json()
163
+ data[bark_params.get(pair[0])] = pair[1]
164
+ headers = {"Content-Type": "application/json;charset=utf-8"}
165
+ response = requests.post(
166
+ url=url, data=json.dumps(data), headers=headers, timeout=15
167
+ ).json()
164
168
 
165
169
  if response["code"] == 200:
166
170
  print("bark 推送成功!")
@@ -385,6 +389,7 @@ def pushplus_bot(title: str, content: str) -> None:
385
389
  else:
386
390
  print("PUSHPLUS 推送失败!")
387
391
 
392
+
388
393
  def weplus_bot(title: str, content: str) -> None:
389
394
  """
390
395
  通过 微加机器人 推送消息。
@@ -396,7 +401,7 @@ def weplus_bot(title: str, content: str) -> None:
396
401
 
397
402
  template = "txt"
398
403
  if len(content) > 800:
399
- template = "html"
404
+ template = "html"
400
405
 
401
406
  url = "https://www.weplusbot.com/send"
402
407
  data = {
@@ -704,7 +709,11 @@ def pushme(title: str, content: str) -> None:
704
709
  return
705
710
  print("PushMe 服务启动")
706
711
 
707
- url = push_config.get("PUSHME_URL") if push_config.get("PUSHME_URL") else "https://push.i-i.me/"
712
+ url = (
713
+ push_config.get("PUSHME_URL")
714
+ if push_config.get("PUSHME_URL")
715
+ else "https://push.i-i.me/"
716
+ )
708
717
  data = {
709
718
  "push_key": push_config.get("PUSHME_KEY"),
710
719
  "title": title,
package/shell/update.sh CHANGED
@@ -156,21 +156,15 @@ update_raw() {
156
156
  autoDelCron=${AutoDelCron}
157
157
  fi
158
158
 
159
- local proxyStr=""
160
- if [[ $proxy ]]; then
161
- if [[ $url == http:* ]]; then
162
- proxyStr="-e \"http_proxy=${proxy}\""
163
- elif [[ $url == https:* ]]; then
164
- proxyStr="-e \"http_proxy=${proxy};https_proxy=${proxy}\""
165
- fi
166
- fi
167
-
168
159
  local raw_url="$url"
169
160
  local suffix="${raw_url##*.}"
170
161
  local raw_file_name="${uniq_path}.${suffix}"
171
162
  echo -e "开始下载:${raw_url} \n\n保存路径:$dir_raw/${raw_file_name}\n"
172
163
 
173
- wget -q --no-check-certificate $proxyStr -O "$dir_raw/${raw_file_name}.new" ${raw_url}
164
+ set_proxy "$proxy"
165
+ wget -q --no-check-certificate -O "$dir_raw/${raw_file_name}.new" ${raw_url}
166
+ exit_status=$?
167
+ unset_proxy
174
168
 
175
169
  if [[ $? -eq 0 ]]; then
176
170
  mv "$dir_raw/${raw_file_name}.new" "$dir_raw/${raw_file_name}"
@@ -255,7 +249,7 @@ reload_qinglong() {
255
249
  reload_pm2
256
250
  }
257
251
 
258
- ## 更新qinglong
252
+ ## 更新 qinglong
259
253
  update_qinglong() {
260
254
  rm -rf ${dir_tmp}/*
261
255
  local mirror="gitee"
@@ -527,7 +521,7 @@ main() {
527
521
  raw)
528
522
  get_uniq_path "$p2"
529
523
  if [[ -n $p2 ]]; then
530
- update_raw "$p2" "$p3" "$p4"
524
+ update_raw "$p2" "$p3" "$p4" "$p5"
531
525
  else
532
526
  eval echo -e "命令输入错误...\\\n" $cmd
533
527
  eval usage $cmd
@@ -180,7 +180,7 @@ exports.default = (app) => {
180
180
  else {
181
181
  return res.send({
182
182
  code: 400,
183
- message: '文件缺少name或者value字段,参考导出文件格式',
183
+ message: '每条数据 name 或者 value 字段不能为空,参考导出文件格式',
184
184
  });
185
185
  }
186
186
  }
@@ -14,7 +14,7 @@ async function startServer() {
14
14
  await require('./loaders/sentry').default({ expressApp: app });
15
15
  await require('./loaders/app').default({ expressApp: app });
16
16
  const server = app
17
- .listen(config_1.default.port, () => {
17
+ .listen(config_1.default.port, '0.0.0.0', () => {
18
18
  var _a;
19
19
  logger_1.default.debug(`✌️ 后端服务启动成功!`);
20
20
  console.debug(`✌️ 后端服务启动成功!`);
@@ -27,7 +27,7 @@ function formatCommand(doc, url) {
27
27
  let _url = url || formatUrl(doc).url;
28
28
  const { type, whitelist, blacklist, dependences, branch, extensions, proxy, autoAddCron, autoDelCron, } = doc;
29
29
  if (type === 'file') {
30
- command += `raw "${_url}"`;
30
+ command += `raw "${_url}" "${proxy || ''}" "${(0, isNil_1.default)(autoAddCron) ? true : Boolean(autoAddCron)}" "${(0, isNil_1.default)(autoDelCron) ? true : Boolean(autoDelCron)}"`;
31
31
  }
32
32
  else {
33
33
  command += `repo "${_url}" "${whitelist || ''}" "${blacklist || ''}" "${dependences || ''}" "${branch || ''}" "${extensions || ''}" "${proxy || ''}" "${(0, isNil_1.default)(autoAddCron) ? true : Boolean(autoAddCron)}" "${(0, isNil_1.default)(autoDelCron) ? true : Boolean(autoDelCron)}"`;
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SystemModel = exports.AuthDataType = exports.LoginStatus = exports.AuthInfo = void 0;
3
+ exports.SystemModel = exports.AuthDataType = exports.LoginStatus = exports.SystemInfo = void 0;
4
4
  const _1 = require(".");
5
5
  const sequelize_1 = require("sequelize");
6
- class AuthInfo {
6
+ class SystemInfo {
7
7
  constructor(options) {
8
8
  this.ip = options.ip;
9
9
  this.info = options.info;
@@ -11,7 +11,7 @@ class AuthInfo {
11
11
  this.id = options.id;
12
12
  }
13
13
  }
14
- exports.AuthInfo = AuthInfo;
14
+ exports.SystemInfo = SystemInfo;
15
15
  var LoginStatus;
16
16
  (function (LoginStatus) {
17
17
  LoginStatus[LoginStatus["success"] = 0] = "success";
@@ -10,26 +10,20 @@ const initData_1 = __importDefault(require("./initData"));
10
10
  const deps_1 = __importDefault(require("./deps"));
11
11
  const initTask_1 = __importDefault(require("./initTask"));
12
12
  exports.default = async ({ expressApp }) => {
13
- try {
14
- (0, depInjector_1.default)();
15
- logger_1.default.info('✌️ Dependency Injector loaded');
16
- console.log('✌️ Dependency Injector loaded');
17
- (0, express_1.default)({ app: expressApp });
18
- logger_1.default.info('✌️ Express loaded');
19
- console.log('✌️ Express loaded');
20
- await (0, initData_1.default)();
21
- logger_1.default.info('✌️ init data loaded');
22
- console.log('✌️ init data loaded');
23
- await (0, deps_1.default)();
24
- logger_1.default.info('✌️ link deps loaded');
25
- console.log('✌️ link deps loaded');
26
- (0, initTask_1.default)();
27
- logger_1.default.info('✌️ init task loaded');
28
- console.log('✌️ init task loaded');
29
- }
30
- catch (error) {
31
- logger_1.default.error(`✌️ depInjectorLoader expressLoader initData linkDeps failed, ${error}`);
32
- console.error(`✌️ depInjectorLoader expressLoader initData linkDeps failed ${error}`);
33
- }
13
+ (0, depInjector_1.default)();
14
+ logger_1.default.info('✌️ Dependency loaded');
15
+ console.log('✌️ Dependency loaded');
16
+ await (0, initData_1.default)();
17
+ logger_1.default.info('✌️ Init data loaded');
18
+ console.log('✌️ Init data loaded');
19
+ await (0, deps_1.default)();
20
+ logger_1.default.info('✌️ Link deps loaded');
21
+ console.log('✌️ Link deps loaded');
22
+ (0, initTask_1.default)();
23
+ logger_1.default.info('✌️ Init task loaded');
24
+ console.log('✌️ Init task loaded');
25
+ (0, express_1.default)({ app: expressApp });
26
+ logger_1.default.info('✌️ Express loaded');
27
+ console.log('✌️ Express loaded');
34
28
  };
35
29
  //# sourceMappingURL=app.js.map
@@ -22,6 +22,9 @@ exports.default = async () => {
22
22
  const envService = typedi_1.Container.get(env_1.default);
23
23
  const dependenceService = typedi_1.Container.get(dependence_1.default);
24
24
  const systemService = typedi_1.Container.get(system_2.default);
25
+ // 初始化增加系统配置
26
+ await system_1.SystemModel.upsert({ type: system_1.AuthDataType.systemConfig });
27
+ await system_1.SystemModel.upsert({ type: system_1.AuthDataType.notification });
25
28
  const installDependencies = () => {
26
29
  // 初始化时安装所有处于安装中,安装成功,安装失败的依赖
27
30
  dependence_2.DependenceModel.findAll({
@@ -129,7 +132,5 @@ exports.default = async () => {
129
132
  // 初始化保存一次ck和定时任务数据
130
133
  await cronService.autosave_crontab();
131
134
  await envService.set_envs();
132
- // 初始化增加系统配置
133
- await system_1.SystemModel.upsert({ type: system_1.AuthDataType.systemConfig });
134
135
  };
135
136
  //# sourceMappingURL=initData.js.map
@@ -19,7 +19,7 @@ app.get('/api/health', (req, res) => {
19
19
  });
20
20
  });
21
21
  app
22
- .listen(config_1.default.publicPort, async () => {
22
+ .listen(config_1.default.publicPort, '0.0.0.0', async () => {
23
23
  var _a;
24
24
  await require('./loaders/sentry').default({ expressApp: app });
25
25
  await require('./loaders/db').default();
@@ -323,7 +323,10 @@ let CronService = class CronService {
323
323
  }
324
324
  async getDb(query) {
325
325
  const doc = await cron_1.CrontabModel.findOne({ where: Object.assign({}, query) });
326
- return doc && doc.get({ plain: true });
326
+ if (!doc) {
327
+ throw new Error(`Cron ${JSON.stringify(query)} not found`);
328
+ }
329
+ return doc.get({ plain: true });
327
330
  }
328
331
  async run(ids) {
329
332
  await cron_1.CrontabModel.update({ status: cron_1.CrontabStatus.queued }, { where: { id: ids } });
@@ -65,7 +65,10 @@ let CronViewService = class CronViewService {
65
65
  }
66
66
  async getDb(query) {
67
67
  const doc = await cronView_1.CrontabViewModel.findOne({ where: Object.assign({}, query) });
68
- return doc && doc.get({ plain: true });
68
+ if (!doc) {
69
+ throw new Error(`CronView ${JSON.stringify(query)} not found`);
70
+ }
71
+ return doc.get({ plain: true });
69
72
  }
70
73
  async disabled(ids) {
71
74
  await cronView_1.CrontabViewModel.update({ isDisabled: 1 }, { where: { id: ids } });
@@ -141,7 +141,10 @@ let DependenceService = class DependenceService {
141
141
  }
142
142
  async getDb(query) {
143
143
  const doc = await dependence_1.DependenceModel.findOne({ where: Object.assign({}, query) });
144
- return doc && doc.get({ plain: true });
144
+ if (!doc) {
145
+ throw new Error(`Dependency ${JSON.stringify(query)} not found`);
146
+ }
147
+ return doc.get({ plain: true });
145
148
  }
146
149
  async updateLog(ids, log) {
147
150
  pLimit_1.default.updateDepLog(async () => {
@@ -169,7 +169,10 @@ let EnvService = class EnvService {
169
169
  }
170
170
  async getDb(query) {
171
171
  const doc = await env_1.EnvModel.findOne({ where: Object.assign({}, query) });
172
- return doc && doc.get({ plain: true });
172
+ if (!doc) {
173
+ throw new Error(`Env ${JSON.stringify(query)} not found`);
174
+ }
175
+ return doc.get({ plain: true });
173
176
  }
174
177
  async disabled(ids) {
175
178
  await env_1.EnvModel.update({ status: env_1.EnvStatus.disabled }, { where: { id: ids } });
@@ -190,10 +190,20 @@ let NotificationService = class NotificationService {
190
190
  if (!barkPush.startsWith('http')) {
191
191
  barkPush = `https://api.day.app/${barkPush}`;
192
192
  }
193
- const url = `${barkPush}/${encodeURIComponent(this.title)}/${encodeURIComponent(this.content)}?icon=${barkIcon}&sound=${barkSound}&group=${barkGroup}&level=${barkLevel}&url=${barkUrl}&isArchive=${barkArchive}`;
193
+ const url = `${barkPush}`;
194
+ const body = {
195
+ title: this.title,
196
+ body: this.content,
197
+ icon: barkIcon,
198
+ sound: barkSound,
199
+ group: barkGroup,
200
+ isArchive: barkArchive,
201
+ level: barkLevel,
202
+ url: barkUrl,
203
+ };
194
204
  try {
195
205
  const res = await got_1.default
196
- .get(url, Object.assign(Object.assign({}, this.gotOption), { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }))
206
+ .post(url, Object.assign(Object.assign({}, this.gotOption), { json: body, headers: { 'Content-Type': 'application/json' } }))
197
207
  .json();
198
208
  if (res.code === 200) {
199
209
  return true;
@@ -55,7 +55,10 @@ let OpenService = class OpenService {
55
55
  }
56
56
  async getDb(query) {
57
57
  const doc = await open_1.AppModel.findOne({ where: query });
58
- return doc && doc.get({ plain: true });
58
+ if (!doc) {
59
+ throw new Error(`App ${JSON.stringify(query)} not found`);
60
+ }
61
+ return doc.get({ plain: true });
59
62
  }
60
63
  async remove(ids) {
61
64
  await open_1.AppModel.destroy({ where: { id: ids } });
@@ -238,7 +238,7 @@ let SubscriptionService = class SubscriptionService {
238
238
  async getDb(query) {
239
239
  const doc = await subscription_1.SubscriptionModel.findOne({ where: Object.assign({}, query) });
240
240
  if (!doc) {
241
- throw new Error(`${JSON.stringify(query)} not found`);
241
+ throw new Error(`Subscription ${JSON.stringify(query)} not found`);
242
242
  }
243
243
  return doc.get({ plain: true });
244
244
  }
@@ -39,7 +39,7 @@ let SystemService = class SystemService {
39
39
  }
40
40
  async getSystemConfig() {
41
41
  const doc = await this.getDb({ type: system_1.AuthDataType.systemConfig });
42
- return doc || {};
42
+ return doc;
43
43
  }
44
44
  async updateAuthDb(payload) {
45
45
  await system_1.SystemModel.upsert(Object.assign({}, payload));
@@ -48,7 +48,10 @@ let SystemService = class SystemService {
48
48
  }
49
49
  async getDb(query) {
50
50
  const doc = await system_1.SystemModel.findOne({ where: Object.assign({}, query) });
51
- return doc && doc.get({ plain: true });
51
+ if (!doc) {
52
+ throw new Error(`System ${JSON.stringify(query)} not found`);
53
+ }
54
+ return doc.get({ plain: true });
52
55
  }
53
56
  async updateNotificationMode(notificationInfo) {
54
57
  const code = Math.random().toString().slice(-6);
@@ -294,7 +294,7 @@ let UserService = class UserService {
294
294
  }
295
295
  async getNotificationMode() {
296
296
  const doc = await this.getDb({ type: system_1.AuthDataType.notification });
297
- return (doc && doc.info) || {};
297
+ return doc.info;
298
298
  }
299
299
  async updateAuthDb(payload) {
300
300
  let doc = await system_1.SystemModel.findOne({ type: payload.type });
@@ -312,7 +312,10 @@ let UserService = class UserService {
312
312
  }
313
313
  async getDb(query) {
314
314
  const doc = await system_1.SystemModel.findOne({ where: Object.assign({}, query) });
315
- return doc && doc.get({ plain: true });
315
+ if (!doc) {
316
+ throw new Error(`${JSON.stringify(query)} not found`);
317
+ }
318
+ return doc.get({ plain: true });
316
319
  }
317
320
  async updateNotificationMode(notificationInfo) {
318
321
  const code = Math.random().toString().slice(-6);
@@ -13,7 +13,7 @@ async function startServer() {
13
13
  (0, depInjector_1.default)();
14
14
  await require('./loaders/update').default({ app });
15
15
  app
16
- .listen(config_1.default.updatePort, () => {
16
+ .listen(config_1.default.updatePort, '0.0.0.0', () => {
17
17
  var _a;
18
18
  logger_1.default.debug(`✌️ 更新服务启动成功!`);
19
19
  console.debug(`✌️ 更新服务启动成功!`);
package/version.yaml CHANGED
@@ -1,9 +1,7 @@
1
- version: 2.17.5
2
- changeLogLink: https://t.me/jiao_long/406
3
- publishTime: 2024-05-25 19:00
1
+ version: 2.17.6
2
+ changeLogLink: https://t.me/jiao_long/407
3
+ publishTime: 2024-06-14 23:00
4
4
  changeLog: |
5
- 1. 修复有可能手动运行任务无日志
6
- 2. 重构 JavaScript 脚本通知文件
7
- 3. PushMe 通知支持自建服务
8
- 4. 增加微加机器人消息通道
9
- 5. 修复任务详情查看脚本错误
5
+ 1. bark 推送改为 post 请求,防止请求头过大
6
+ 2. 修复单文件订阅代理无效
7
+ 3. 修复系统设置通知和依赖数据未初始化