Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F995390
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.js"
;
import
type
Context
from
"../../context.js"
;
import
{
AllowAll
}
from
"../../datastore/allow-all.js"
;
import
{
default
as
QueryOr
}
from
"../../datastore/query-or.js"
;
import
type
{
CollectionItem
}
from
"../../main.js"
;
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
Mon, Dec 23, 02:47 (11 h, 15 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
556014
Default Alt Text
or.ts (1 KB)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline
Log In to Comment