From ebe5ee08491478d101a9431771112b1e579204cd Mon Sep 17 00:00:00 2001 From: Rafa de la Torre Date: Tue, 20 Apr 2021 12:05:53 +0200 Subject: [PATCH] Simplify: use MessageBrokerHelper#cartodb_central_topic --- app/models/carto/connection.rb | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/app/models/carto/connection.rb b/app/models/carto/connection.rb index d5977ec880..6a783d8625 100644 --- a/app/models/carto/connection.rb +++ b/app/models/carto/connection.rb @@ -1,6 +1,8 @@ module Carto class Connection < ActiveRecord::Base + include ::MessageBrokerHelper + TYPE_OAUTH_SERVICE = 'oauth-service'.freeze TYPE_DB_CONNECTOR = 'db-connector'.freeze @@ -42,10 +44,10 @@ module Carto before_validation :manage_prevalidation after_create :manage_create - after_create :notify_central_bq_connection_created, if :bigquery_connector? + after_create :notify_central_bq_connection_created, if: :bigquery_connector? after_update :manage_update after_destroy :manage_destroy - after_destroy :notify_central_bq_connection_deleted, if :bigquery_connector? + after_destroy :notify_central_bq_connection_deleted, if: :bigquery_connector? def complete? connection_manager.complete?(self) @@ -58,15 +60,11 @@ module Carto end def notify_central_bq_connection_created - message_broker = Carto::Common::MessageBroker.new(logger: logger) - notifications_topic = message_broker.get_topic(:cartodb_central) - notifications_topic.publish(:grant_do_full_access, { username: user.username, target_email: bq_permissions_target_mail }) + cartodb_central_topic.publish(:grant_do_full_access, { username: user.username, target_email: bq_permissions_target_mail }) end def notify_central_bq_connection_deleted - message_broker = Carto::Common::MessageBroker.new(logger: logger) - notifications_topic = message_broker.get_topic(:cartodb_central) - notifications_topic.publish(:revoke_do_full_access, { username: user.username, target_email: bq_permissions_target_mail }) + cartodb_central_topic.publish(:revoke_do_full_access, { username: user.username, target_email: bq_permissions_target_mail }) end def bq_permissions_target_mail