Test sending a message to a friend

This commit is contained in:
yflory
2019-05-17 17:23:21 +02:00
parent b15c67e8d4
commit 9ead40a332
2 changed files with 30 additions and 12 deletions

View File

@@ -625,11 +625,25 @@ define([
// Set the display name (username) in the proxy
Store.setDisplayName = function (clientId, value, cb) {
if (store.mailbox) {
if (store.mailbox && store.proxy.friends) {
// XXX test mailbox, should be removed in prod
store.mailbox.post('notifications', 'NAME_CHANGED', {
/*store.mailbox.post('notifications', 'NAME_CHANGED', {
old: store.proxy[Constants.displayNameKey],
new: value
});*/
Object.keys(store.proxy.friends).forEach(function (curve) {
var f = store.proxy.friends[curve];
if (!f.notifications) { return; }
store.mailbox.sendTo('NAME_CHANGED', {
old: store.proxy[Constants.displayNameKey],
new: value
}, {
channel: f.notifications,
curvePublic: curve
}, function (obj) {
if (obj && obj.error) { return void console.error(obj.error); }
console.log('notif sent to '+f);
});
});
}
store.proxy[Constants.displayNameKey] = value;