1
This commit is contained in:
@@ -3,6 +3,7 @@ const db = require('../dbProxy');
|
||||
const jobManager = require('../job/index');
|
||||
const ScheduleUtils = require('./utils');
|
||||
const ScheduleConfig = require('./config');
|
||||
const authorizationService = require('../../services/authorization_service');
|
||||
|
||||
|
||||
/**
|
||||
@@ -91,6 +92,12 @@ class CommandManager {
|
||||
throw new Error(`任务不存在: ${task_id}`);
|
||||
}
|
||||
|
||||
// 1.5 检查账号授权状态
|
||||
const authCheck = await authorizationService.checkAuthorization(task.sn_code, 'sn_code');
|
||||
if (!authCheck.is_authorized) {
|
||||
throw new Error(`授权检查失败: ${authCheck.message}`);
|
||||
}
|
||||
|
||||
// 2. 获取指令信息
|
||||
const command_name = command.command_name || command.name || '未知指令';
|
||||
const command_type = command.command_type || command.type;
|
||||
|
||||
@@ -48,6 +48,18 @@ class TaskHandlers {
|
||||
|
||||
console.log(`[任务处理器] 自动投递任务 - 设备: ${sn_code}, 关键词: ${keyword}`);
|
||||
|
||||
// 检查授权状态
|
||||
const authorizationService = require('../../services/authorization_service');
|
||||
const authCheck = await authorizationService.checkAuthorization(sn_code, 'sn_code');
|
||||
if (!authCheck.is_authorized) {
|
||||
console.log(`[任务处理器] 自动投递任务 - 设备: ${sn_code} 授权检查失败: ${authCheck.message}`);
|
||||
return {
|
||||
success: false,
|
||||
deliveredCount: 0,
|
||||
message: authCheck.message
|
||||
};
|
||||
}
|
||||
|
||||
deviceManager.recordTaskStart(sn_code, task);
|
||||
const startTime = Date.now();
|
||||
|
||||
@@ -543,6 +555,18 @@ class TaskHandlers {
|
||||
const { sn_code, taskParams } = task;
|
||||
console.log(`[任务处理器] 自动沟通任务 - 设备: ${sn_code}`);
|
||||
|
||||
// 检查授权状态
|
||||
const authorizationService = require('../../services/authorization_service');
|
||||
const authCheck = await authorizationService.checkAuthorization(sn_code, 'sn_code');
|
||||
if (!authCheck.is_authorized) {
|
||||
console.log(`[任务处理器] 自动沟通任务 - 设备: ${sn_code} 授权检查失败: ${authCheck.message}`);
|
||||
return {
|
||||
success: false,
|
||||
chatCount: 0,
|
||||
message: authCheck.message
|
||||
};
|
||||
}
|
||||
|
||||
deviceManager.recordTaskStart(sn_code, task);
|
||||
const startTime = Date.now();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user