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

Merge pull request #1667 from slingamn/playback.2

fix znc.in/playback for individual DM targets
This commit is contained in:
Shivaram Lingamneni 2021-05-30 02:37:46 -04:00 committed by GitHub
commit c24254fe45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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 {
rb := NewResponseBuffer(session)
zncPlayPrivmsgs(client, rb, "", time.Now().UTC(), session.autoreplayMissedSince)
zncPlayPrivmsgsFromAll(client, rb, time.Now().UTC(), session.autoreplayMissedSince)
rb.Send(true)
}
session.autoreplayMissedSince = time.Time{}

View File

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