new: [sync] Added a protection from receiving empty published events from other instances

- a temporary solution to some older, bugged instances emitting them
pull/4980/head
iglocska 2019-08-09 11:33:31 +02:00
parent 79be07069f
commit 647c640f06
No known key found for this signature in database
GPG Key ID: BEA224F1FEF113AC
1 changed files with 16 additions and 0 deletions

View File

@ -3374,6 +3374,22 @@ class Event extends AppModel
return 'Blocked by blacklist';
}
}
if (empty($data['Event']['Attribute']) && empty($data['Event']['Object']) && !empty($data['Event']['published'])) {
$this->Log = ClassRegistry::init('Log');
$this->Log->create();
$validationErrors['Event'] = 'Received a published event that was empty. Event add process blocked.';
$this->Log->save(array(
'org' => $user['Organisation']['name'],
'model' => 'Event',
'model_id' => 0,
'email' => $user['email'],
'action' => 'add',
'user_id' => $user['id'],
'title' => $validationErrors['Event'],
'change' => ''
));
return json_encode($validationErrors);
}
$this->create();
// force check userid and orgname to be from yourself
$data['Event']['user_id'] = $user['id'];