fix(send): extract webhook_url from JSON ext_info for WECOM_BOT

This commit is contained in:
2026-07-15 13:35:44 +08:00
parent 168cd2de11
commit 0ad12c6df6
3 changed files with 41 additions and 4 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

View File

@@ -287,6 +287,19 @@ function resetDrawerForm() {
drawerForm.extInfo = '' drawerForm.extInfo = ''
} }
function parseBotExtInfo(extInfo: string | undefined): string {
if (!extInfo) return ''
try {
const parsed = JSON.parse(extInfo)
if (parsed && typeof parsed === 'object' && parsed.webhook_url) {
return parsed.webhook_url
}
} catch {
// fallback to legacy plain URL
}
return extInfo
}
function fillDrawerForm(row: any) { function fillDrawerForm(row: any) {
drawerForm.accountType = row.accountType ?? 1 drawerForm.accountType = row.accountType ?? 1
drawerForm.channelType = row.channelType ?? 'wecom' drawerForm.channelType = row.channelType ?? 'wecom'
@@ -295,7 +308,7 @@ function fillDrawerForm(row: any) {
drawerForm.accountName = row.accountName ?? '' drawerForm.accountName = row.accountName ?? ''
drawerForm.sessionArchiveEnabled = row.sessionArchiveEnabled ?? 0 drawerForm.sessionArchiveEnabled = row.sessionArchiveEnabled ?? 0
drawerForm.serverHost = row.serverHost ?? '' drawerForm.serverHost = row.serverHost ?? ''
drawerForm.extInfo = row.extInfo ?? '' drawerForm.extInfo = row.accountType === 6 ? parseBotExtInfo(row.extInfo) : (row.extInfo ?? '')
} }
function openCreateDialog() { function openCreateDialog() {
@@ -327,9 +340,17 @@ async function loadSubjects() {
} }
} }
function buildAccountPayload(form: typeof dialogForm) {
const payload: any = { ...form }
if (form.accountType === 6 && form.extInfo && form.extInfo.trim()) {
payload.extInfo = JSON.stringify({ webhook_url: form.extInfo.trim() })
}
return payload
}
async function handleSave() { async function handleSave() {
try { try {
await createChannelAccount(dialogForm) await createChannelAccount(buildAccountPayload(dialogForm))
ElMessage.success('创建成功') ElMessage.success('创建成功')
dialogVisible.value = false dialogVisible.value = false
await loadAccounts() await loadAccounts()
@@ -341,7 +362,7 @@ async function handleSave() {
async function handleDrawerSave() { async function handleDrawerSave() {
if (!currentAccount.value?.id) return if (!currentAccount.value?.id) return
try { try {
await updateChannelAccount(currentAccount.value.id, drawerForm) await updateChannelAccount(currentAccount.value.id, buildAccountPayload(drawerForm))
ElMessage.success('更新成功') ElMessage.success('更新成功')
drawerVisible.value = false drawerVisible.value = false
await loadAccounts() await loadAccounts()

View File

@@ -791,6 +791,22 @@ public class SendService {
} }
} }
@SuppressWarnings("unchecked")
private String extractWeComBotWebhookUrl(String extInfo) {
if (!StringUtils.hasText(extInfo)) {
return null;
}
try {
Map<String, Object> parsed = JsonUtils.fromJson(extInfo, Map.class);
if (parsed != null && parsed.get("webhook_url") != null) {
return String.valueOf(parsed.get("webhook_url"));
}
} catch (Exception e) {
// fallback: treat legacy ext_info as plain URL string
}
return extInfo;
}
private RetryConfig loadRetryConfig(String tenantCode, SendRequest request) { private RetryConfig loadRetryConfig(String tenantCode, SendRequest request) {
String channelTypeStr = extractChannelType(request.getChannelStrategy()); String channelTypeStr = extractChannelType(request.getChannelStrategy());
PolicyGroup policyGroup = loadPolicyGroup(tenantCode, channelTypeStr); PolicyGroup policyGroup = loadPolicyGroup(tenantCode, channelTypeStr);
@@ -989,7 +1005,7 @@ public class SendService {
} }
if (account.getAccountType() != null && account.getAccountType() == AccountType.WECOM_BOT.getCode() if (account.getAccountType() != null && account.getAccountType() == AccountType.WECOM_BOT.getCode()
&& StringUtils.hasText(account.getExtInfo())) { && StringUtils.hasText(account.getExtInfo())) {
extra.put("webhook_url", account.getExtInfo()); extra.put("webhook_url", extractWeComBotWebhookUrl(account.getExtInfo()));
} }
} }
extra.put("record_id", record.getId()); extra.put("record_id", record.getId());