3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-11 06:29:29 +01:00

Merge pull request #761 from slingamn/issue760.1

fix #760
This commit is contained in:
Shivaram Lingamneni 2020-01-29 13:09:22 -08:00 committed by GitHub
commit bc692a70a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 8 deletions

View File

@ -704,7 +704,7 @@ func (channel *Channel) autoReplayHistory(client *Client, rb *ResponseBuffer, sk
// autoreplay any messages as necessary // autoreplay any messages as necessary
config := channel.server.Config() config := channel.server.Config()
var items []history.Item 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) items, _ = channel.history.Between(rb.session.zncPlaybackTimes.after, rb.session.zncPlaybackTimes.before, false, config.History.ChathistoryMax)
} else if !rb.session.HasHistoryCaps() { } else if !rb.session.HasHistoryCaps() {
var replayLimit int var replayLimit int

View File

@ -49,7 +49,7 @@ func zncWireTimeToTime(str string) (result time.Time) {
type zncPlaybackTimes struct { type zncPlaybackTimes struct {
after time.Time after time.Time
before 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 // https://wiki.znc.in/Playback
@ -71,12 +71,13 @@ func zncPlaybackHandler(client *Client, command string, params []string, rb *Res
before = zncWireTimeToTime(params[3]) before = zncWireTimeToTime(params[3])
} }
var targets map[string]bool var targets StringSet
// three cases: // three cases:
// 1. the user's PMs get played back immediately upon receiving this // 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 // 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 // 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, // history for channels that the client is already joined to. In this scenario,
// there are three total attempts to play the history: // 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, ",") { for _, targetName := range strings.Split(targetString, ",") {
if cfTarget, err := CasefoldChannel(targetName); err == nil { if cfTarget, err := CasefoldChannel(targetName); err == nil {
if targets == 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() { for _, channel := range client.Channels() {
if targets == nil || targets.Has(channel.NameCasefolded()) {
channel.autoReplayHistory(client, rb, "") channel.autoReplayHistory(client, rb, "")
rb.Flush(true) rb.Flush(true)
} }
} }
}