initial persistent history implementation

This commit is contained in:
Shivaram Lingamneni 2020-02-18 19:38:42 -05:00
parent 0d5a4fd584
commit 33dac4c0ba
34 changed files with 2229 additions and 595 deletions

View file

@ -8,6 +8,8 @@ import (
"strconv"
"strings"
"time"
"github.com/oragono/oragono/irc/history"
)
type zncCommandHandler func(client *Client, command string, params []string, rb *ResponseBuffer)
@ -89,10 +91,8 @@ func zncPlaybackHandler(client *Client, command string, params []string, rb *Res
// 3.3 When the client sends a subsequent redundant JOIN line for those
// channels; redundant JOIN is a complete no-op so we won't replay twice
config := client.server.Config()
if params[1] == "*" {
items, _ := client.history.Between(after, before, false, config.History.ChathistoryMax)
client.replayPrivmsgHistory(rb, items, true)
zncPlayPrivmsgs(client, rb, after, before)
} else {
targets = make(StringSet)
// TODO actually handle nickname targets
@ -116,3 +116,15 @@ func zncPlaybackHandler(client *Client, command string, params []string, rb *Res
}
}
}
func zncPlayPrivmsgs(client *Client, rb *ResponseBuffer, after, before time.Time) {
_, sequence, _ := client.server.GetHistorySequence(nil, client, "*")
if sequence == nil {
return
}
zncMax := client.server.Config().History.ZNCMax
items, _, err := sequence.Between(history.Selector{Time: after}, history.Selector{Time: before}, zncMax)
if err == nil {
client.replayPrivmsgHistory(rb, items, "", true)
}
}