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