fix(wecom): handle empty response by encrypting and returning a default response
This commit is contained in:
parent
8fb47305d6
commit
597648a96e
1 changed files with 5 additions and 0 deletions
|
|
@ -433,6 +433,11 @@ func (c *WeComAIBotChannel) handleMessageCallback(
|
||||||
// Process the message and get streaming response
|
// Process the message and get streaming response
|
||||||
response := c.processMessage(ctx, msg, timestamp, nonce)
|
response := c.processMessage(ctx, msg, timestamp, nonce)
|
||||||
|
|
||||||
|
// Check if response is empty (e.g. due to unsupported message type)
|
||||||
|
if response == "" {
|
||||||
|
response = c.encryptEmptyResponse(timestamp, nonce)
|
||||||
|
}
|
||||||
|
|
||||||
// Return encrypted JSON response
|
// Return encrypted JSON response
|
||||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue