Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F21590369
or.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
Unknown
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
application/javascript
Expires
Mon, Nov 9, 14:14 (1 h, 6 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1182323
Default Alt Text
or.ts (1 KB)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline