Răsfoiți Sursa

feat(rcs-number): 添加存储属性和连接池大小配置

- 添加存储属性和连接池大小配置到rcs-number模块
- 导入SysConfigModule以支持存储属性配置

fix(sys-config): 添加备份渠道配置

- 添加备份渠道配置到sys-config模块
- 如果未配置备份渠道,则默认使用cloud034渠道
xiongzhu 1 an în urmă
părinte
comite
142b96bee9

+ 3 - 1
src/rcs-number/rcs-number.module.ts

@@ -18,6 +18,7 @@ import { CarrierIdModule } from 'src/carrier-id/carrier-id.module'
 import { BlackList } from './entities/black-list.entity'
 import { hwyzm } from './impl/hwyzm.service'
 import { cowboy } from './impl/cowboy.service'
+import { SysConfigModule } from 'src/sys-config/sys-config.module'
 
 @Module({
     imports: [
@@ -26,7 +27,8 @@ import { cowboy } from './impl/cowboy.service'
         OperaterConfigModule,
         forwardRef(() => TaskModule),
         ChannelModule,
-        CarrierIdModule
+        CarrierIdModule,
+        SysConfigModule
     ],
     providers: [RcsNumberService, mwze167, durian, i18nvc, firefox, d38, cloud214, xyz, hwyzm, cowboy],
     controllers: [RcsNumberController],

+ 16 - 3
src/rcs-number/rcs-number.service.ts

@@ -25,6 +25,7 @@ import { CarrierIdService } from 'src/carrier-id/carrier-id.service'
 import { BlackList } from './entities/black-list.entity'
 import { hwyzm } from './impl/hwyzm.service'
 import { cowboy } from './impl/cowboy.service'
+import { SysConfigService } from 'src/sys-config/sys-config.service'
 
 @Injectable()
 export class RcsNumberService {
@@ -45,6 +46,7 @@ export class RcsNumberService {
         private operatorConfigService: OperatorConfigService,
         private channelService: ChannelService,
         private carrierIdService: CarrierIdService,
+        private sysConfigService: SysConfigService,
         private mwze167: mwze167,
         private durian: durian,
         private i18nvc: i18nvc,
@@ -75,7 +77,7 @@ export class RcsNumberService {
         return page
     }
 
-    async create(country?: string, deviceId?: string, taskId?: number) {
+    async create(country?: string, deviceId?: string, taskId?: number, store?: boolean) {
         let operatorConfig: OperatorConfig
         if (country) {
             operatorConfig = await this.operatorConfigService.findByCountry(country)
@@ -111,13 +113,24 @@ export class RcsNumberService {
         }
 
         const channels = await this.channelService.all()
+
+        let storeNumberChannels: string[] = []
+        if (store) {
+            storeNumberChannels = (await this.sysConfigService.getString('store_number_channels', ''))
+                .split(',')
+                .map((i) => i.trim())
+                .filter((i) => i)
+        }
+
         const availableChannels = channels.filter((channel) => {
             return (
-                channel.countryConfig.find(
+                (store ? storeNumberChannels.includes(channel.source.toString()) : true) &&
+                (channel.countryConfig.find(
                     (config) =>
                         config.countryCode.toLowerCase() === operatorConfig.country ||
                         config.countryCode.toUpperCase() === operatorConfig.country
-                )?.enabled || false
+                )?.enabled ||
+                    false)
             )
         })
         if (!availableChannels.length) {

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

@@ -111,6 +111,14 @@ export class SysConfigService implements OnModuleInit {
                 remark: '使用备份'
             })
         }
+        if (!(await this.sysConfigRepository.findOneBy({ name: 'store_number_channels' }))) {
+            await this.sysConfigRepository.save({
+                name: 'store_number_channels',
+                value: 'cloud034',
+                type: SysConfigType.String,
+                remark: '备份渠道'
+            })
+        }
     }
 
     async findAll(req: PageRequest<SysConfig>) {