Merge pull request #6872 from JakubOnderka/rest-response-filter-event

chg: [internal] Use RestResponse for filterEventIdsForPush
pull/7024/head
Jakub Onderka 2021-02-10 21:46:29 +01:00 committed by GitHub
commit 5c04671a0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 11 deletions

View File

@ -3695,9 +3695,6 @@ class EventsController extends AppController
public function filterEventIdsForPush()
{
if (!$this->userRole['perm_sync']) {
throw new MethodNotAllowedException(__('You do not have the permission to do that.'));
}
if ($this->request->is('post')) {
$incomingIDs = array();
$incomingEvents = array();
@ -3710,16 +3707,16 @@ class EventsController extends AppController
'recursive' => -1,
'fields' => array('Event.uuid', 'Event.timestamp', 'Event.locked'),
));
foreach ($events as $k => $v) {
if ($v['Event']['timestamp'] >= $incomingEvents[$v['Event']['uuid']]) {
unset($incomingEvents[$v['Event']['uuid']]);
foreach ($events as $event) {
if ($event['Event']['timestamp'] >= $incomingEvents[$event['Event']['uuid']]) {
unset($incomingEvents[$event['Event']['uuid']]);
continue;
}
if ($v['Event']['locked'] == 0) {
unset($incomingEvents[$v['Event']['uuid']]);
if ($event['Event']['locked'] == 0) {
unset($incomingEvents[$event['Event']['uuid']]);
}
}
$this->set('result', array_keys($incomingEvents));
return $this->RestResponse->viewData(array_keys($incomingEvents), $this->response->type());
}
}

View File

@ -1,2 +0,0 @@
<?php
echo json_encode($result);