Merge branch 'notif-history' into 5.4-rc

This commit is contained in:
yflory 2023-07-11 14:59:21 +02:00
commit 5911051ccc
2 changed files with 19 additions and 10 deletions

View File

@ -806,7 +806,7 @@ define([
hash: 'string'
}
*/
if (!data.msg) { return void cb(true); }
if (!data.msg) { return void cb(null, null, true); }
// Check if the request is valid (sent by the correct user)
var myCurve = Util.find(ctx, ['store', 'proxy', 'curvePublic']);
@ -816,7 +816,7 @@ define([
// except if the author is ourselves.
if (curve && data.msg.author !== curve && data.msg.author !== myCurve) {
console.error('blocked');
return void cb(true);
return void cb(null, null, true);
}
var type = data.msg.type;

View File

@ -372,13 +372,13 @@ proxy.mailboxes = {
hash: hash
};
var notify = box.ready;
Handlers.add(ctx, box, message, function (dismissed, toDismiss) {
Handlers.add(ctx, box, message, function (dismissed, toDismiss, invalid) {
if (toDismiss) { // List of other messages to remove
dismiss(ctx, toDismiss, '', function () {
console.log('Notification handled automatically');
});
}
if (dismissed) { // This message should be removed
if (invalid || dismissed) { // This message should be removed
dismiss(ctx, {
type: type,
hash: hash
@ -475,12 +475,21 @@ proxy.mailboxes = {
console.log(e);
}
}
ctx.emit('HISTORY', {
txid: txid,
time: _msg[5],
message: message,
hash: _msg[4].slice(0,64)
}, [req.cId]);
var hash = _msg[4].slice(0,64);
Handlers.add(ctx, req.box, {
hash,
msg: message
}, function (dismissed, toDismiss, invalid) {
// Show dismissed messages, hide invalid messages
// Invalid: no content or impersonation attempt
if (invalid) { return; }
ctx.emit('HISTORY', {
txid: txid,
time: _msg[5],
message: message,
hash: hash
}, [req.cId]);
});
} else if (type === 'HISTORY_RANGE_END') {
ctx.emit('HISTORY', {
txid: txid,