Merge pull request #289 from matrix-org/dbkr/email_notifs

Support for enabling email notifications
This commit is contained in:
Matthew Hodgson 2016-05-10 16:39:37 +02:00
commit 62a1100fca
2 changed files with 37 additions and 2 deletions

View file

@ -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
});
},
};

View file

@ -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 = (<div>
<h3>Notifications</h3>
<div className="mx_UserSettings_section">
<Notifications/>
<Notifications threepids={this.state.threepids} />
</div>
</div>);
}