Test sending a message from a pad (inner iframe)

pull/1/head
yflory 6 years ago
parent 9ead40a332
commit 7fd3bba2a6

@ -451,6 +451,7 @@ define([
avatar: Util.find(store.proxy, ['profile', 'avatar']), avatar: Util.find(store.proxy, ['profile', 'avatar']),
profile: Util.find(store.proxy, ['profile', 'view']), profile: Util.find(store.proxy, ['profile', 'view']),
color: getUserColor(), color: getUserColor(),
notifications: Util.find(store.proxy, ['mailboxes', 'notifications', 'channel']),
curvePublic: store.proxy.curvePublic, curvePublic: store.proxy.curvePublic,
}, },
// "priv" is not shared with other users but is needed by the apps // "priv" is not shared with other users but is needed by the apps

@ -343,6 +343,9 @@ proxy.mailboxes = {
if (cmd === 'DISMISS') { if (cmd === 'DISMISS') {
return void dismiss(ctx, data, clientId, cb); return void dismiss(ctx, data, clientId, cb);
} }
if (cmd === 'SENDTO') {
return void sendTo(ctx, data.type, data.msg, data.user, cb);
}
}; };
return mailbox; return mailbox;

@ -31,8 +31,16 @@ define([
}); });
}; };
mailbox.sendTo = function (user, type, content) { mailbox.sendTo = function (type, content, user) {
console.log(user, type, content); console.log(user, type, content);
execCommand('SENDTO', {
type: type,
msg: content,
user: user
}, function (err, obj) {
if (err || (obj && obj.error)) { return void console.error(err || obj.error); }
console.log('notif sent to other user from inner');
});
}; };
// UI // UI

@ -69,7 +69,23 @@ define([
return void UI.alert(Messages.pinLimitNotPinned, null, true); return void UI.alert(Messages.pinLimitNotPinned, null, true);
} else if (err) { return; } } else if (err) { return; }
evTitleChange.fire(title); evTitleChange.fire(title);
if (titleUpdated) { titleUpdated(undefined, title); } if (titleUpdated) {
titleUpdated(undefined, title);
// XXX Test notifications from inner
var users = metadataMgr.getMetadata().users;
var me = metadataMgr.getNetfluxId();
Object.keys(users).forEach(function (netfluxId) {
if (netfluxId === me) { return; }
var user = users[netfluxId];
if (!user.curvePublic || !user.notifications) { return; }
Common.mailbox.sendTo("TEST_NOTIF_TITLE", {
new_title: title
}, {
channel: user.notifications,
curvePublic: user.curvePublic
});
});
}
}); });
}); });

Loading…
Cancel
Save