add toggle for email notifications

This commit is contained in:
Javier 2016-10-28 10:13:40 -03:00
commit 410d35495b
6 changed files with 100 additions and 49 deletions

View file

@ -85,6 +85,10 @@ angular.module('copayApp.services').factory('configService', function(storageSer
windows: {},
}
},
emailNotifications: {
enabled: true,
},
};
var configCache = null;

View file

@ -0,0 +1,36 @@
'use strict';
angular.module('copayApp.services').factory('emailService', function($log, configService, profileService, lodash, walletService) {
var root = {};
root.enableEmailNotifications = function(val) {
val = val || false;
var config = configService.getSync();
if (!config.emailFor) {
$log.debug('No email configuration available');
return;
}
var keys = lodash.keys(config.emailFor);
var wallets = lodash.map(keys, function(k) {
return profileService.getWallet(k);
});
if (!wallets) {
$log.debug('No wallets found');
return;
}
lodash.each(wallets, function(w) {
walletService.updateRemotePreferences(w, {
email: val ? config.emailFor[w.credentials.walletId] : null
}, function(err) {
if (err) $log.warn(err);
});
});
};
return root;
});