Support for email notifs

Add utility funcs in UserSettingsStore and pass threepids to Notifications so it can do email notif stuff
This commit is contained in:
David Baker 2016-04-12 16:17:04 +01:00
parent 1d5f234f2c
commit fcab259511
2 changed files with 31 additions and 2 deletions

View file

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

View file

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