From fcab259511e844923938c4f73102d724187a4de8 Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 12 Apr 2016 16:17:04 +0100 Subject: [PATCH 1/3] Support for email notifs Add utility funcs in UserSettingsStore and pass threepids to Notifications so it can do email notif stuff --- src/UserSettingsStore.js | 29 +++++++++++++++++++++++ src/components/structures/UserSettings.js | 4 ++-- 2 files changed, 31 insertions(+), 2 deletions(-) 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 = (

Notifications

- +
); } From 6a596f034f6255e2b91ba93b4d30b3e58ccfa5c4 Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 3 May 2016 11:21:05 +0100 Subject: [PATCH 2/3] Clarify comment --- src/UserSettingsStore.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/UserSettingsStore.js b/src/UserSettingsStore.js index b93c19a309..cddf90a1b6 100644 --- a/src/UserSettingsStore.js +++ b/src/UserSettingsStore.js @@ -103,7 +103,7 @@ module.exports = { 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 + append: true, // We always append for email pushers since we don't want to stop other accounts notifying to the same email address }); }, }; From 6dd530e2a4b8bb2ebd8d143329b4fa0a6ba833be Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 4 May 2016 09:41:36 +0100 Subject: [PATCH 3/3] Comment getEmailPusher --- src/UserSettingsStore.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/UserSettingsStore.js b/src/UserSettingsStore.js index cddf90a1b6..cf7131eb7b 100644 --- a/src/UserSettingsStore.js +++ b/src/UserSettingsStore.js @@ -78,6 +78,12 @@ 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;