Automation Fix
This commit is contained in:
parent
c6f57a3661
commit
9d9304d30e
@ -26,8 +26,18 @@ class AutomationsApi extends ApiController
|
|||||||
$this->requireAuth();
|
$this->requireAuth();
|
||||||
$obj = $this->input;
|
$obj = $this->input;
|
||||||
|
|
||||||
|
if (
|
||||||
|
empty($obj['name']) ||
|
||||||
|
!isset($obj['name']) ||
|
||||||
|
!isset($obj['conditions']) ||
|
||||||
|
!isset($obj['tasks']) ||
|
||||||
|
!isset($obj['days'])
|
||||||
|
) {
|
||||||
|
throw new Exception("Invalid request payload", 400);
|
||||||
|
}
|
||||||
|
|
||||||
$response = [];
|
$response = [];
|
||||||
$response = AutomationManager::create($obj['name'],$obj['days'], $obj['tasks'], $obj['conditions']);
|
$response = AutomationManager::create($obj['name'],json_encode($obj['days']), json_encode($obj['tasks']), json_encode($obj['conditions']));
|
||||||
|
|
||||||
$this->response(['value'=>'OK']);
|
$this->response(['value'=>'OK']);
|
||||||
}
|
}
|
||||||
|
@ -17,14 +17,14 @@ class AutomationManager{
|
|||||||
return Db::command ('UPDATE automation SET executed = 0 WHERE automation_id=?', array ($automationId));
|
return Db::command ('UPDATE automation SET executed = 0 WHERE automation_id=?', array ($automationId));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function create ($name, $onDays, $doCode, $ifCode, $automationId = "") {
|
public static function create ($name, $onDays, $doCode, $ifCode, $userId = 1, $automationId = "") {
|
||||||
$userId = UserManager::getUserData('user_id');
|
$userId = UserManager::getUserData('user_id', $userId);
|
||||||
$scene = array (
|
$scene = array (
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'owner_id' => $userId,
|
'owner_id' => $userId,
|
||||||
'on_days' => $onDays,
|
'on_days' => $onDays,
|
||||||
'if_something' => $ifCode,
|
'conditions' => $ifCode,
|
||||||
'do_something' => $doCode,
|
'tasks' => $doCode,
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
if ($automationId == "") {
|
if ($automationId == "") {
|
||||||
|
@ -14,7 +14,7 @@ class SettingsManager{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function create ($name, $value, $type = '') {
|
public static function create ($name, $value, $type = '') {
|
||||||
//if (!self::getByName($name)){
|
if (!self::getByName($name)){
|
||||||
$setting = array (
|
$setting = array (
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'value' => $value,
|
'value' => $value,
|
||||||
@ -26,7 +26,7 @@ class SettingsManager{
|
|||||||
echo $error->getMessage();
|
echo $error->getMessage();
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
//}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function update ($name, $value, $type = '') {
|
public static function update ($name, $value, $type = '') {
|
||||||
|
Loading…
Reference in New Issue
Block a user