app

Local-first trade for farms and co-ops
git clone https://radroots.dev/git/app.git
Log | Files | Refs | README | LICENSE

operation-flags.ts (704B)


      1 import { readRelayPolicy, type RelayPolicy } from './relays.ts';
      2 
      3 // Static availability is read only from original admitted policy. This boolean
      4 // is not an owner, signer, route, lease or permission to replay retained work.
      5 export function operationEnabled(
      6   policy: RelayPolicy | undefined,
      7   operation: unknown
      8 ): boolean {
      9   if (!policy) return false;
     10   try {
     11     const manifest = readRelayPolicy(policy);
     12     if (operation === 'posting') return manifest.postingEnabled;
     13     if (operation === 'messaging') return manifest.messagingEnabled;
     14     if (operation === 'new_listing')
     15       return manifest.postingEnabled && manifest.messagingEnabled;
     16     return false;
     17   } catch {
     18     return false;
     19   }
     20 }