Page MenuHomeSealhub

not.ts
No OneTemporary

import Policy from "../../chip-types/policy";
import * as Query from "../../datastore/query";
import { 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(`it's not true that "${result.reason}"`);
}
return Policy.allow(`it's not true that "${result.reason}"`);
}
}

File Metadata

Mime Type
text/x-java
Expires
Tue, Jul 8, 08:37 (7 h, 35 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
810494
Default Alt Text
not.ts (1 KB)

Event Timeline