Don't return messages user doesn't have access to!
This commit is contained in:
parent
d5268c7b9e
commit
4f6a0b175c
|
@ -5,6 +5,9 @@
|
|||
const MenuModule = require('./menu_module.js').MenuModule;
|
||||
const Message = require('./message.js');
|
||||
const UserProps = require('./user_property.js');
|
||||
const {
|
||||
hasMessageConfAndAreaRead
|
||||
} = require('./message_area.js');
|
||||
|
||||
exports.moduleInfo = {
|
||||
name : 'My Messages',
|
||||
|
@ -30,7 +33,27 @@ exports.getModule = class MyMessagesModule extends MenuModule {
|
|||
this.client.log.warn( { error : err.message }, 'Error finding messages addressed to current user');
|
||||
return this.prevMenu();
|
||||
}
|
||||
this.messageList = messageList;
|
||||
|
||||
//
|
||||
// We need to filter out messages belonging to conf/areas the user
|
||||
// doesn't have access to.
|
||||
//
|
||||
// Keep a cache around for quick lookup.
|
||||
//
|
||||
const acsCache = new Map(); // areaTag:boolean
|
||||
this.messageList = messageList.filter(msg => {
|
||||
let cached = acsCache.get(msg.areaTag);
|
||||
if(false === cached) {
|
||||
return false;
|
||||
}
|
||||
if(true === cached) {
|
||||
return true;
|
||||
}
|
||||
cached = hasMessageConfAndAreaRead(this.client, msg.areaTag);
|
||||
acsCache.set(msg.areaTag, cached);
|
||||
return cached;
|
||||
});
|
||||
|
||||
this.finishedLoading();
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue