3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-22 11:59:40 +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 { 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 {