GODT-1351: Fix used size update from mail operations

This commit is contained in:
Jakub
2021-11-05 07:38:09 +01:00
parent 2899e7bb15
commit 2e52b8db87
2 changed files with 20 additions and 2 deletions

View File

@ -45,6 +45,9 @@ type Event struct {
Addresses []*EventAddress
// Messages to show to the user.
Notices []string
// Update of used user space
UsedSpace *int64
}
// EventAction is the action that created a change.
@ -184,6 +187,21 @@ func (c *client) getEvent(ctx context.Context, eventID string, numberOfMergedEve
return nil, err
}
// API notifies about used space two ways:
// - by `event.User.UsedSpace`
// - by `event.UsedSpace`
//
// Because event merging is implemented for User object we copy the
// value from event.UsedSpace to event.User.UsedSpace and continue with
// user.
if event.UsedSpace != nil {
if event.User == nil {
event.User = &User{UsedSpace: event.UsedSpace}
} else {
event.User.UsedSpace = event.UsedSpace
}
}
if event.More && numberOfMergedEvents < maxNumberOfMergedEvents {
nextEvent, err := c.getEvent(ctx, event.EventID, numberOfMergedEvents+1)
if err != nil {