diff --git a/api/s5.go b/api/s5.go index 31b4686..5915326 100644 --- a/api/s5.go +++ b/api/s5.go @@ -34,5 +34,6 @@ func getRoutes(h *s5.HttpHandler, portal interfaces.Portal) map[string]jape.Hand "GET /s5/account/login": h.AccountLoginChallenge, "POST /s5/account/login": h.AccountLogin, "GET /s5/account": s5.AuthMiddleware(h.AccountInfo, portal), + "GET /s5/account/stats": s5.AuthMiddleware(h.AccountStats, portal), } } diff --git a/api/s5/http.go b/api/s5/http.go index e4341a6..5604d4f 100644 --- a/api/s5/http.go +++ b/api/s5/http.go @@ -532,6 +532,27 @@ func (h *HttpHandler) AccountInfo(jc jape.Context) { jc.Encode(info) } +func (h *HttpHandler) AccountStats(jc jape.Context) { + _, user := h.portal.Accounts().AccountExists(jc.Request.Context().Value(AuthUserIDKey).(uint64)) + + info := &AccountStatsResponse{ + AccountInfoResponse: AccountInfoResponse{ + Email: user.Email, + QuotaExceeded: false, + EmailConfirmed: false, + IsRestricted: false, + Tier: 0, + }, + Stats: AccountStats{ + Total: AccountStatsTotal{ + UsedStorage: 0, + }, + }, + } + + jc.Encode(info) +} + func setAuthCookie(jwt string, jc jape.Context) { authCookie := http.Cookie{ Name: "s5-auth-token", diff --git a/api/s5/messages.go b/api/s5/messages.go index fce0470..6ec2353 100644 --- a/api/s5/messages.go +++ b/api/s5/messages.go @@ -29,3 +29,16 @@ type AccountInfoResponse struct { IsRestricted bool `json:"isRestricted"` Tier uint8 `json:"tier"` } + +type AccountStatsResponse struct { + AccountInfoResponse + Stats AccountStats `json:"stats"` +} + +type AccountStats struct { + Total AccountStatsTotal `json:"total"` +} + +type AccountStatsTotal struct { + UsedStorage uint64 `json:"usedStorage"` +}