3
0
mirror of https://github.com/ergochat/ergo.git synced 2025-01-05 09:32:32 +01:00

Merge pull request #809 from slingamn/graceperiod

fix handling of history grace periods
This commit is contained in:
Shivaram Lingamneni 2020-02-24 02:51:12 -08:00 committed by GitHub
commit 7f4c50b81d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -913,12 +913,14 @@ func (server *Server) GetHistorySequence(providedChannel *Channel, client *Clien
} }
if config.History.Restrictions.EnforceRegistrationDate { if config.History.Restrictions.EnforceRegistrationDate {
regCutoff := client.historyCutoff() regCutoff := client.historyCutoff()
regCutoff.Add(-time.Duration(config.History.Restrictions.GracePeriod)) // take the later of the two cutoffs
// take the earlier of the two cutoffs
if regCutoff.After(cutoff) { if regCutoff.After(cutoff) {
cutoff = regCutoff cutoff = regCutoff
} }
} }
if !cutoff.IsZero() {
cutoff = cutoff.Add(-time.Duration(config.History.Restrictions.GracePeriod))
}
if hist != nil { if hist != nil {
sequence = hist.MakeSequence(recipient, cutoff) sequence = hist.MakeSequence(recipient, cutoff)
} else if recipient != "" { } else if recipient != "" {