/** * response all msg * @param $postObj * @return string */ function response($postObj) { $log = new Logs(); $return = ''; $msgType = $postObj->MsgType; $logmsg = '[user] ' . $postObj->FromUserName . ' [msg-type] ' . $msgType; switch ($msgType) { case MSGTYPE_EVENT: $logmsg .= ' [event] ' . $postObj->Event; switch ($postObj->Event) { case 'subscribe': //关注 $return = subscribe($postObj); break; case 'unsubscribe': unsubscribe($postObj); break; case 'CLICK': switch ($postObj->EventKey) { case 'MENU_NEWS': $return = news($postObj); break; } } break; case MSGTYPE_TEXT: //txt $logmsg .= ' [content] ' . $postObj->Content; $return = textResponse($postObj); break; default: $return = news($postObj); break; } if (!$log->write_log($logmsg, 'access')) { if (DEBUG) { echo 'error: ' . $log->error; } } return $return; }
$job = new Job($jobid); if ($job === false) { textResponse(204); } $machine = new Machine(Session::getMachineId()); if (!$machine->hasJob($job->getJobId())) { textResponse(403, 'Job not assigned to you'); } $job->unset('machine'); $job->set('buildstatus', $_POST['buildstatus']); $job->set('buildreason', $_POST['buildreason']); $job->moveToQueue('archivequeue'); jsonResponse(200, $job->getJobData()); })->conditions(array('jobid' => '[0-9]')); /* Jobgroup - List details of jobgroup */ $app->get('/group/:groupid/', 'isAllowed', function ($groupid) use($app) { $jobgroup = new Jobgroup($groupid); if (!$jobgroup->exists()) { textResponse(404, 'Jobgroup not found'); } jsonResponse(200, $jobgroup->getGroupInfo()); }); /* 404 - not found */ $app->notFound(function () use($app) { textResponse(404, 'Not found'); }); /* 500 - internal server error */ $app->error(function (\Exception $e) use($app) { textResponse(500, 'Internal Server Error'); }); $app->run();