forked from unimatrix/web
Project central game rights and reuse native support department adapters
This commit is contained in:
parent
5291938c1a
commit
04532cb7ec
1 changed files with 103 additions and 8 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import {nativeAgentIdentity} from './organisation-native-projection.mjs';
|
||||
import {syncGamePermissions} from './game-permission-sync.mjs';
|
||||
import {spawn} from 'node:child_process';
|
||||
import {existsSync} from 'node:fs';
|
||||
|
|
@ -7,7 +8,7 @@ const native='/home/dunerealms/apps/integrations/osticket/sync-agents.php';
|
|||
export async function syncNativeAgents(db){
|
||||
if(!existsSync(native))return;
|
||||
const {results}=await db.prepare('SELECT id,username,role FROM site_accounts').all();
|
||||
const accounts=[];for(const user of results){const access=await accessFor(db,user);accounts.push({...user,role:access.rank,ranks:access.ranks,permissions:access.nodes});}
|
||||
const accounts=[];for(const user of results){const access=await accessFor(db,user);accounts.push(nativeAgentIdentity(user,access));}
|
||||
await new Promise((resolve,reject)=>{const child=spawn('/usr/bin/php',[native],{stdio:['pipe','ignore','pipe']});let error='';child.stderr.on('data',chunk=>{error+=chunk.toString().slice(0,1000)});const timer=setTimeout(()=>{child.kill();reject(Error('Native staff sync timed out'));},20000);child.once('error',reject);child.once('exit',code=>{clearTimeout(timer);code===0?resolve():reject(Error('Native staff sync failed'));});child.stdin.on('error',()=>{});child.stdin.end(JSON.stringify(accounts));});
|
||||
await syncNativeSeals(db);
|
||||
await syncGamePermissions(db);
|
||||
|
|
|
|||
Loading…
Reference in a new issue

Staff