Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F995875
not.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
not.ts
View Options
import
Policy
from
"../../chip-types/policy"
;
import
*
as
Query
from
"../../datastore/query"
;
import
type
{
CollectionItem
,
Context
}
from
"../../main"
;
export
default
class
Not
extends
Policy
{
static
type_name
=
"not"
;
strategy_to_negate
:
Policy
;
constructor
(
strategy
:
Policy
)
{
super
(
strategy
);
this
.
strategy_to_negate
=
Policy
.
fromDefinition
(
strategy
);
}
async
_getRestrictingQuery
(
context
:
Context
)
{
//assuming "not" can take only one access strategy as a parameter
const
query
=
await
this
.
strategy_to_negate
.
getRestrictingQuery
(
context
);
return
new
Query
.
Not
(
query
);
}
async
isItemSensitive
(
context
:
Context
)
{
return
this
.
strategy_to_negate
.
isItemSensitive
(
context
);
}
async
checkerFunction
(
context
:
Context
,
item_getter
:
()
=>
Promise
<
CollectionItem
>
)
{
const
result
=
await
this
.
strategy_to_negate
.
check
(
context
,
item_getter
);
if
(
result
===
null
)
{
return
null
;
}
if
(
result
.
allowed
)
{
return
Policy
.
deny
(
context
.
app
.
i18n
(
"policy_not_allow"
,
[
result
.
reason
])
);
}
return
Policy
.
allow
(
`it's not true that "
${
result
.
reason
}
"`
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Mon, Dec 23, 23:42 (1 d, 1 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
553699
Default Alt Text
not.ts (1 KB)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline
Log In to Comment