21 lines
1.1 KiB
PHP
21 lines
1.1 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
use app\service\Settings;
|
|
use app\service\shared\SourceApiClient;
|
|
use app\service\group\GroupStore;
|
|
use app\service\group\KefuApplicationService;
|
|
require dirname(__DIR__) . '/vendor/autoload.php';
|
|
try {
|
|
(new think\App(dirname(__DIR__) . DIRECTORY_SEPARATOR))->initialize();
|
|
$options=getopt('', ['actor-id:']);
|
|
$actor=filter_var($options['actor-id']??null,FILTER_VALIDATE_INT,['options'=>['min_range'=>1]]);
|
|
if(!$actor||!in_array((string)$actor,array_map('trim',explode(',',Settings::get('IAM_GROUP_OWNER_IDS'))),true)){
|
|
throw new RuntimeException('请指定已配置的集团管理员 actor-id');
|
|
}
|
|
$source=new SourceApiClient();
|
|
$store=new GroupStore($source->sourceKey());
|
|
echo json_encode((new KefuApplicationService($store,$source))->sync(['client_id'=>'kefu'],(int)$actor),JSON_UNESCAPED_UNICODE|JSON_THROW_ON_ERROR)."\n";
|
|
}catch(Throwable $error){
|
|
fwrite(STDERR,$error instanceof \app\exception\ApiError||get_class($error)===RuntimeException::class?$error->getMessage()."\n":"客服目录同步失败,请检查只读接入配置。\n");exit(1);
|
|
}
|