diff --git a/src/SlashCommands.js b/src/SlashCommands.js index fcdd33474e..5a43d41dd5 100644 --- a/src/SlashCommands.js +++ b/src/SlashCommands.js @@ -335,8 +335,14 @@ module.exports = { input = input.replace(/\s+$/, ""); if (input[0] === "/" && input[1] !== "/") { var bits = input.match(/^(\S+?)( +(.*))?$/); - var cmd = bits[1].substring(1).toLowerCase(); - var args = bits[3]; + var cmd, args; + if (bits) { + cmd = bits[1].substring(1).toLowerCase(); + args = bits[3]; + } + else { + cmd = input; + } if (cmd === "me") return null; if (aliases[cmd]) { cmd = aliases[cmd]; diff --git a/src/UserSettingsStore.js b/src/UserSettingsStore.js index 49baf3a3a0..cf7131eb7b 100644 --- a/src/UserSettingsStore.js +++ b/src/UserSettingsStore.js @@ -77,4 +77,39 @@ module.exports = { return cli.setPassword(authDict, new_password); }, + + /** + * Returns the email pusher (pusher of type 'email') for a given + * email address. Email pushers all have the same app ID, so since + * pushers are unique over (app ID, pushkey), there will be at most + * one such pusher. + */ + 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 we don't want to stop other accounts notifying to the same email address + }); + }, }; diff --git a/src/components/structures/UserSettings.js b/src/components/structures/UserSettings.js index 57c5b7a9be..e2a28f0cef 100644 --- a/src/components/structures/UserSettings.js +++ b/src/components/structures/UserSettings.js @@ -328,12 +328,12 @@ module.exports = React.createClass({ ); } var notification_area; - if (!MatrixClientPeg.get().isGuest()) { + if (!MatrixClientPeg.get().isGuest() && this.state.threepids !== undefined) { notification_area = (