[bugfix] more robust list timeline invalidation (#1995)

This commit is contained in:
kim 2023-07-18 09:43:17 +01:00 committed by GitHub
commit f4319740ab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 254 additions and 226 deletions

View file

@ -93,28 +93,21 @@ func (p *Processor) StatusesGet(
}
var (
items = make([]interface{}, 0, count)
nextMaxIDValue string
prevMinIDValue string
)
items = make([]interface{}, 0, count)
for i, s := range filtered {
// Set next + prev values before filtering and API
// converting, so caller can still page properly.
if i == count-1 {
nextMaxIDValue = s.ID
}
if i == 0 {
prevMinIDValue = s.ID
}
nextMaxIDValue = filtered[count-1].ID
prevMinIDValue = filtered[0].ID
)
for _, s := range filtered {
// Convert filtered statuses to API statuses.
item, err := p.tc.StatusToAPIStatus(ctx, s, requestingAccount)
if err != nil {
log.Debugf(ctx, "skipping status %s because it couldn't be converted to its api representation: %s", s.ID, err)
log.Errorf(ctx, "error convering to api status: %v", err)
continue
}
items = append(items, item)
}
@ -171,23 +164,20 @@ func (p *Processor) WebStatusesGet(ctx context.Context, targetAccountID string,
}
var (
items = make([]interface{}, 0, count)
nextMaxIDValue string
)
items = make([]interface{}, 0, count)
for i, s := range statuses {
// Set next value before API converting,
// so caller can still page properly.
if i == count-1 {
nextMaxIDValue = s.ID
}
nextMaxIDValue = statuses[count-1].ID
)
for _, s := range statuses {
// Convert fetched statuses to API statuses.
item, err := p.tc.StatusToAPIStatus(ctx, s, nil)
if err != nil {
log.Debugf(ctx, "skipping status %s because it couldn't be converted to its api representation: %s", s.ID, err)
log.Errorf(ctx, "error convering to api status: %v", err)
continue
}
items = append(items, item)
}