Procházet zdrojové kódy

feat(sys-config): 添加获取布尔配置的方法并在任务服务中应用

xiongzhu před 10 měsíci
rodič
revize
0dd96629d0

+ 6 - 0
src/sys-config/sys-config.service.ts

@@ -246,6 +246,12 @@ export class SysConfigService implements OnModuleInit {
         return conf.value || defaultValue
     }
 
+    async getBoolean(name: string, defaultValue: boolean) {
+        const conf = await this.sysConfigRepository.findOneBy({ name })
+        if (!conf) return defaultValue
+        return conf.value === '1'
+    }
+
     async getApkManifest(url: string) {
         const response = await axios({
             method: 'GET',

+ 1 - 0
src/task/task.service.ts

@@ -142,6 +142,7 @@ export class TaskService implements OnModuleInit {
         task.message = task.message || ''
         task.total = phones.length
         task.country = phoneList.country
+        task.groupMode = await this.sysConfigService.getBoolean('group_mode', false)
         if (task.country) {
             const countryConfig = await this.countryConfigService.getDestConfig(task.country)
             task.useBackup = countryConfig.useBackup