mirror of
https://github.com/HeyPuter/puter.git
synced 2026-09-15 09:45:54 +00:00
dev: add function-flag feature flag type
This commit is contained in:
@@ -42,10 +42,21 @@ class FeatureFlagService extends BaseService {
|
||||
if ( ! this.known_flags.has(permission) ) {
|
||||
this.known_flags.set(permission, true);
|
||||
}
|
||||
|
||||
|
||||
if ( this.known_flags[permission].$ === 'config-flag' ) {
|
||||
return this.known_flags[permission].value;
|
||||
}
|
||||
|
||||
const actor = options.actor ?? Context.get('actor');
|
||||
|
||||
if ( this.known_flags[permission].$ === 'function-flag' ) {
|
||||
return await this.known_flags[permission].fn({
|
||||
...options,
|
||||
actor
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
const svc_permission = this.services.get('permission');
|
||||
const reading = await svc_permission.scan(actor, `feature:${permission}`);
|
||||
const l = PermissionUtil.reading_to_options(reading);
|
||||
@@ -60,6 +71,10 @@ class FeatureFlagService extends BaseService {
|
||||
summary[key] = value.value;
|
||||
continue;
|
||||
}
|
||||
if ( value.$ === 'function-flag' ) {
|
||||
summary[key] = await value.fn({ actor });
|
||||
continue;
|
||||
}
|
||||
const svc_permission = this.services.get('permission');
|
||||
const reading = await svc_permission.scan(actor, `feature:${key}`);
|
||||
const l = PermissionUtil.reading_to_options(reading);
|
||||
|
||||
Reference in New Issue
Block a user