diff --git a/src/UserSettingsStore.js b/src/UserSettingsStore.js index 49baf3a3a0..b93c19a309 100644 --- a/src/UserSettingsStore.js +++ b/src/UserSettingsStore.js @@ -77,4 +77,33 @@ module.exports = { return cli.setPassword(authDict, new_password); }, + + getEmailPusher: function(pushers, address) { + if (pushers === undefined) { + return undefined; + } + for (var i = 0; i < pushers.length; ++i) { + if (pushers[i].kind == 'email' && pushers[i].pushkey == address) { + return pushers[i]; + } + } + return undefined; + }, + + hasEmailPusher: function(pushers, address) { + return this.getEmailPusher(pushers, address) !== undefined; + }, + + addEmailPusher: function(address) { + return MatrixClientPeg.get().setPusher({ + kind: 'email', + app_id: "m.email", + pushkey: address, + app_display_name: 'Email Notifications', + device_display_name: address, + lang: navigator.language, + data: {}, + append: true, // We always append for email pushers since the email is not a device that would 'logged out' from + }); + }, }; diff --git a/src/components/structures/UserSettings.js b/src/components/structures/UserSettings.js index a5f2a59878..5c0e6cbf09 100644 --- a/src/components/structures/UserSettings.js +++ b/src/components/structures/UserSettings.js @@ -319,12 +319,12 @@ module.exports = React.createClass({ ); } var notification_area; - if (!MatrixClientPeg.get().isGuest()) { + if (!MatrixClientPeg.get().isGuest() && this.state.threepids !== undefined) { notification_area = (