|
|
@@ -1,4 +1,4 @@
|
|
|
-import { Injectable, Req, ServiceUnavailableException } from '@nestjs/common'
|
|
|
+import { Injectable, InternalServerErrorException, Req, ServiceUnavailableException } from '@nestjs/common'
|
|
|
import { InjectRepository } from '@nestjs/typeorm'
|
|
|
import { PhoneList } from './entities/phone-list.entity'
|
|
|
import { DataSource, In, Repository } from 'typeorm'
|
|
|
@@ -11,6 +11,7 @@ import axios from 'axios'
|
|
|
import { FileService } from '../file/file.service'
|
|
|
import { encryptData, getFileMd5FromUrl } from '../utils/crypto'
|
|
|
import * as yauzl from 'yauzl'
|
|
|
+import { getCountryDataList } from 'countries-list'
|
|
|
|
|
|
const token =
|
|
|
'QYiuiRiEnGWQk/QutmXyo154KeBvRKpg7Eqa/6N6FPgEUlyn5hJV1UmkK2yFRgVMEjQ7ByEAg/2jYFjCleNMaaPUdJfFCr5d9Nndj3b4mx4QM6iVIxxt9B6Phl6ZJ7gVPKtxGE+XTFJepWxaKs9VZSgLI9ORZ/rDD2HZhKQtOm0='
|
|
|
@@ -87,6 +88,13 @@ export class PhoneListService {
|
|
|
|
|
|
async createPhoneList(phoneList: PhoneList, type?: number): Promise<PhoneList> {
|
|
|
phoneList.type = type ? type : 0
|
|
|
+ if (
|
|
|
+ !getCountryDataList()
|
|
|
+ .map((c) => c.iso2 as string)
|
|
|
+ .includes(phoneList.country)
|
|
|
+ ) {
|
|
|
+ throw new InternalServerErrorException('Country code wrong!')
|
|
|
+ }
|
|
|
return await this.phoneListRepository.save(phoneList)
|
|
|
}
|
|
|
|