mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-26 05:49:25 +01:00
CHATHISTORY with no results SHOULD send an empty batch
This commit is contained in:
parent
98a7b45d96
commit
03378da81b
@ -944,7 +944,9 @@ func (channel *Channel) replayHistoryForResume(session *Session, after time.Time
|
||||
items, complete, _ = seq.Between(afterS, beforeS, channel.server.Config().History.ZNCMax)
|
||||
}
|
||||
rb := NewResponseBuffer(session)
|
||||
channel.replayHistoryItems(rb, items, false)
|
||||
if len(items) != 0 {
|
||||
channel.replayHistoryItems(rb, items, false)
|
||||
}
|
||||
if !complete && !session.resumeDetails.HistoryIncomplete {
|
||||
// warn here if we didn't warn already
|
||||
rb.Add(nil, histServMask, "NOTICE", channel.Name(), session.client.t("Some additional message history may have been lost"))
|
||||
@ -961,10 +963,7 @@ func stripMaskFromNick(nickMask string) (nick string) {
|
||||
}
|
||||
|
||||
func (channel *Channel) replayHistoryItems(rb *ResponseBuffer, items []history.Item, autoreplay bool) {
|
||||
if len(items) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
// send an empty batch if necessary, as per the CHATHISTORY spec
|
||||
chname := channel.Name()
|
||||
client := rb.target
|
||||
eventPlayback := rb.session.capabilities.Has(caps.EventPlayback)
|
||||
|
@ -832,9 +832,11 @@ func (session *Session) playResume() {
|
||||
if !timestamp.IsZero() && privmsgSeq != nil {
|
||||
after := history.Selector{Time: timestamp}
|
||||
items, complete, _ := privmsgSeq.Between(after, history.Selector{}, config.History.ZNCMax)
|
||||
rb := NewResponseBuffer(session)
|
||||
client.replayPrivmsgHistory(rb, items, "", complete)
|
||||
rb.Send(true)
|
||||
if len(items) != 0 {
|
||||
rb := NewResponseBuffer(session)
|
||||
client.replayPrivmsgHistory(rb, items, "", complete)
|
||||
rb.Send(true)
|
||||
}
|
||||
}
|
||||
|
||||
session.resumeDetails = nil
|
||||
@ -844,12 +846,10 @@ func (client *Client) replayPrivmsgHistory(rb *ResponseBuffer, items []history.I
|
||||
var batchID string
|
||||
details := client.Details()
|
||||
nick := details.nick
|
||||
if 0 < len(items) {
|
||||
if target == "" {
|
||||
target = nick
|
||||
}
|
||||
batchID = rb.StartNestedHistoryBatch(target)
|
||||
if target == "" {
|
||||
target = nick
|
||||
}
|
||||
batchID = rb.StartNestedHistoryBatch(target)
|
||||
|
||||
allowTags := rb.session.capabilities.Has(caps.MessageTags)
|
||||
for _, item := range items {
|
||||
|
@ -525,7 +525,7 @@ func chathistoryHandler(server *Server, client *Client, msg ircmsg.IrcMessage, r
|
||||
var err error
|
||||
defer func() {
|
||||
// successful responses are sent as a chathistory or history batch
|
||||
if err == nil && 0 < len(items) {
|
||||
if err == nil {
|
||||
if channel != nil {
|
||||
channel.replayHistoryItems(rb, items, false)
|
||||
} else {
|
||||
@ -958,7 +958,7 @@ func historyHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *R
|
||||
items, _, err = sequence.Between(start, end, limit)
|
||||
}
|
||||
|
||||
if err == nil {
|
||||
if err == nil && len(items) != 0 {
|
||||
if channel != nil {
|
||||
channel.replayHistoryItems(rb, items, false)
|
||||
} else {
|
||||
|
@ -124,7 +124,7 @@ func zncPlayPrivmsgs(client *Client, rb *ResponseBuffer, after, before time.Time
|
||||
}
|
||||
zncMax := client.server.Config().History.ZNCMax
|
||||
items, _, err := sequence.Between(history.Selector{Time: after}, history.Selector{Time: before}, zncMax)
|
||||
if err == nil {
|
||||
if err == nil && len(items) != 0 {
|
||||
client.replayPrivmsgHistory(rb, items, "", true)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user