responsebuffer: Handle sending early properly

This commit is contained in:
Daniel Oaks 2018-02-04 21:34:44 +10:00
parent 3680a3fe9a
commit 470109461b
1 changed files with 8 additions and 0 deletions

View File

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