Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F996143
or.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
or.ts
View Options
import
Bluebird
from
"bluebird"
;
import
Policy
,
{
ReducingPolicy
,
PolicyDecision
,
}
from
"../../chip-types/policy"
;
import
type
Context
from
"../../context"
;
import
{
AllowAll
}
from
"../../datastore/allow-all"
;
import
{
default
as
QueryOr
}
from
"../../datastore/query-or"
;
import
type
{
CollectionItem
}
from
"../../main"
;
export
default
class
Or
extends
ReducingPolicy
{
static
type_name
=
"or"
;
async
_getRestrictingQuery
(
context
:
Context
)
{
const
queries
=
await
Bluebird
.
map
(
this
.
policies
,
(
strategy
)
=>
strategy
.
getRestrictingQuery
(
context
)
);
if
(
queries
.
some
((
query
)
=>
query
instanceof
AllowAll
))
{
return
new
AllowAll
();
}
return
new
QueryOr
(...
queries
);
}
async
isItemSensitive
(
context
:
Context
)
{
return
Bluebird
.
map
(
this
.
policies
,
(
strategy
)
=>
strategy
.
isItemSensitive
(
context
)
).
reduce
((
a
,
b
)
=>
a
||
b
,
true
);
}
async
checkerFunction
(
context
:
Context
,
item_getter
:
()
=>
Promise
<
CollectionItem
>
)
{
const
results
=
await
this
.
checkAllPolicies
(
context
,
item_getter
);
const
positives
:
Exclude
<
PolicyDecision
,
null
>
[]
=
results
.
filter
(
(
result
)
=>
result
?
.
allowed
===
true
)
as
Exclude
<
PolicyDecision
,
null
>
[];
if
(
positives
.
length
===
0
)
{
return
Policy
.
deny
(
results
.
map
((
r
)
=>
`"
${
r
?
.
reason
}
"`
).
join
(
", "
));
}
return
Policy
.
allow
(
positives
[
0
].
reason
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Tue, Dec 24, 11:41 (1 d, 3 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
555035
Default Alt Text
or.ts (1 KB)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline
Log In to Comment