mirror of
https://github.com/ergochat/ergo.git
synced 2025-12-20 02:00:11 -08:00
fix #1005
This commit is contained in:
parent
a46c0eed9f
commit
2779fe7c10
3 changed files with 41 additions and 20 deletions
|
|
@ -1793,33 +1793,35 @@ func nickHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Resp
|
|||
|
||||
// helper to store a batched PRIVMSG in the session object
|
||||
func absorbBatchedMessage(server *Server, client *Client, msg ircmsg.IrcMessage, batchTag string, histType history.ItemType, rb *ResponseBuffer) {
|
||||
var errorCode, errorMessage string
|
||||
defer func() {
|
||||
if errorCode != "" {
|
||||
if histType != history.Notice {
|
||||
rb.Add(nil, server.name, "FAIL", "BATCH", errorCode, errorMessage)
|
||||
}
|
||||
rb.session.EndMultilineBatch("")
|
||||
}
|
||||
}()
|
||||
|
||||
if batchTag != rb.session.batch.label {
|
||||
if histType != history.Notice {
|
||||
rb.Add(nil, server.name, "FAIL", "BATCH", "MULTILINE_INVALID", client.t("Incorrect batch tag sent"))
|
||||
}
|
||||
rb.session.EndMultilineBatch("")
|
||||
errorCode, errorMessage = "MULTILINE_INVALID", client.t("Incorrect batch tag sent")
|
||||
return
|
||||
} else if len(msg.Params) < 2 || msg.Params[1] == "" {
|
||||
if histType != history.Notice {
|
||||
rb.Add(nil, server.name, "FAIL", "BATCH", "MULTILINE_INVALID", client.t("Invalid multiline batch"))
|
||||
}
|
||||
rb.session.EndMultilineBatch("")
|
||||
} else if len(msg.Params) < 2 {
|
||||
errorCode, errorMessage = "MULTILINE_INVALID", client.t("Invalid multiline batch")
|
||||
return
|
||||
}
|
||||
rb.session.batch.command = msg.Command
|
||||
isConcat, _ := msg.GetTag(caps.MultilineConcatTag)
|
||||
if isConcat && len(msg.Params[1]) == 0 {
|
||||
errorCode, errorMessage = "MULTILINE_INVALID", client.t("Cannot send a blank line with the multiline concat tag")
|
||||
return
|
||||
}
|
||||
rb.session.batch.message.Append(msg.Params[1], isConcat)
|
||||
config := server.Config()
|
||||
if config.Limits.Multiline.MaxBytes < rb.session.batch.message.LenBytes() {
|
||||
if histType != history.Notice {
|
||||
rb.Add(nil, server.name, "FAIL", "BATCH", "MULTILINE_MAX_BYTES", strconv.Itoa(config.Limits.Multiline.MaxBytes))
|
||||
}
|
||||
rb.session.EndMultilineBatch("")
|
||||
errorCode, errorMessage = "MULTILINE_MAX_BYTES", strconv.Itoa(config.Limits.Multiline.MaxBytes)
|
||||
} else if config.Limits.Multiline.MaxLines != 0 && config.Limits.Multiline.MaxLines < rb.session.batch.message.LenLines() {
|
||||
if histType != history.Notice {
|
||||
rb.Add(nil, server.name, "FAIL", "BATCH", "MULTILINE_MAX_LINES", strconv.Itoa(config.Limits.Multiline.MaxLines))
|
||||
}
|
||||
rb.session.EndMultilineBatch("")
|
||||
errorCode, errorMessage = "MULTILINE_MAX_LINES", strconv.Itoa(config.Limits.Multiline.MaxLines)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue