mirror of https://github.com/xwiki-labs/cryptpad
Merge branch 'notif-history' into 5.4-rc
This commit is contained in:
commit
5911051ccc
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue