diff --git a/NEWS.md b/NEWS.md index 6ae1491dbe..425aa8d406 100644 --- a/NEWS.md +++ b/NEWS.md @@ -16,6 +16,7 @@ Development * Include DB connections, all parameters for Oauth connections, and the relationship between synchronizations and connections, in User migrations [#16287](https://github.com/CartoDB/cartodb/pull/16287) * Upgrade to CARTO Viewer v1.0.8 [16347](https://github.com/CartoDB/cartodb/pull/16347) * Show user's database location in profile [16349](https://github.com/CartoDB/cartodb/pull/16349) +* Setting to enable/disable import notifications [16354](https://github.com/CartoDB/cartodb/pull/16354) ### Bug fixes / enhancements - Add marginTop to Page when notification is displayed [#16355](https://github.com/CartoDB/cartodb/pull/16355) diff --git a/app/models/carto/user_email_notification.rb b/app/models/carto/user_email_notification.rb index cf801608ab..4d4e779f9f 100644 --- a/app/models/carto/user_email_notification.rb +++ b/app/models/carto/user_email_notification.rb @@ -7,7 +7,8 @@ module Carto validate :valid_notification NOTIFICATION_DO_SUBSCRIPTIONS = 'do_subscriptions'.freeze - VALID_NOTIFICATIONS = [NOTIFICATION_DO_SUBSCRIPTIONS].freeze + NOTIFICATION_IMPORTS = 'imports'.freeze + VALID_NOTIFICATIONS = [NOTIFICATION_DO_SUBSCRIPTIONS, NOTIFICATION_IMPORTS].freeze def self.new_do_subscriptions(user_id) Carto::UserEmailNotification.create!( diff --git a/lib/assets/javascripts/locale/en.json b/lib/assets/javascripts/locale/en.json index ac3ad39ebd..a477a1b09f 100644 --- a/lib/assets/javascripts/locale/en.json +++ b/lib/assets/javascripts/locale/en.json @@ -92,7 +92,8 @@ "notifications": { "enabled": "On", "disabled": "Off", - "do_subscriptions":"Emails from Data Observatory" + "do_subscriptions": "Emails from Data Observatory", + "imports": "Emails from Imports" } } } diff --git a/lib/resque/user_jobs.rb b/lib/resque/user_jobs.rb index 0014416908..81f63ce207 100644 --- a/lib/resque/user_jobs.rb +++ b/lib/resque/user_jobs.rb @@ -191,6 +191,8 @@ module Resque def self.perform(user_id, imported_tables, total_tables, first_imported_table, first_table, errors, filenames) u = ::User.where(id: user_id).first + return unless u.carto_user.email_notification_enabled?(Carto::UserEmailNotification::NOTIFICATION_IMPORTS) + ImportMailer.data_import_finished(u, imported_tables, total_tables, first_imported_table, first_table, errors, filenames).deliver_now end diff --git a/package-lock.json b/package-lock.json index 2851d59706..ae1eacb9dd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "cartodb-ui", - "version": "1.0.0-assets.265", + "version": "1.0.0-assets.268", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 5c9637b8e1..2d8b7b1eaf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cartodb-ui", - "version": "1.0.0-assets.267", + "version": "1.0.0-assets.268", "description": "CARTO UI frontend", "repository": { "type": "git",