mirror of https://github.com/MISP/MISP
fix: [feed] fix REST problems
parent
027aa91dd4
commit
8415cea5db
|
@ -132,7 +132,10 @@ class FeedsController extends AppController
|
|||
public function importFeeds()
|
||||
{
|
||||
if ($this->request->is('post')) {
|
||||
$results = $this->Feed->importFeeds($this->request->data['Feed']['json'], $this->Auth->user());
|
||||
if (isset($this->request->data['Feed']['json'])) {
|
||||
$this->request->data = $this->request->data['Feed']['json'];
|
||||
}
|
||||
$results = $this->Feed->importFeeds($this->request->data, $this->Auth->user());
|
||||
if ($results['successes'] > 0) {
|
||||
$flashType = 'success';
|
||||
$message = $results['successes'] . ' new feeds added.';
|
||||
|
@ -505,8 +508,12 @@ class FeedsController extends AppController
|
|||
}
|
||||
}
|
||||
}
|
||||
$this->Flash->success($message);
|
||||
$this->redirect(array('action' => 'index'));
|
||||
if ($this->_isRest()) {
|
||||
return $this->RestResponse->viewData(array('result' => $message), $this->response->type());
|
||||
} else {
|
||||
$this->Flash->success($message);
|
||||
$this->redirect(array('action' => 'index'));
|
||||
}
|
||||
}
|
||||
|
||||
public function getEvent($feedId, $eventUuid, $all = false)
|
||||
|
|
|
@ -1231,7 +1231,9 @@ class Feed extends AppModel
|
|||
|
||||
public function importFeeds($feeds, $user, $default = false)
|
||||
{
|
||||
$feeds = json_decode($feeds, true);
|
||||
if (is_string($feeds)) {
|
||||
$feeds = json_decode($feeds, true);
|
||||
}
|
||||
if ($feeds && !isset($feeds[0])) {
|
||||
$feeds = array($feeds);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue