| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- import { io } from "socket.io-client"
- import axios from "axios"
- import { setTimeout } from "timers/promises"
- import chalk from "chalk"
- const axiosInstance = axios.create({
- baseURL: "http://47.98.225.28/api",
- headers: {
- Authorization:
- "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InpvdW1hQWRtaW4iLCJzdWIiOjEsInJvbGVzIjpbImFkbWluIl0sImlhdCI6MTcyNjU4MTk1OH0.dQiHFYaDDa1qp4OpEHaH5SCZ9dafJ8uO9fAAc8HZgAo"
- }
- })
- const {
- data: { items: devices }
- } = await axiosInstance.post("/device", {
- page: { page: 1, limit: 1000 },
- search: {
- where: { online: true, busy: false, canSend: false },
- order: { name: "ASC" }
- }
- })
- for (let device of devices) {
- console.log(chalk.green(`${device.name} resume`))
- axiosInstance
- .post(
- `/device/${device.id}/sendMessage`,
- {
- action: "resume",
- data: { request: true, reset: true }
- },
- {
- timeout: 60000
- }
- )
- .catch(e => {
- console.log(chalk.red(e.message))
- })
- await setTimeout(500)
- }
|