3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-25 21:39:25 +01:00

responsebuffer: Handle sending early properly

This commit is contained in:
Daniel Oaks 2018-02-04 21:34:44 +10:00
parent 3680a3fe9a
commit 470109461b

View File

@ -75,6 +75,11 @@ func (rb *ResponseBuffer) AddSplitMessageFromClient(msgid string, from *Client,
// Send sends the message to our target client.
func (rb *ResponseBuffer) Send() error {
// fall out if no messages to send
if len(rb.messages) == 0 {
return
}
// make batch and all if required
var batch *Batch
useLabel := rb.target.capabilities.Has(caps.LabeledResponse) && rb.Label != ""
@ -116,5 +121,8 @@ func (rb *ResponseBuffer) Send() error {
batch.End(rb.target)
}
// clear out any existing messages
rb.messages = []ircmsg.IrcMessage{}
return nil
}