|
|
@@ -65,6 +65,57 @@ export class RcsNumberService {
|
|
|
|
|
|
private readonly redis: Redis | null
|
|
|
|
|
|
+ constructor(
|
|
|
+ @InjectRepository(RcsNumber)
|
|
|
+ private rcsNumberRepository: Repository<RcsNumber>,
|
|
|
+ @InjectRepository(BlackList)
|
|
|
+ private blackListRepository: Repository<BlackList>,
|
|
|
+ @Inject(forwardRef(() => DeviceService))
|
|
|
+ private deviceService: DeviceService,
|
|
|
+ @Inject(forwardRef(() => TaskService))
|
|
|
+ private taskService: TaskService,
|
|
|
+ private operatorConfigService: OperatorConfigService,
|
|
|
+ private channelService: ChannelService,
|
|
|
+ private carrierIdService: CarrierIdService,
|
|
|
+ private sysConfigService: SysConfigService,
|
|
|
+ private mwze167: mwze167,
|
|
|
+ private i18nvc: i18nvc,
|
|
|
+ private firefox: firefox,
|
|
|
+ private d38: d38,
|
|
|
+ private xyz: xyz,
|
|
|
+ private hwyzm: hwyzm,
|
|
|
+ private cowboy: cowboy,
|
|
|
+ private durainus: durainus,
|
|
|
+ private usapanel: usapanel,
|
|
|
+ private textverified: textverified,
|
|
|
+ private dashboard: dashboard,
|
|
|
+ private sms23256: sms23256,
|
|
|
+ private svenkvint: svenkvint,
|
|
|
+ private smsapi: smsapi,
|
|
|
+ private xlcode: xlcode,
|
|
|
+ private smsman: smsman,
|
|
|
+ private globalcode: globalcode,
|
|
|
+ private readonly redisService: RedisService
|
|
|
+ ) {
|
|
|
+ this.durian = new durian('unsnap3094', 'U3Jma1hkbUxXblEyL0ZYai9WWFVvdz09', RcsNumberSource.durian)
|
|
|
+ this.durian02 = new durian('unsnap30941', 'RHJGV1paR1BFWjlFbCtnakUza2xJdz09', RcsNumberSource.durian02)
|
|
|
+ this.cloud033 = new cloud214('100033', '1e40ca9795b1fc038db76512175d59b5', RcsNumberSource.cloud033)
|
|
|
+ this.cloud034 = new cloud214('100034', '54bdd0d9dd6707b2b40d8deb5edb1385', RcsNumberSource.cloud034)
|
|
|
+ this.cloud037 = new cloud214('100037', 'aaec6c21e54dc53b92e472df21a95bb7', RcsNumberSource.cloud037)
|
|
|
+ this.cloud041 = new cloud214('100041', '8174f3107605645d17fd6c5edc0bfb7d', RcsNumberSource.cloud041)
|
|
|
+ this.cloud050 = new cloud214('100050', '6c0f25c802b82d2a5c78f01fb627be2c', RcsNumberSource.cloud050)
|
|
|
+ this.sms4verify01 = new sms4verify('Yt8kbBGbvMTL3OBZ2dvwXCm78MI59D', '0', RcsNumberSource.sms4verify01)
|
|
|
+ this.sms4verify02 = new sms4verify('402qwEj44JiaWMOOBPIxMnWaqeyIuV', '0', RcsNumberSource.sms4verify02)
|
|
|
+ this.sms4verify03 = new sms4verify('LFSsOnOjipHUE6jtgCpcEy7M9SEGme', '0.45', RcsNumberSource.sms4verify03)
|
|
|
+ this.sms7979 = new sms7979('BbrlHwT4IWrfxR1tbSP6O8RkzW7Gdh', 45, RcsNumberSource.sms7979)
|
|
|
+ this.sms797902 = new sms7979('BbrlHwT4IWrfxR1tbSP6O8RkzW7Gdh', 45, RcsNumberSource.sms797902)
|
|
|
+ this.smspva = new smspva('uNW56fGr0zstfs87Xn0e1l2gCYVnb1', RcsNumberSource.smspva)
|
|
|
+ this.smspva02 = new smspva('rTTL8pZtKkQ60zjU82bvbMEP7G6XGU', RcsNumberSource.smspva02)
|
|
|
+ this.smstiger = new smstiger('Aq7XKGX7qnCf6y8CouchYJ0VK60AxISm', RcsNumberSource.smstiger)
|
|
|
+ this.smstiger02 = new smstiger('t6AV7f5KgwRmWsK9M5xN6uTTtHiog8EQ', RcsNumberSource.smstiger02)
|
|
|
+ this.redis = this.redisService.getOrThrow()
|
|
|
+ }
|
|
|
+
|
|
|
async findAll(req: PageRequest<RcsNumber>): Promise<Pagination<RcsNumber>> {
|
|
|
let page = await paginate<RcsNumber>(this.rcsNumberRepository, req.page, req.search)
|
|
|
let items = page.items
|
|
|
@@ -158,30 +209,9 @@ export class RcsNumberService {
|
|
|
const numberService = this.getNumberService(channel.source)
|
|
|
let res: GetNumberResponse
|
|
|
try {
|
|
|
- // const resString = await this.redis.rpop(operatorConfig.country)
|
|
|
- // res = resString ? JSON.parse(resString) : null
|
|
|
- // let attempts = 0
|
|
|
- // while (
|
|
|
- // res !== null &&
|
|
|
- // new Date(res.expiryTime).getTime() - 120000 < new Date().getTime() &&
|
|
|
- // (store ? !storeNumberChannels.includes(res.source.toString()) : true) &&
|
|
|
- // attempts < 20
|
|
|
- // ) {
|
|
|
- // attempts++
|
|
|
- // const newVar = await this.redis.rpop(operatorConfig.country)
|
|
|
- // res = newVar ? JSON.parse(newVar) : null
|
|
|
- // }
|
|
|
- // if (res === null || (res && store ? !storeNumberChannels.includes(res.source.toString()) : true)) {
|
|
|
- // res = await numberService.getNumber(operatorConfig.country)
|
|
|
- // } else {
|
|
|
- // Logger.log(`${operatorConfig.country} - ${res.source}\t Get the number from the cache`, 'GetNumber')
|
|
|
- // }
|
|
|
res = await numberService.getNumber(operatorConfig.country)
|
|
|
} catch (e) {
|
|
|
Logger.error(`${operatorConfig.country} - ${numberService.source}\t ${e.message}`, 'GetNumber')
|
|
|
- // if (channel.source === RcsNumberSource.usapanel) {
|
|
|
- // await this.redis.del('usapanel')
|
|
|
- // }
|
|
|
throw new ServiceUnavailableException(e.message)
|
|
|
}
|
|
|
if (!res?.number) {
|
|
|
@@ -190,6 +220,12 @@ export class RcsNumberService {
|
|
|
const rawNumber = res.number
|
|
|
res.number = checkAndFormatNumber(operatorConfig.country, res.number, res.operatorName)
|
|
|
if (await this.checkForDuplicateNumbers(res, channel.source)) {
|
|
|
+ if (channel.source === RcsNumberSource.durian || channel.source === RcsNumberSource.durian02) {
|
|
|
+ await numberService.blockNumber(res.number)
|
|
|
+ }
|
|
|
+ if (channel.source === RcsNumberSource.smspva || channel.source === RcsNumberSource.smspva02) {
|
|
|
+ await numberService.blockNumber(res.orderId)
|
|
|
+ }
|
|
|
throw new ServiceUnavailableException(`该号码已存在,无效号码: ${res.number}`)
|
|
|
}
|
|
|
const mapTo = matchOperator(res.operatorCode, operatorConfig)
|
|
|
@@ -242,57 +278,6 @@ export class RcsNumberService {
|
|
|
return number
|
|
|
}
|
|
|
|
|
|
- constructor(
|
|
|
- @InjectRepository(RcsNumber)
|
|
|
- private rcsNumberRepository: Repository<RcsNumber>,
|
|
|
- @InjectRepository(BlackList)
|
|
|
- private blackListRepository: Repository<BlackList>,
|
|
|
- @Inject(forwardRef(() => DeviceService))
|
|
|
- private deviceService: DeviceService,
|
|
|
- @Inject(forwardRef(() => TaskService))
|
|
|
- private taskService: TaskService,
|
|
|
- private operatorConfigService: OperatorConfigService,
|
|
|
- private channelService: ChannelService,
|
|
|
- private carrierIdService: CarrierIdService,
|
|
|
- private sysConfigService: SysConfigService,
|
|
|
- private mwze167: mwze167,
|
|
|
- private i18nvc: i18nvc,
|
|
|
- private firefox: firefox,
|
|
|
- private d38: d38,
|
|
|
- private xyz: xyz,
|
|
|
- private hwyzm: hwyzm,
|
|
|
- private cowboy: cowboy,
|
|
|
- private durainus: durainus,
|
|
|
- private usapanel: usapanel,
|
|
|
- private textverified: textverified,
|
|
|
- private dashboard: dashboard,
|
|
|
- private sms23256: sms23256,
|
|
|
- private svenkvint: svenkvint,
|
|
|
- private smsapi: smsapi,
|
|
|
- private xlcode: xlcode,
|
|
|
- private smsman: smsman,
|
|
|
- private globalcode: globalcode,
|
|
|
- private readonly redisService: RedisService
|
|
|
- ) {
|
|
|
- this.durian = new durian('unsnap3094', 'U3Jma1hkbUxXblEyL0ZYai9WWFVvdz09', RcsNumberSource.durian)
|
|
|
- this.durian02 = new durian('unsnap30941', 'RHJGV1paR1BFWjlFbCtnakUza2xJdz09', RcsNumberSource.durian02)
|
|
|
- this.cloud033 = new cloud214('100033', '1e40ca9795b1fc038db76512175d59b5', RcsNumberSource.cloud033)
|
|
|
- this.cloud034 = new cloud214('100034', '54bdd0d9dd6707b2b40d8deb5edb1385', RcsNumberSource.cloud034)
|
|
|
- this.cloud037 = new cloud214('100037', 'aaec6c21e54dc53b92e472df21a95bb7', RcsNumberSource.cloud037)
|
|
|
- this.cloud041 = new cloud214('100041', '8174f3107605645d17fd6c5edc0bfb7d', RcsNumberSource.cloud041)
|
|
|
- this.cloud050 = new cloud214('100050', '6c0f25c802b82d2a5c78f01fb627be2c', RcsNumberSource.cloud050)
|
|
|
- this.sms4verify01 = new sms4verify('Yt8kbBGbvMTL3OBZ2dvwXCm78MI59D', '0', RcsNumberSource.sms4verify01)
|
|
|
- this.sms4verify02 = new sms4verify('402qwEj44JiaWMOOBPIxMnWaqeyIuV', '0', RcsNumberSource.sms4verify02)
|
|
|
- this.sms4verify03 = new sms4verify('LFSsOnOjipHUE6jtgCpcEy7M9SEGme', '0.45', RcsNumberSource.sms4verify03)
|
|
|
- this.sms7979 = new sms7979('BbrlHwT4IWrfxR1tbSP6O8RkzW7Gdh', 45, RcsNumberSource.sms7979)
|
|
|
- this.sms797902 = new sms7979('BbrlHwT4IWrfxR1tbSP6O8RkzW7Gdh', 45, RcsNumberSource.sms797902)
|
|
|
- this.smspva = new smspva('uNW56fGr0zstfs87Xn0e1l2gCYVnb1', RcsNumberSource.smspva)
|
|
|
- this.smspva02 = new smspva('rTTL8pZtKkQ60zjU82bvbMEP7G6XGU', RcsNumberSource.smspva02)
|
|
|
- this.smstiger = new smstiger('Aq7XKGX7qnCf6y8CouchYJ0VK60AxISm', RcsNumberSource.smstiger)
|
|
|
- this.smstiger02 = new smstiger('t6AV7f5KgwRmWsK9M5xN6uTTtHiog8EQ', RcsNumberSource.smstiger02)
|
|
|
- this.redis = this.redisService.getOrThrow()
|
|
|
- }
|
|
|
-
|
|
|
async release(id: number): Promise<void> {
|
|
|
const rcsNumber = await this.rcsNumberRepository.findOneBy({ id })
|
|
|
if (rcsNumber) {
|
|
|
@@ -400,13 +385,11 @@ export class RcsNumberService {
|
|
|
|
|
|
async checkForDuplicateNumbers(res: GetNumberResponse, channel: RcsNumberSource) {
|
|
|
try {
|
|
|
- if (channel === RcsNumberSource.smspva || channel === RcsNumberSource.smspva02) {
|
|
|
- const size = await this.rcsNumberRepository.countBy({
|
|
|
- number: res.number
|
|
|
- })
|
|
|
- if (size > 3) {
|
|
|
- return true
|
|
|
- }
|
|
|
+ const size = await this.rcsNumberRepository.countBy({
|
|
|
+ number: res.number
|
|
|
+ })
|
|
|
+ if (size > 3) {
|
|
|
+ return true
|
|
|
}
|
|
|
} catch (e) {
|
|
|
Logger.error('checkForDuplicateNumbers error:', e.message)
|