mirror of
https://github.com/ergochat/ergo.git
synced 2025-12-20 02:00:11 -08:00
initial persistent history implementation
This commit is contained in:
parent
0d5a4fd584
commit
33dac4c0ba
34 changed files with 2229 additions and 595 deletions
18
irc/znc.go
18
irc/znc.go
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue