3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-22 03:49:27 +01:00

fix znc.in/playback for individual DM targets

This is a regression introduced in 0d05ab4ff4249f; playback for an individual
DM target would play all DMs.
This commit is contained in:
Shivaram Lingamneni 2021-05-28 18:07:54 -04:00
parent 351eb8ad27
commit ac806e5c62
2 changed files with 14 additions and 6 deletions

View File

@ -747,7 +747,7 @@ func (client *Client) playReattachMessages(session *Session) {
} }
if !session.autoreplayMissedSince.IsZero() && !hasHistoryCaps { if !session.autoreplayMissedSince.IsZero() && !hasHistoryCaps {
rb := NewResponseBuffer(session) rb := NewResponseBuffer(session)
zncPlayPrivmsgs(client, rb, "", time.Now().UTC(), session.autoreplayMissedSince) zncPlayPrivmsgsFromAll(client, rb, time.Now().UTC(), session.autoreplayMissedSince)
rb.Send(true) rb.Send(true)
} }
session.autoreplayMissedSince = time.Time{} session.autoreplayMissedSince = time.Time{}

View File

@ -165,7 +165,7 @@ func zncPlaybackPlayHandler(client *Client, command string, params []string, rb
} }
if playPrivmsgs { if playPrivmsgs {
zncPlayPrivmsgs(client, rb, "", start, end) zncPlayPrivmsgsFromAll(client, rb, start, end)
} }
rb.session.zncPlaybackTimes = &zncPlaybackTimes{ rb.session.zncPlaybackTimes = &zncPlaybackTimes{
@ -183,16 +183,24 @@ func zncPlaybackPlayHandler(client *Client, command string, params []string, rb
} }
for _, cfNick := range nickTargets { for _, cfNick := range nickTargets {
zncPlayPrivmsgs(client, rb, cfNick, start, end) zncPlayPrivmsgsFrom(client, rb, cfNick, start, end)
rb.Flush(true) rb.Flush(true)
} }
} }
func zncPlayPrivmsgs(client *Client, rb *ResponseBuffer, target string, start, end time.Time) { func zncPlayPrivmsgsFrom(client *Client, rb *ResponseBuffer, target string, start, end time.Time) {
_, sequence, _ := client.server.GetHistorySequence(nil, client, target) _, sequence, err := client.server.GetHistorySequence(nil, client, target)
if sequence == nil { if sequence == nil || err != nil {
return return
} }
zncMax := client.server.Config().History.ZNCMax
items, err := sequence.Between(history.Selector{Time: start}, history.Selector{Time: end}, zncMax)
if err == nil && len(items) != 0 {
client.replayPrivmsgHistory(rb, items, target)
}
}
func zncPlayPrivmsgsFromAll(client *Client, rb *ResponseBuffer, start, end time.Time) {
zncMax := client.server.Config().History.ZNCMax zncMax := client.server.Config().History.ZNCMax
items, err := client.privmsgsBetween(start, end, maxDMTargetsForAutoplay, zncMax) items, err := client.privmsgsBetween(start, end, maxDMTargetsForAutoplay, zncMax)
if err == nil && len(items) != 0 { if err == nil && len(items) != 0 {