|
|
@@ -102,7 +102,10 @@ export class TaskService implements OnModuleInit {
|
|
|
taskItem.taskId = task.id
|
|
|
taskItem.number = phone.number
|
|
|
if (dynamicMessageList !== null && task.message.includes('[#random#]')) {
|
|
|
- taskItem.message = task.message.replace('[#random#]', dynamicMessageList[Math.floor(Math.random() * dynamicMessageList.length)])
|
|
|
+ taskItem.message = task.message.replace(
|
|
|
+ '[#random#]',
|
|
|
+ dynamicMessageList[Math.floor(Math.random() * dynamicMessageList.length)]
|
|
|
+ )
|
|
|
} else {
|
|
|
taskItem.message = task.message
|
|
|
}
|
|
|
@@ -268,17 +271,16 @@ export class TaskService implements OnModuleInit {
|
|
|
async getToBeSentNum() {
|
|
|
let total = 0
|
|
|
// 任务队列
|
|
|
- const tasks = await this.taskRepository.find(
|
|
|
- {
|
|
|
- where: {
|
|
|
- status: TaskStatus.QUEUED
|
|
|
- },
|
|
|
- order: {
|
|
|
- createdAt: 'ASC'
|
|
|
- }
|
|
|
- })
|
|
|
+ const tasks = await this.taskRepository.find({
|
|
|
+ where: {
|
|
|
+ status: TaskStatus.QUEUED
|
|
|
+ },
|
|
|
+ order: {
|
|
|
+ createdAt: 'ASC'
|
|
|
+ }
|
|
|
+ })
|
|
|
if (tasks.length > 0) {
|
|
|
- const list = tasks.map(task => task.listId)
|
|
|
+ const list = tasks.map((task) => task.listId)
|
|
|
// 队列中剩余任务发送数
|
|
|
const number = await this.phoneRepository.countBy({
|
|
|
listId: In(list)
|
|
|
@@ -287,12 +289,11 @@ export class TaskService implements OnModuleInit {
|
|
|
}
|
|
|
|
|
|
// 正在执行的任务
|
|
|
- const current = await this.taskRepository.find(
|
|
|
- {
|
|
|
- where: {
|
|
|
- status: TaskStatus.PENDING
|
|
|
- }
|
|
|
- })
|
|
|
+ const current = await this.taskRepository.find({
|
|
|
+ where: {
|
|
|
+ status: TaskStatus.PENDING
|
|
|
+ }
|
|
|
+ })
|
|
|
if (current.length > 0) {
|
|
|
const number = await this.phoneRepository.countBy({
|
|
|
listId: current[0].listId
|
|
|
@@ -390,7 +391,13 @@ export class TaskService implements OnModuleInit {
|
|
|
id: randomUUID(),
|
|
|
action: 'task',
|
|
|
data: {
|
|
|
- config: { rcsWait, rcsInterval, cleanCount, requestNumberInterval },
|
|
|
+ config: {
|
|
|
+ rcsWait,
|
|
|
+ rcsInterval,
|
|
|
+ cleanCount,
|
|
|
+ requestNumberInterval,
|
|
|
+ checkConnection: task.checkConnection
|
|
|
+ },
|
|
|
tasks: taskItems,
|
|
|
taskId: task.id
|
|
|
}
|