diff --git a/app/Model/Attribute.php b/app/Model/Attribute.php index fbe9559be..ae731f91c 100644 --- a/app/Model/Attribute.php +++ b/app/Model/Attribute.php @@ -480,7 +480,7 @@ class Attribute extends AppModel $result = $this->saveAttachment($attribute); } } - $pubToZmq = Configure::read('Plugin.ZeroMQ_enable') && Configure::read('Plugin.ZeroMQ_attribute_notifications_enable'); + $pubToZmq = $this->pubToZmq('attribute'); $kafkaTopic = $this->kafkaTopic('attribute'); if ($pubToZmq || $kafkaTopic) { $attributeForPublish = $this->fetchAttribute($this->id); @@ -532,7 +532,7 @@ class Attribute extends AppModel // update correlation.. $this->Correlation->beforeSaveCorrelation($this->data['Attribute']); if (!empty($this->data['Attribute']['id'])) { - if (Configure::read('Plugin.ZeroMQ_enable') && Configure::read('Plugin.ZeroMQ_attribute_notifications_enable')) { + if ($this->pubToZmq('attribute')) { $pubSubTool = $this->getPubSubTool(); $pubSubTool->attribute_save($this->data, 'delete'); } diff --git a/app/Model/Event.php b/app/Model/Event.php index cf18576b2..3a31aaa69 100755 --- a/app/Model/Event.php +++ b/app/Model/Event.php @@ -396,7 +396,7 @@ class Event extends AppModel } if (!empty($this->data['Event']['id'])) { - if (Configure::read('Plugin.ZeroMQ_enable') && Configure::read('Plugin.ZeroMQ_event_notifications_enable')) { + if ($this->pubToZmq('event')) { $pubSubTool = $this->getPubSubTool(); $pubSubTool->event_save(array('Event' => $this->data['Event']), 'delete'); } @@ -523,7 +523,7 @@ class Event extends AppModel $this->Attribute->Correlation->updateAll($updateCorrelation, ['Correlation.event_id' => (int)$event['id']]); } } - if (empty($event['unpublishAction']) && empty($event['skip_zmq']) && Configure::read('Plugin.ZeroMQ_enable') && Configure::read('Plugin.ZeroMQ_event_notifications_enable')) { + if (empty($event['unpublishAction']) && empty($event['skip_zmq']) && $this->pubToZmq('event')) { $pubSubTool = $this->getPubSubTool(); $eventForZmq = $this->quickFetchEvent($event['id']); if (!empty($event)) { diff --git a/app/Model/MispObject.php b/app/Model/MispObject.php index 4c45fcd08..aca87f5a0 100644 --- a/app/Model/MispObject.php +++ b/app/Model/MispObject.php @@ -300,9 +300,7 @@ class MispObject extends AppModel public function afterSave($created, $options = array()) { - $pubToZmq = Configure::read('Plugin.ZeroMQ_enable') && - Configure::read('Plugin.ZeroMQ_object_notifications_enable') && - empty($this->data['Object']['skip_zmq']); + $pubToZmq = $this->pubToZmq('object') && empty($this->data['Object']['skip_zmq']); $kafkaTopic = $this->kafkaTopic('object'); $pubToKafka = $kafkaTopic && empty($this->data['Object']['skip_kafka']); if ($pubToZmq || $pubToKafka) { @@ -329,10 +327,9 @@ class MispObject extends AppModel public function beforeDelete($cascade = true) { if (!empty($this->data['Object']['id'])) { - $pubToZmq = Configure::read('Plugin.ZeroMQ_enable') && Configure::read('Plugin.ZeroMQ_object_notifications_enable'); - $kafkaTopic = Configure::read('Plugin.Kafka_object_notifications_topic'); - $pubToKafka = Configure::read('Plugin.Kafka_enable') && Configure::read('Plugin.Kafka_object_notifications_enable') && !empty($kafkaTopic); - if ($pubToZmq || $pubToKafka) { + $pubToZmq = $this->pubToZmq('object'); + $kafkaTopic = $this->kafkaTopic('object'); + if ($pubToZmq || $kafkaTopic) { $object = $this->find('first', array( 'recursive' => -1, 'conditions' => array('Object.id' => $this->data['Object']['id']) @@ -341,7 +338,7 @@ class MispObject extends AppModel $pubSubTool = $this->getPubSubTool(); $pubSubTool->object_save($object, 'delete'); } - if ($pubToKafka) { + if ($kafkaTopic) { $kafkaPubTool = $this->getKafkaPubTool(); $kafkaPubTool->publishJson($kafkaTopic, $object, 'delete'); } diff --git a/app/Model/Organisation.php b/app/Model/Organisation.php index a15399588..0f9a8b80d 100644 --- a/app/Model/Organisation.php +++ b/app/Model/Organisation.php @@ -150,7 +150,7 @@ class Organisation extends AppModel public function afterSave($created, $options = array()) { - if (Configure::read('Plugin.ZeroMQ_enable') && Configure::read('Plugin.ZeroMQ_organisation_notifications_enable')) { + if ($this->pubToZmq('organisation')) { $pubSubTool = $this->getPubSubTool(); $pubSubTool->modified($this->data, 'organisation'); } diff --git a/app/Model/User.php b/app/Model/User.php index 0f7719fba..bb8e14ca2 100644 --- a/app/Model/User.php +++ b/app/Model/User.php @@ -276,7 +276,7 @@ class User extends AppModel public function afterSave($created, $options = array()) { - $pubToZmq = Configure::read('Plugin.ZeroMQ_enable') && Configure::read('Plugin.ZeroMQ_user_notifications_enable'); + $pubToZmq = $this->pubToZmq('user'); $kafkaTopic = $this->kafkaTopic('user'); if ($pubToZmq || $kafkaTopic) { if (!empty($this->data)) {