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 {

View File

@ -420,7 +420,6 @@ const (
"Unread": 0
}
],
"UsedSpace": 7552905,
"Notices": ["Server will be down in 2min because of a NSA attack"],
"Code": 1000
}
@ -465,7 +464,7 @@ const (
"User": {
"ID": "userID1",
"Name": "user",
"UsedSpace": 12345,
"UsedSpace": 444,
"MaxSpace": 12345678
},
"Addresses": [
@ -478,6 +477,7 @@ const (
}
}
],
"UsedSpace": 12345,
"Notices": ["Server will be down in 2min because of a NSA attack"]
}
`