Fix getMessageAreaByTag() and improve hasMessageConfAndAreaRead()
This commit is contained in:
parent
dff8e12dcc
commit
d5268c7b9e
|
@ -254,7 +254,7 @@ function getMessageAreaByTag(areaTag, optionalConfTag) {
|
||||||
|
|
||||||
// :TODO: this could be cached
|
// :TODO: this could be cached
|
||||||
if(_.isString(optionalConfTag)) {
|
if(_.isString(optionalConfTag)) {
|
||||||
if(_.isObject(confs, [ optionalConfTag, 'areas', areaTag ])) {
|
if(_.has(confs, [ optionalConfTag, 'areas', areaTag ])) {
|
||||||
return Object.assign(
|
return Object.assign(
|
||||||
{
|
{
|
||||||
areaTag,
|
areaTag,
|
||||||
|
@ -269,7 +269,7 @@ function getMessageAreaByTag(areaTag, optionalConfTag) {
|
||||||
//
|
//
|
||||||
let area;
|
let area;
|
||||||
_.forEach(confs, (conf, confTag) => {
|
_.forEach(confs, (conf, confTag) => {
|
||||||
if(_.isObject(conf, [ 'areas', areaTag ])) {
|
if(_.has(conf, [ 'areas', areaTag ])) {
|
||||||
area = Object.assign({ areaTag, confTag }, conf.areas[areaTag]);
|
area = Object.assign({ areaTag, confTag }, conf.areas[areaTag]);
|
||||||
return false; // stop iteration
|
return false; // stop iteration
|
||||||
}
|
}
|
||||||
|
@ -401,9 +401,12 @@ function changeMessageArea(client, areaTag, cb) {
|
||||||
changeMessageAreaWithOptions(client, areaTag, { persist : true }, cb);
|
changeMessageAreaWithOptions(client, areaTag, { persist : true }, cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
function hasMessageConfAndAreaRead(client, area) {
|
function hasMessageConfAndAreaRead(client, areaOrTag) {
|
||||||
const conf = getMessageConfTagByAreaTag(area.areaTag);
|
if(_.isString(areaOrTag)) {
|
||||||
return client.acs.hasMessageConfRead(conf) && client.acs.hasMessageAreaRead(area);
|
areaOrTag = getMessageAreaByTag(areaOrTag) || {};
|
||||||
|
}
|
||||||
|
const conf = getMessageConferenceByTag(areaOrTag.confTag);
|
||||||
|
return client.acs.hasMessageConfRead(conf) && client.acs.hasMessageAreaRead(areaOrTag);
|
||||||
}
|
}
|
||||||
|
|
||||||
function filterMessageAreaTagsByReadACS(client, areaTags) {
|
function filterMessageAreaTagsByReadACS(client, areaTags) {
|
||||||
|
@ -472,8 +475,7 @@ function getMessageListForArea(client, areaTag, filter, cb)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(client) {
|
if(client) {
|
||||||
const area = getMessageAreaByTag(areaTag);
|
if(!hasMessageConfAndAreaRead(client, areaTag)) {
|
||||||
if(!client.acs.hasMessageAreaRead(area)) {
|
|
||||||
return cb(null, []);
|
return cb(null, []);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue