Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Support for enabling email notifications #289

Merged
merged 6 commits into from
May 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions src/UserSettingsStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
},
};
4 changes: 2 additions & 2 deletions src/components/structures/UserSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,12 +328,12 @@ module.exports = React.createClass({
);
}
var notification_area;
if (!MatrixClientPeg.get().isGuest()) {
if (!MatrixClientPeg.get().isGuest() && this.state.threepids !== undefined) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

surely we should still show the Notifications settings, even if the user has no threepids?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If they have no threepids, this should be the empty list.

notification_area = (<div>
<h3>Notifications</h3>

<div className="mx_UserSettings_section">
<Notifications/>
<Notifications threepids={this.state.threepids} />
</div>
</div>);
}
Expand Down