mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-27 04:49:47 +01:00
fix(rebase): post-merge compile fixes and upstream migration cleanup
Add Twilio SMS constants, extend westernization cleanup for upstream web search/device calling seeds, remove reintroduced Chinese-only model seeds, and teach the Liquibase H2 harness about new upstream SQL patterns.
This commit is contained in:
parent
a5db8f8b11
commit
0a05931a00
5 changed files with 85 additions and 16 deletions
|
|
@ -239,31 +239,31 @@ public interface Constant {
|
|||
}
|
||||
|
||||
/**
|
||||
* 系统短信
|
||||
* System SMS parameters
|
||||
*/
|
||||
enum SysMSMParam {
|
||||
/**
|
||||
* 阿里云授权keyID
|
||||
* Twilio account SID
|
||||
*/
|
||||
ALIYUN_SMS_ACCESS_KEY_ID("aliyun.sms.access_key_id"),
|
||||
TWILIO_SMS_ACCOUNT_SID("twilio.sms.account_sid"),
|
||||
/**
|
||||
* 阿里云授权密钥
|
||||
* Twilio auth token
|
||||
*/
|
||||
ALIYUN_SMS_ACCESS_KEY_SECRET("aliyun.sms.access_key_secret"),
|
||||
TWILIO_SMS_AUTH_TOKEN("twilio.sms.auth_token"),
|
||||
/**
|
||||
* 阿里云短信签名
|
||||
* Twilio phone number (from)
|
||||
*/
|
||||
ALIYUN_SMS_SIGN_NAME("aliyun.sms.sign_name"),
|
||||
TWILIO_SMS_PHONE_NUMBER("twilio.sms.phone_number"),
|
||||
/**
|
||||
* 阿里云短信模板
|
||||
* Twilio SMS template message
|
||||
*/
|
||||
ALIYUN_SMS_SMS_CODE_TEMPLATE_CODE("aliyun.sms.sms_code_template_code"),
|
||||
TWILIO_SMS_TEMPLATE_MESSAGE("twilio.sms.template_message"),
|
||||
/**
|
||||
* 单号码最大短信发送条数
|
||||
* Max SMS per phone number per day
|
||||
*/
|
||||
SERVER_SMS_MAX_SEND_COUNT("server.sms_max_send_count"),
|
||||
/**
|
||||
* 是否开启手机注册
|
||||
* Enable mobile registration
|
||||
*/
|
||||
SERVER_ENABLE_MOBILE_REGISTER("server.enable_mobile_register");
|
||||
|
||||
|
|
|
|||
|
|
@ -255,10 +255,10 @@ public class SysParamsServiceImpl extends BaseServiceImpl<SysParamsDao, SysParam
|
|||
// 检测短信关联参数是否为空
|
||||
ArrayList<String> list = new ArrayList<String>();
|
||||
list.add(Constant.SysMSMParam.SERVER_SMS_MAX_SEND_COUNT.getValue());
|
||||
list.add(Constant.SysMSMParam.ALIYUN_SMS_ACCESS_KEY_ID.getValue());
|
||||
list.add(Constant.SysMSMParam.ALIYUN_SMS_ACCESS_KEY_SECRET.getValue());
|
||||
list.add(Constant.SysMSMParam.ALIYUN_SMS_SIGN_NAME.getValue());
|
||||
list.add(Constant.SysMSMParam.ALIYUN_SMS_SMS_CODE_TEMPLATE_CODE.getValue());
|
||||
list.add(Constant.SysMSMParam.TWILIO_SMS_ACCOUNT_SID.getValue());
|
||||
list.add(Constant.SysMSMParam.TWILIO_SMS_AUTH_TOKEN.getValue());
|
||||
list.add(Constant.SysMSMParam.TWILIO_SMS_PHONE_NUMBER.getValue());
|
||||
list.add(Constant.SysMSMParam.TWILIO_SMS_TEMPLATE_MESSAGE.getValue());
|
||||
StringBuilder str = new StringBuilder();
|
||||
list.forEach(item -> {
|
||||
if (!StringUtils.isNoneBlank(item)) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
-- Westernize upstream web search and device calling plugin seeds added after the prior cleanup queue.
|
||||
UPDATE `ai_model_provider`
|
||||
SET `name` = 'Web Search',
|
||||
`fields` = '[{"key": "provider", "type": "string", "label": "Search provider: metaso / tavily", "default": "metaso", "editing": false, "selected": false}, {"key": "description", "type": "string", "label": "Tool description", "default": "Web search tool. Use when the user explicitly asks for current information from the internet.", "editing": false, "selected": false}, {"key": "max_results", "type": "string", "label": "Result count", "default": "5", "editing": false, "selected": false}, {"key": "api_key", "type": "string", "label": "API key", "default": "mk-XXXX", "editing": false, "selected": false}]'
|
||||
WHERE `id` = 'SYSTEM_PLUGIN_WEB_SEARCH';
|
||||
|
||||
UPDATE `ai_model_provider`
|
||||
SET `name` = 'Device Calling'
|
||||
WHERE `id` = 'SYSTEM_PLUGIN_CALL_DEVICE';
|
||||
|
||||
-- Remove upstream Chinese-only provider seeds reintroduced after the earlier westernization queue.
|
||||
DELETE FROM `ai_tts_voice` WHERE `tts_model_id` IN ('ASR_DoubaoStreamASRV2', 'TTS_HSDSTTS_V2');
|
||||
DELETE FROM `ai_model_config` WHERE `id` IN ('ASR_DoubaoStreamASRV2', 'TTS_HSDSTTS_V2');
|
||||
DELETE FROM `ai_model_provider` WHERE `id` IN ('SYSTEM_ASR_DoubaoStreamASRV2', 'SYSTEM_TTS_HSDSTTS_V2');
|
||||
|
|
@ -732,3 +732,10 @@ databaseChangeLog:
|
|||
- sqlFile:
|
||||
encoding: utf8
|
||||
path: classpath:db/changelog/202605251426.sql
|
||||
- changeSet:
|
||||
id: 202606131200
|
||||
author: codex
|
||||
changes:
|
||||
- sqlFile:
|
||||
encoding: utf8
|
||||
path: classpath:db/changelog/202606131200.sql
|
||||
|
|
|
|||
|
|
@ -142,6 +142,7 @@ class LiquibaseWesternizationIntegrationTest {
|
|||
normalized = normalized.replaceAll("(?im)^\\s*START\\s+TRANSACTION\\s*;?\\s*$", "");
|
||||
normalized = normalized.replaceAll("(?im)^\\s*COMMIT\\s*;?\\s*$", "");
|
||||
normalized = normalized.replaceAll("(?i)\\s+AFTER\\s+`[^`]+`", "");
|
||||
normalized = rewriteConditionalInsertBlocks(normalized);
|
||||
normalized = rewriteConditionalAddColumnBlocks(normalized);
|
||||
normalized = normalized.replace("TINYINT UNSIGNED", "TINYINT");
|
||||
normalized = normalized.replace("INT UNSIGNED", "INT");
|
||||
|
|
@ -150,6 +151,21 @@ class LiquibaseWesternizationIntegrationTest {
|
|||
normalized = normalized.replace("int unsigned", "int");
|
||||
normalized = normalized.replace("bigint unsigned", "bigint");
|
||||
normalized = rewriteCreateTableIndexNames(normalized);
|
||||
if ("202605251426.sql".equals(fileName)) {
|
||||
normalized = normalized.replaceAll(
|
||||
"(?s)UPDATE sys_params\\s*SET param_value = CAST\\(\\s*JSON_SET\\(.*?\\) AS CHAR\\s*\\)\\s*WHERE param_code = 'system-web\\.menu'\\s*AND NOT JSON_CONTAINS_PATH\\([^;]+;",
|
||||
Matcher.quoteReplacement("""
|
||||
UPDATE sys_params
|
||||
SET param_value = JSON_SET(
|
||||
CAST(param_value AS VARCHAR),
|
||||
'$.addressBook',
|
||||
'{"name":"feature.addressBook.name","enabled":false,"description":"feature.addressBook.description"}'
|
||||
)
|
||||
WHERE param_code = 'system-web.menu'
|
||||
AND JSON_EXTRACT(CAST(param_value AS VARCHAR), '$.addressBook') IS NULL;
|
||||
""")
|
||||
);
|
||||
}
|
||||
if ("202601141645.sql".equals(fileName)) {
|
||||
normalized = normalized.replaceAll(
|
||||
"(?s)UPDATE `ai_model_provider` ap\\s+JOIN \\(.*?\\) filtered ON ap\\.id = filtered\\.id\\s+SET ap\\.fields = filtered\\.new_fields;",
|
||||
|
|
@ -228,6 +244,38 @@ WHERE r.sort = 0;
|
|||
}
|
||||
}
|
||||
|
||||
private String rewriteConditionalInsertBlocks(String sql) {
|
||||
Pattern pattern = Pattern.compile(
|
||||
"(?s)SET @data_exists = \\(SELECT COUNT\\(\\*\\) FROM ([^)]+)\\);\\s*" +
|
||||
"SET @sql = IF\\(@data_exists = 0,\\s*'(INSERT INTO .*?)',\\s*'SELECT .*?' AS msg'\\);\\s*" +
|
||||
"PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;"
|
||||
);
|
||||
|
||||
Matcher matcher = pattern.matcher(sql);
|
||||
StringBuffer rewritten = new StringBuffer();
|
||||
while (matcher.find()) {
|
||||
String tableClause = matcher.group(1).trim();
|
||||
String insertStatement = matcher.group(2).replace("''", "'").replaceAll("\\s+", " ");
|
||||
Pattern valuesPattern = Pattern.compile(
|
||||
"(?is)^INSERT INTO\\s+(`[^`]+`\\s*\\([^)]+\\))\\s*VALUES\\s*(\\(.+\\))\\s*$"
|
||||
);
|
||||
Matcher valuesMatcher = valuesPattern.matcher(insertStatement.trim());
|
||||
String replacement;
|
||||
if (valuesMatcher.matches()) {
|
||||
String valuesBody = valuesMatcher.group(2);
|
||||
replacement =
|
||||
"INSERT INTO " + valuesMatcher.group(1) +
|
||||
" SELECT " + valuesBody.substring(1, valuesBody.length() - 1) +
|
||||
" WHERE NOT EXISTS (SELECT 1 FROM " + tableClause + ");";
|
||||
} else {
|
||||
replacement = insertStatement + ";";
|
||||
}
|
||||
matcher.appendReplacement(rewritten, Matcher.quoteReplacement(replacement));
|
||||
}
|
||||
matcher.appendTail(rewritten);
|
||||
return rewritten.toString();
|
||||
}
|
||||
|
||||
private String rewriteConditionalAddColumnBlocks(String sql) {
|
||||
Pattern pattern = Pattern.compile(
|
||||
"(?s)SET @col_exists = .*?;\\s*" +
|
||||
|
|
@ -403,7 +451,7 @@ WHERE r.sort = 0;
|
|||
|
||||
private void assertLatestChangeSetApplied(Connection connection) throws SQLException {
|
||||
String latestId = scalar(connection, "SELECT MAX(ID) FROM DATABASECHANGELOG");
|
||||
Assertions.assertEquals("202604021100", latestId, "latest downstream cleanup migration should be applied");
|
||||
Assertions.assertEquals("202606131200", latestId, "latest downstream cleanup migration should be applied");
|
||||
}
|
||||
|
||||
private void assertRequiredSeedCoverage(Connection connection) throws SQLException {
|
||||
|
|
|
|||
Loading…
Reference in a new issue