(ctx context.Context, source Source, notification Notification)
| 217 | } |
| 218 | |
| 219 | func (p *Processor) resync(ctx context.Context, source Source, notification Notification) (*Payload, error) { |
| 220 | ids, err := source.ListRecentMessageIDs(ctx, p.Config.ResyncMax) |
| 221 | if err != nil { |
| 222 | return nil, p.openRateLimitCircuitIfNeeded(err) |
| 223 | } |
| 224 | |
| 225 | batch, err := source.FetchMessages(ctx, ids) |
| 226 | if err != nil { |
| 227 | return nil, p.openRateLimitCircuitIfNeeded(err) |
| 228 | } |
| 229 | |
| 230 | p.advanceHistory(notification.HistoryID, notification.MessageID, "watch: failed to update state after resync: %v") |
| 231 | |
| 232 | if batch.Excluded > 0 && len(batch.Messages) == 0 { |
| 233 | if p.Config.Verbose { |
| 234 | p.logf("watch: skipping hook; all messages excluded") |
| 235 | } |
| 236 | |
| 237 | return nil, ErrNoNewMessages |
| 238 | } |
| 239 | |
| 240 | return &Payload{ |
| 241 | Source: "gmail", |
| 242 | Account: p.Config.Account, |
| 243 | HistoryID: notification.HistoryID, |
| 244 | Messages: batch.Messages, |
| 245 | }, nil |
| 246 | } |
| 247 | |
| 248 | func (p *Processor) advanceHistory(historyID, messageID, warning string) { |
| 249 | if err := p.Repository.AdvanceHistory(historyID, messageID, p.currentTime()); err != nil { |
no test coverage detected