|
@@ -1793,33 +1793,35 @@ func nickHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Resp
|
1793
|
1793
|
|
1794
|
1794
|
// helper to store a batched PRIVMSG in the session object
|
1795
|
1795
|
func absorbBatchedMessage(server *Server, client *Client, msg ircmsg.IrcMessage, batchTag string, histType history.ItemType, rb *ResponseBuffer) {
|
1796
|
|
- if batchTag != rb.session.batch.label {
|
1797
|
|
- if histType != history.Notice {
|
1798
|
|
- rb.Add(nil, server.name, "FAIL", "BATCH", "MULTILINE_INVALID", client.t("Incorrect batch tag sent"))
|
|
1796
|
+ var errorCode, errorMessage string
|
|
1797
|
+ defer func() {
|
|
1798
|
+ if errorCode != "" {
|
|
1799
|
+ if histType != history.Notice {
|
|
1800
|
+ rb.Add(nil, server.name, "FAIL", "BATCH", errorCode, errorMessage)
|
|
1801
|
+ }
|
|
1802
|
+ rb.session.EndMultilineBatch("")
|
1799
|
1803
|
}
|
1800
|
|
- rb.session.EndMultilineBatch("")
|
|
1804
|
+ }()
|
|
1805
|
+
|
|
1806
|
+ if batchTag != rb.session.batch.label {
|
|
1807
|
+ errorCode, errorMessage = "MULTILINE_INVALID", client.t("Incorrect batch tag sent")
|
1801
|
1808
|
return
|
1802
|
|
- } else if len(msg.Params) < 2 || msg.Params[1] == "" {
|
1803
|
|
- if histType != history.Notice {
|
1804
|
|
- rb.Add(nil, server.name, "FAIL", "BATCH", "MULTILINE_INVALID", client.t("Invalid multiline batch"))
|
1805
|
|
- }
|
1806
|
|
- rb.session.EndMultilineBatch("")
|
|
1809
|
+ } else if len(msg.Params) < 2 {
|
|
1810
|
+ errorCode, errorMessage = "MULTILINE_INVALID", client.t("Invalid multiline batch")
|
1807
|
1811
|
return
|
1808
|
1812
|
}
|
1809
|
1813
|
rb.session.batch.command = msg.Command
|
1810
|
1814
|
isConcat, _ := msg.GetTag(caps.MultilineConcatTag)
|
|
1815
|
+ if isConcat && len(msg.Params[1]) == 0 {
|
|
1816
|
+ errorCode, errorMessage = "MULTILINE_INVALID", client.t("Cannot send a blank line with the multiline concat tag")
|
|
1817
|
+ return
|
|
1818
|
+ }
|
1811
|
1819
|
rb.session.batch.message.Append(msg.Params[1], isConcat)
|
1812
|
1820
|
config := server.Config()
|
1813
|
1821
|
if config.Limits.Multiline.MaxBytes < rb.session.batch.message.LenBytes() {
|
1814
|
|
- if histType != history.Notice {
|
1815
|
|
- rb.Add(nil, server.name, "FAIL", "BATCH", "MULTILINE_MAX_BYTES", strconv.Itoa(config.Limits.Multiline.MaxBytes))
|
1816
|
|
- }
|
1817
|
|
- rb.session.EndMultilineBatch("")
|
|
1822
|
+ errorCode, errorMessage = "MULTILINE_MAX_BYTES", strconv.Itoa(config.Limits.Multiline.MaxBytes)
|
1818
|
1823
|
} else if config.Limits.Multiline.MaxLines != 0 && config.Limits.Multiline.MaxLines < rb.session.batch.message.LenLines() {
|
1819
|
|
- if histType != history.Notice {
|
1820
|
|
- rb.Add(nil, server.name, "FAIL", "BATCH", "MULTILINE_MAX_LINES", strconv.Itoa(config.Limits.Multiline.MaxLines))
|
1821
|
|
- }
|
1822
|
|
- rb.session.EndMultilineBatch("")
|
|
1824
|
+ errorCode, errorMessage = "MULTILINE_MAX_LINES", strconv.Itoa(config.Limits.Multiline.MaxLines)
|
1823
|
1825
|
}
|
1824
|
1826
|
}
|
1825
|
1827
|
|