|
@@ -212,16 +212,24 @@ func (rb *ResponseBuffer) flushInternal(final bool, blocking bool) error {
|
212
|
212
|
}
|
213
|
213
|
|
214
|
214
|
useLabel := rb.session.capabilities.Has(caps.LabeledResponse) && rb.Label != ""
|
215
|
|
- // use a batch if we have a label, and we either currently have 0 or 2+ messages,
|
|
215
|
+ // use a batch if we have a label, and we either currently have 2+ messages,
|
216
|
216
|
// or we are doing a Flush() and we have to assume that there will be more messages
|
217
|
217
|
// in the future.
|
218
|
|
- useBatch := useLabel && (len(rb.messages) != 1 || !final)
|
|
218
|
+ startBatch := useLabel && (1 < len(rb.messages) || !final)
|
219
|
219
|
|
220
|
|
- // if label but no batch, add label to first message
|
221
|
|
- if useLabel && !useBatch && len(rb.messages) == 1 && rb.batchID == "" {
|
222
|
|
- rb.messages[0].SetTag(caps.LabelTagName, rb.Label)
|
223
|
|
- } else if useBatch {
|
|
220
|
+ if startBatch {
|
224
|
221
|
rb.sendBatchStart(blocking)
|
|
222
|
+ } else if useLabel && len(rb.messages) == 0 && rb.batchID == "" && final {
|
|
223
|
+ // ACK message
|
|
224
|
+ message := ircmsg.MakeMessage(nil, rb.session.client.server.name, "ACK")
|
|
225
|
+ message.SetTag(caps.LabelTagName, rb.Label)
|
|
226
|
+ if rb.session.capabilities.Has(caps.ServerTime) {
|
|
227
|
+ message.SetTag("time", time.Now().UTC().Format(IRCv3TimestampFormat))
|
|
228
|
+ }
|
|
229
|
+ rb.session.SendRawMessage(message, blocking)
|
|
230
|
+ } else if useLabel && len(rb.messages) == 1 && rb.batchID == "" && final {
|
|
231
|
+ // single labeled message
|
|
232
|
+ rb.messages[0].SetTag(caps.LabelTagName, rb.Label)
|
225
|
233
|
}
|
226
|
234
|
|
227
|
235
|
// send each message out
|