Merge pull request #4942 from JDonadio/feat/email-toggle
Add toggle for email notifications
This commit is contained in:
commit
ef63305d76
6 changed files with 100 additions and 49 deletions
|
|
@ -85,6 +85,10 @@ angular.module('copayApp.services').factory('configService', function(storageSer
|
|||
windows: {},
|
||||
}
|
||||
},
|
||||
|
||||
emailNotifications: {
|
||||
enabled: true,
|
||||
},
|
||||
};
|
||||
|
||||
var configCache = null;
|
||||
|
|
|
|||
36
src/js/services/emailService.js
Normal file
36
src/js/services/emailService.js
Normal 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;
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue