代码提交

This commit is contained in:
wong
2026-01-06 10:58:29 +08:00
parent efcbb06eb2
commit ea2dd8cab2
23 changed files with 1848 additions and 722 deletions

View File

@@ -1896,11 +1896,35 @@ class WorkbenchController extends Controller
throw new \Exception('消息间最小间隔不能大于最大间隔');
}
$contentGroupsExisting = $originalConfig ? $this->decodeJsonArray($originalConfig->contentLibraries ?? []) : [];
$contentGroupsParam = $this->getParamValue($param, 'contentGroups', null);
$contentGroups = $contentGroupsParam !== null
? $this->extractIdList($contentGroupsParam, '内容库参数格式错误')
: $contentGroupsExisting;
// 群公告groupPushSubType = 2contentGroups 可以为空,不需要验证
if ($targetType === 1 && $groupPushSubType === 2) {
// 群公告可以不传内容库,允许为空,不进行任何验证
$contentGroupsParam = $this->getParamValue($param, 'contentGroups', null);
if ($contentGroupsParam !== null) {
// 如果传入了参数,尝试解析,但不验证格式和是否为空
try {
$contentGroups = $this->extractIdList($contentGroupsParam, '内容库参数格式错误');
} catch (\Exception $e) {
// 群公告时忽略格式错误,使用空数组
$contentGroups = [];
}
} else {
// 如果没有传入参数,使用现有配置或空数组
$contentGroupsExisting = $originalConfig ? $this->decodeJsonArray($originalConfig->contentLibraries ?? []) : [];
$contentGroups = $contentGroupsExisting;
}
} else {
// 其他情况,正常处理并验证
$contentGroupsExisting = $originalConfig ? $this->decodeJsonArray($originalConfig->contentLibraries ?? []) : [];
$contentGroupsParam = $this->getParamValue($param, 'contentGroups', null);
$contentGroups = $contentGroupsParam !== null
? $this->extractIdList($contentGroupsParam, '内容库参数格式错误')
: $contentGroupsExisting;
// 其他情况,内容库为必填
if (empty($contentGroups)) {
throw new \Exception('请至少选择一个内容库');
}
}
$data['contentLibraries'] = json_encode($contentGroups, JSON_UNESCAPED_UNICODE);
$postPushTagsExisting = $originalConfig ? $this->decodeJsonArray($originalConfig->postPushTags ?? []) : [];