Преглед на файлове

fix #2043

Add human-readable description parameters to multiline fail messages,
since they are technically required by the standard-replies spec
(although the utility of showing them to users is dubious)
tags/v2.14.0-rc1
Shivaram Lingamneni преди 3 седмици
родител
ревизия
7318e48629
променени са 1 файла, в които са добавени 19 реда и са изтрити 8 реда
  1. 19
    8
      irc/handlers.go

+ 19
- 8
irc/handlers.go Целия файл

@@ -2204,27 +2204,30 @@ func validateSplitMessageLen(msgType history.ItemType, source, target string, me
2204 2204
 
2205 2205
 // helper to store a batched PRIVMSG in the session object
2206 2206
 func absorbBatchedMessage(server *Server, client *Client, msg ircmsg.Message, batchTag string, histType history.ItemType, rb *ResponseBuffer) {
2207
-	var errorCode, errorMessage string
2207
+	var failParams []string
2208 2208
 	defer func() {
2209
-		if errorCode != "" {
2209
+		if failParams != nil {
2210 2210
 			if histType != history.Notice {
2211
-				rb.Add(nil, server.name, "FAIL", "BATCH", errorCode, errorMessage)
2211
+				params := make([]string, 1+len(failParams))
2212
+				params[0] = "BATCH"
2213
+				copy(params[1:], failParams)
2214
+				rb.Add(nil, server.name, "FAIL", params...)
2212 2215
 			}
2213 2216
 			rb.session.EndMultilineBatch("")
2214 2217
 		}
2215 2218
 	}()
2216 2219
 
2217 2220
 	if batchTag != rb.session.batch.label {
2218
-		errorCode, errorMessage = "MULTILINE_INVALID", client.t("Incorrect batch tag sent")
2221
+		failParams = []string{"MULTILINE_INVALID", client.t("Incorrect batch tag sent")}
2219 2222
 		return
2220 2223
 	} else if len(msg.Params) < 2 {
2221
-		errorCode, errorMessage = "MULTILINE_INVALID", client.t("Invalid multiline batch")
2224
+		failParams = []string{"MULTILINE_INVALID", client.t("Invalid multiline batch")}
2222 2225
 		return
2223 2226
 	}
2224 2227
 	rb.session.batch.command = msg.Command
2225 2228
 	isConcat, _ := msg.GetTag(caps.MultilineConcatTag)
2226 2229
 	if isConcat && len(msg.Params[1]) == 0 {
2227
-		errorCode, errorMessage = "MULTILINE_INVALID", client.t("Cannot send a blank line with the multiline concat tag")
2230
+		failParams = []string{"MULTILINE_INVALID", client.t("Cannot send a blank line with the multiline concat tag")}
2228 2231
 		return
2229 2232
 	}
2230 2233
 	if !isConcat && len(rb.session.batch.message.Split) != 0 {
@@ -2234,9 +2237,17 @@ func absorbBatchedMessage(server *Server, client *Client, msg ircmsg.Message, ba
2234 2237
 	rb.session.batch.lenBytes += len(msg.Params[1])
2235 2238
 	config := server.Config()
2236 2239
 	if config.Limits.Multiline.MaxBytes < rb.session.batch.lenBytes {
2237
-		errorCode, errorMessage = "MULTILINE_MAX_BYTES", strconv.Itoa(config.Limits.Multiline.MaxBytes)
2240
+		failParams = []string{
2241
+			"MULTILINE_MAX_BYTES",
2242
+			strconv.Itoa(config.Limits.Multiline.MaxBytes),
2243
+			fmt.Sprintf(client.t("Multiline batch byte limit %d exceeded"), config.Limits.Multiline.MaxBytes),
2244
+		}
2238 2245
 	} else if config.Limits.Multiline.MaxLines != 0 && config.Limits.Multiline.MaxLines < rb.session.batch.message.LenLines() {
2239
-		errorCode, errorMessage = "MULTILINE_MAX_LINES", strconv.Itoa(config.Limits.Multiline.MaxLines)
2246
+		failParams = []string{
2247
+			"MULTILINE_MAX_LINES",
2248
+			strconv.Itoa(config.Limits.Multiline.MaxLines),
2249
+			fmt.Sprintf(client.t("Multiline batch line limit %d exceeded"), config.Limits.Multiline.MaxLines),
2250
+		}
2240 2251
 	}
2241 2252
 }
2242 2253
 

Loading…
Отказ
Запис