Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F996276
and.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
and.js
View Options
"use strict"
;
const
locreq
=
require
(
"locreq"
)(
__dirname
);
const
Promise
=
require
(
"bluebird"
);
const
AccessStrategy
=
locreq
(
"lib/chip-types/access-strategy.js"
);
const
Query
=
require
(
"../../../datastore/query.js"
);
function
parse_params
(
app
,
params
)
{
return
Object
.
keys
(
params
).
map
(
i
=>
new
AccessStrategy
(
app
,
params
[
i
]));
}
module
.
exports
=
function
(
app
)
{
const
and
=
{
name
:
"and"
,
getRestrictingQuery
:
async
function
(
context
,
params
)
{
const
access_strategies
=
parse_params
(
app
,
params
);
const
queries
=
await
Promise
.
map
(
access_strategies
,
strategy
=>
strategy
.
getRestrictingQuery
(
context
)
);
if
(
queries
.
some
(
query
=>
query
instanceof
Query
.
DenyAll
))
{
return
new
Query
.
DenyAll
();
}
const
aggregated_pipeline
=
queries
.
reduce
(
(
acc
,
query
)
=>
acc
.
concat
(
query
.
toPipeline
()),
[]
);
return
Query
.
fromCustomPipeline
(
aggregated_pipeline
);
},
item_sensitive
:
function
(
params
)
{
const
access_strategies
=
parse_params
(
app
,
params
);
return
Promise
.
map
(
access_strategies
,
function
(
access_strategy
)
{
return
access_strategy
.
is_item_sensitive
();
}).
reduce
((
a
,
b
)
=>
a
||
b
);
},
checker_function
:
function
(
context
,
params
,
item
)
{
return
and
.
item_sensitive
(
params
).
then
(
function
(
item_sensitive
)
{
if
(
item_sensitive
&&
item
===
undefined
)
{
return
undefined
;
}
else
{
const
access_strategies
=
parse_params
(
app
,
params
);
const
results
=
access_strategies
.
map
(
function
(
strategy
)
{
return
strategy
.
check
(
context
,
item
);
});
return
Promise
.
all
(
results
);
}
});
},
};
return
and
;
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Dec 24, 14:02 (20 h, 56 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
557148
Default Alt Text
and.js (1 KB)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline
Log In to Comment