Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F996200
not.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
not.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
=
locreq
(
"lib/datastore/query.js"
);
function
parse_params
(
app
,
params
)
{
let
strategies
;
if
(
params
instanceof
Array
)
{
strategies
=
params
.
map
(
declaration
=>
new
AccessStrategy
(
app
,
declaration
)
);
}
else
{
strategies
=
[
new
AccessStrategy
(
app
,
params
)];
}
return
strategies
;
}
module
.
exports
=
function
(
app
)
{
return
{
name
:
"not"
,
getRestrictingQuery
:
async
function
(
context
,
params
)
{
//assuming "not" can take only one access strategy as a parameter
const
strategy
=
parse_params
(
app
,
params
)[
0
];
const
query
=
await
strategy
.
getRestrictingQuery
(
context
);
return
new
Query
.
Not
(
query
);
},
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
,
false
);
},
checker_function
:
function
(
context
,
params
,
item
)
{
const
strategies
=
parse_params
(
app
,
params
);
return
Promise
.
map
(
strategies
,
function
(
strategy
)
{
return
strategy
.
check
(
context
,
item
);
})
.
any
()
.
then
(
function
()
{
return
Promise
.
reject
(
"Action not allowed"
);
})
.
catch
({
sealious_error
:
true
},
function
()
{
return
Promise
.
resolve
();
});
},
};
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Dec 24, 14:02 (20 h, 30 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
557104
Default Alt Text
not.js (1 KB)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline
Log In to Comment