mirror of
https://github.com/ProtonMail/go-proton-api.git
synced 2025-12-23 23:57:50 -05:00
feat(GODT-2948): Add used space per product to user info
This commit is contained in:
committed by
LBeernaertProton
parent
331ad8e6d5
commit
f1adb1492e
@@ -17,7 +17,28 @@ import (
|
|||||||
|
|
||||||
func (b *Backend) GetUser(userID string) (proton.User, error) {
|
func (b *Backend) GetUser(userID string) (proton.User, error) {
|
||||||
return withAcc(b, userID, func(acc *account) (proton.User, error) {
|
return withAcc(b, userID, func(acc *account) (proton.User, error) {
|
||||||
return acc.toUser(), nil
|
return withMessages(b, func(m map[string]*message) (proton.User, error) {
|
||||||
|
return withAtts(b, func(attachments map[string]*attachment) (proton.User, error) {
|
||||||
|
user := acc.toUser()
|
||||||
|
|
||||||
|
var messageBytes uint64
|
||||||
|
for _, v := range m {
|
||||||
|
if _, ok := acc.addresses[v.addrID]; ok {
|
||||||
|
messageBytes += uint64(len(v.armBody))
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, a := range v.attIDs {
|
||||||
|
if attach, ok := attachments[a]; ok {
|
||||||
|
messageBytes += uint64(len(b.attData[attach.attDataID]))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
user.ProductUsedSpace.Mail = messageBytes
|
||||||
|
|
||||||
|
return user, nil
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,12 +7,14 @@ type User struct {
|
|||||||
Email string
|
Email string
|
||||||
Keys Keys
|
Keys Keys
|
||||||
|
|
||||||
UsedSpace int
|
UsedSpace uint64
|
||||||
MaxSpace int
|
MaxSpace uint64
|
||||||
MaxUpload int
|
MaxUpload uint64
|
||||||
|
|
||||||
Credit int
|
Credit int
|
||||||
Currency string
|
Currency string
|
||||||
|
|
||||||
|
ProductUsedSpace ProductUsedSpace
|
||||||
}
|
}
|
||||||
|
|
||||||
type DeleteUserReq struct {
|
type DeleteUserReq struct {
|
||||||
@@ -20,3 +22,11 @@ type DeleteUserReq struct {
|
|||||||
Feedback string
|
Feedback string
|
||||||
Email string
|
Email string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ProductUsedSpace struct {
|
||||||
|
Calendar uint64
|
||||||
|
Contact uint64
|
||||||
|
Drive uint64
|
||||||
|
Mail uint64
|
||||||
|
Pass uint64
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user