mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-10 22:19:31 +01:00
commit
bc692a70a0
@ -704,7 +704,7 @@ func (channel *Channel) autoReplayHistory(client *Client, rb *ResponseBuffer, sk
|
||||
// autoreplay any messages as necessary
|
||||
config := channel.server.Config()
|
||||
var items []history.Item
|
||||
if rb.session.zncPlaybackTimes != nil && (rb.session.zncPlaybackTimes.targets == nil || rb.session.zncPlaybackTimes.targets[channel.NameCasefolded()]) {
|
||||
if rb.session.zncPlaybackTimes != nil && (rb.session.zncPlaybackTimes.targets == nil || rb.session.zncPlaybackTimes.targets.Has(channel.NameCasefolded())) {
|
||||
items, _ = channel.history.Between(rb.session.zncPlaybackTimes.after, rb.session.zncPlaybackTimes.before, false, config.History.ChathistoryMax)
|
||||
} else if !rb.session.HasHistoryCaps() {
|
||||
var replayLimit int
|
||||
|
13
irc/znc.go
13
irc/znc.go
@ -49,7 +49,7 @@ func zncWireTimeToTime(str string) (result time.Time) {
|
||||
type zncPlaybackTimes struct {
|
||||
after time.Time
|
||||
before time.Time
|
||||
targets map[string]bool // nil for "*" (everything), otherwise the channel names
|
||||
targets StringSet // nil for "*" (everything), otherwise the channel names
|
||||
}
|
||||
|
||||
// https://wiki.znc.in/Playback
|
||||
@ -71,12 +71,13 @@ func zncPlaybackHandler(client *Client, command string, params []string, rb *Res
|
||||
before = zncWireTimeToTime(params[3])
|
||||
}
|
||||
|
||||
var targets map[string]bool
|
||||
var targets StringSet
|
||||
|
||||
// three cases:
|
||||
// 1. the user's PMs get played back immediately upon receiving this
|
||||
// 2. if this is a new connection (from the server's POV), save the information
|
||||
// and use it to process subsequent joins
|
||||
// and use it to process subsequent joins. (This is the Textual behavior:
|
||||
// first send the playback PRIVMSG, then send the JOIN lines.)
|
||||
// 3. if this is a reattach (from the server's POV), immediately play back
|
||||
// history for channels that the client is already joined to. In this scenario,
|
||||
// there are three total attempts to play the history:
|
||||
@ -96,9 +97,9 @@ func zncPlaybackHandler(client *Client, command string, params []string, rb *Res
|
||||
for _, targetName := range strings.Split(targetString, ",") {
|
||||
if cfTarget, err := CasefoldChannel(targetName); err == nil {
|
||||
if targets == nil {
|
||||
targets = make(map[string]bool)
|
||||
targets = make(StringSet)
|
||||
}
|
||||
targets[cfTarget] = true
|
||||
targets.Add(cfTarget)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -110,7 +111,9 @@ func zncPlaybackHandler(client *Client, command string, params []string, rb *Res
|
||||
}
|
||||
|
||||
for _, channel := range client.Channels() {
|
||||
if targets == nil || targets.Has(channel.NameCasefolded()) {
|
||||
channel.autoReplayHistory(client, rb, "")
|
||||
rb.Flush(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user