Skip to content

Commit 6d7943f

Browse files
authored
fix: localize dingtalk and whatsapp setup copy (#1124)
* fix: localize dingtalk and whatsapp setup copy * fix: address channel connect review feedback * fix: align developer notify copy with tests * Revert "fix: align developer notify copy with tests" This reverts commit 942d6c1. * chore: align developer notify tests with existing copy
1 parent f35d8d9 commit 6d7943f

9 files changed

Lines changed: 397 additions & 60 deletions

File tree

apps/controller/openapi.json

Lines changed: 184 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4991,7 +4991,7 @@
49914991
}
49924992
}
49934993
},
4994-
"409": {
4994+
"422": {
49954995
"description": "Invalid credentials",
49964996
"content": {
49974997
"application/json": {
@@ -5000,10 +5000,192 @@
50005000
"properties": {
50015001
"message": {
50025002
"type": "string"
5003+
},
5004+
"code": {
5005+
"type": "string",
5006+
"enum": [
5007+
"already_connected",
5008+
"app_id_mismatch",
5009+
"invalid_credentials",
5010+
"network_error",
5011+
"proxy_error",
5012+
"sync_failed",
5013+
"timeout",
5014+
"upstream_http_error"
5015+
]
5016+
},
5017+
"requestId": {
5018+
"type": "string"
5019+
},
5020+
"retryable": {
5021+
"type": "boolean"
5022+
},
5023+
"phase": {
5024+
"type": "string",
5025+
"enum": [
5026+
"verify_credentials",
5027+
"verify_app",
5028+
"persist_config",
5029+
"sync_runtime"
5030+
]
50035031
}
50045032
},
50055033
"required": [
5006-
"message"
5034+
"message",
5035+
"code",
5036+
"requestId",
5037+
"retryable",
5038+
"phase"
5039+
]
5040+
}
5041+
}
5042+
}
5043+
},
5044+
"502": {
5045+
"description": "Upstream request failed",
5046+
"content": {
5047+
"application/json": {
5048+
"schema": {
5049+
"type": "object",
5050+
"properties": {
5051+
"message": {
5052+
"type": "string"
5053+
},
5054+
"code": {
5055+
"type": "string",
5056+
"enum": [
5057+
"already_connected",
5058+
"app_id_mismatch",
5059+
"invalid_credentials",
5060+
"network_error",
5061+
"proxy_error",
5062+
"sync_failed",
5063+
"timeout",
5064+
"upstream_http_error"
5065+
]
5066+
},
5067+
"requestId": {
5068+
"type": "string"
5069+
},
5070+
"retryable": {
5071+
"type": "boolean"
5072+
},
5073+
"phase": {
5074+
"type": "string",
5075+
"enum": [
5076+
"verify_credentials",
5077+
"verify_app",
5078+
"persist_config",
5079+
"sync_runtime"
5080+
]
5081+
}
5082+
},
5083+
"required": [
5084+
"message",
5085+
"code",
5086+
"requestId",
5087+
"retryable",
5088+
"phase"
5089+
]
5090+
}
5091+
}
5092+
}
5093+
},
5094+
"503": {
5095+
"description": "Local persistence or runtime sync failed",
5096+
"content": {
5097+
"application/json": {
5098+
"schema": {
5099+
"type": "object",
5100+
"properties": {
5101+
"message": {
5102+
"type": "string"
5103+
},
5104+
"code": {
5105+
"type": "string",
5106+
"enum": [
5107+
"already_connected",
5108+
"app_id_mismatch",
5109+
"invalid_credentials",
5110+
"network_error",
5111+
"proxy_error",
5112+
"sync_failed",
5113+
"timeout",
5114+
"upstream_http_error"
5115+
]
5116+
},
5117+
"requestId": {
5118+
"type": "string"
5119+
},
5120+
"retryable": {
5121+
"type": "boolean"
5122+
},
5123+
"phase": {
5124+
"type": "string",
5125+
"enum": [
5126+
"verify_credentials",
5127+
"verify_app",
5128+
"persist_config",
5129+
"sync_runtime"
5130+
]
5131+
}
5132+
},
5133+
"required": [
5134+
"message",
5135+
"code",
5136+
"requestId",
5137+
"retryable",
5138+
"phase"
5139+
]
5140+
}
5141+
}
5142+
}
5143+
},
5144+
"504": {
5145+
"description": "Upstream timeout",
5146+
"content": {
5147+
"application/json": {
5148+
"schema": {
5149+
"type": "object",
5150+
"properties": {
5151+
"message": {
5152+
"type": "string"
5153+
},
5154+
"code": {
5155+
"type": "string",
5156+
"enum": [
5157+
"already_connected",
5158+
"app_id_mismatch",
5159+
"invalid_credentials",
5160+
"network_error",
5161+
"proxy_error",
5162+
"sync_failed",
5163+
"timeout",
5164+
"upstream_http_error"
5165+
]
5166+
},
5167+
"requestId": {
5168+
"type": "string"
5169+
},
5170+
"retryable": {
5171+
"type": "boolean"
5172+
},
5173+
"phase": {
5174+
"type": "string",
5175+
"enum": [
5176+
"verify_credentials",
5177+
"verify_app",
5178+
"persist_config",
5179+
"sync_runtime"
5180+
]
5181+
}
5182+
},
5183+
"required": [
5184+
"message",
5185+
"code",
5186+
"requestId",
5187+
"retryable",
5188+
"phase"
50075189
]
50085190
}
50095191
}

apps/controller/src/routes/channel-routes.ts

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ function logChannelConnectFailure(
146146
container: ControllerContainer,
147147
input: {
148148
requestId: string;
149-
channel: "discord" | "telegram";
149+
channel: "discord" | "telegram" | "dingtalk";
150150
locale: ControllerLocale;
151151
error: unknown;
152152
},
@@ -538,10 +538,30 @@ export function registerChannelRoutes(
538538
content: { "application/json": { schema: channelResponseSchema } },
539539
description: "Connected dingtalk channel",
540540
},
541-
409: {
542-
content: { "application/json": { schema: errorSchema } },
541+
422: {
542+
content: {
543+
"application/json": { schema: channelConnectErrorSchema },
544+
},
543545
description: "Invalid credentials",
544546
},
547+
502: {
548+
content: {
549+
"application/json": { schema: channelConnectErrorSchema },
550+
},
551+
description: "Upstream request failed",
552+
},
553+
503: {
554+
content: {
555+
"application/json": { schema: channelConnectErrorSchema },
556+
},
557+
description: "Local persistence or runtime sync failed",
558+
},
559+
504: {
560+
content: {
561+
"application/json": { schema: channelConnectErrorSchema },
562+
},
563+
description: "Upstream timeout",
564+
},
545565
},
546566
}),
547567
async (c) => {
@@ -551,19 +571,15 @@ export function registerChannelRoutes(
551571
200,
552572
);
553573
} catch (error) {
554-
logger.error(
555-
{ error: error instanceof Error ? error.message : String(error) },
556-
"channel_connect_error_dingtalk",
557-
);
558-
return c.json(
559-
{
560-
message:
561-
error instanceof Error
562-
? error.message
563-
: "DingTalk connect failed",
564-
},
565-
409,
566-
);
574+
const requestId = c.get("requestId");
575+
const locale = await getControllerLocale(container);
576+
const response = logChannelConnectFailure(container, {
577+
requestId,
578+
channel: "dingtalk",
579+
locale,
580+
error,
581+
});
582+
return c.json(response.body, response.status);
567583
}
568584
},
569585
);

0 commit comments

Comments
 (0)