fix: reject CMPP daily limit synchronously

This commit is contained in:
hectorzhao
2026-07-22 17:09:44 +08:00
parent 66bc230d7e
commit 55019443c0
7 changed files with 112 additions and 20 deletions
+8 -3
View File
@@ -61,6 +61,7 @@ type submitResponseMessage struct {
type submitResponse struct {
Accepted bool `json:"accepted"`
Result uint32 `json:"result,omitempty"`
MessageID string `json:"messageId"`
Messages []submitResponseMessage `json:"messages,omitempty"`
}
@@ -316,11 +317,15 @@ func (s Server) handleSubmit(response *cmpp.Response, packet *cmpp.Packet, logge
if err != nil {
reason = err.Error()
}
responseResult := result.Result
if responseResult == 0 {
responseResult = 9
}
logger.Printf(
"cmpp inbound event=submit_rejected protocol=%s packet_type=%s account=%s remote=%s seq=%d phone=%s result=9 stage=business duration_ms=%d content_chars=%d content_hash=%s reason=%q",
clientProtocol, req.protocol, account, remote, req.sequenceID, phone, time.Since(startedAt).Milliseconds(), len([]rune(content)), contentHash, reason,
"cmpp inbound event=submit_rejected protocol=%s packet_type=%s account=%s remote=%s seq=%d phone=%s result=%d stage=business duration_ms=%d content_chars=%d content_hash=%s reason=%q",
clientProtocol, req.protocol, account, remote, req.sequenceID, phone, responseResult, time.Since(startedAt).Milliseconds(), len([]rune(content)), contentHash, reason,
)
setInboundSubmitResponse(response.Packer, 0, 9)
setInboundSubmitResponse(response.Packer, 0, responseResult)
return false, nil
}
gatewayMsgID := messageIDFrom(result.MessageID, req.sequenceID)