|
|
@@ -147,15 +147,6 @@ export class TaskService implements OnModuleInit {
|
|
|
const taskItem = new TaskItem()
|
|
|
taskItem.taskId = task.id
|
|
|
taskItem.number = phone.number
|
|
|
- taskItem.message = task.message
|
|
|
- task.dynamicMessage?.forEach((dm) => {
|
|
|
- if (dm.key && dm.values?.length > 0) {
|
|
|
- taskItem.message = taskItem.message.replaceAll(
|
|
|
- `${dm.key}`,
|
|
|
- dm.values[Math.floor(Math.random() * dm.values.length)]
|
|
|
- )
|
|
|
- }
|
|
|
- })
|
|
|
taskItem.embed = extraNumbers.includes(phone.number)
|
|
|
taskItem.status = TaskStatus.IDLE
|
|
|
return taskItem
|
|
|
@@ -222,7 +213,7 @@ export class TaskService implements OnModuleInit {
|
|
|
|
|
|
async delTask(id: number): Promise<void> {
|
|
|
const task = await this.taskRepository.findOneBy({ id })
|
|
|
- if (task.status !== TaskStatus.IDLE){
|
|
|
+ if (task.status !== TaskStatus.IDLE) {
|
|
|
throw new Error('当前任务状态无法删除!')
|
|
|
}
|
|
|
await this.taskRepository.delete(id)
|
|
|
@@ -848,10 +839,6 @@ export class TaskService implements OnModuleInit {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- taskItems.forEach((item) => {
|
|
|
- item.message = this.getMessage(task)
|
|
|
- })
|
|
|
-
|
|
|
devices = devices.splice(0, Math.ceil(taskItems.length / 5))
|
|
|
const taskConfig = {
|
|
|
rcsWait: task.rcsWait || (await this.getConfig('rcs_wait', 2000)),
|
|
|
@@ -872,7 +859,9 @@ export class TaskService implements OnModuleInit {
|
|
|
)
|
|
|
Promise.all(
|
|
|
devices.map(async (device, i) => {
|
|
|
- const items = taskItems.slice(i * 5, i * 5 + 5)
|
|
|
+ const items = taskItems
|
|
|
+ .slice(i * 5, i * 5 + 5)
|
|
|
+ .map((item) => ({ ...item, message: this.getMessage(task) }))
|
|
|
try {
|
|
|
const res: any = await Promise.race([
|
|
|
this.eventsGateway.sendForResult(
|