From cdb92757aa1ef2ac9a85ca02793f4611061ec1b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Schw=C3=B6rer?= Date: Sat, 12 Apr 2025 14:04:22 +0200 Subject: [PATCH] Fix quota_used returning old value when there were no messages today --- scnserver/models/user.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scnserver/models/user.go b/scnserver/models/user.go index a855b6c..a31fe46 100644 --- a/scnserver/models/user.go +++ b/scnserver/models/user.go @@ -11,7 +11,7 @@ type User struct { TimestampLastRead *SCNTime `db:"timestamp_lastread" json:"timestamp_lastread"` TimestampLastSent *SCNTime `db:"timestamp_lastsent" json:"timestamp_lastsent"` MessagesSent int `db:"messages_sent" json:"messages_sent"` - QuotaUsed int `db:"quota_used" json:"quota_used"` + QuotaUsed int `db:"quota_used" json:"-"` QuotaUsedDay *string `db:"quota_used_day" json:"-"` IsPro bool `db:"is_pro" json:"is_pro"` ProToken *string `db:"pro_token" json:"-"` @@ -22,6 +22,7 @@ type User struct { type UserExtra struct { QuotaRemaining int `json:"quota_remaining"` QuotaPerDay int `json:"quota_max"` + QuotaUsed int `json:"quota_used"` DefaultChannel string `json:"default_channel"` MaxBodySize int `json:"max_body_size"` MaxTitleLength int `json:"max_title_length"` @@ -58,6 +59,7 @@ func (u User) WithClients(clients []Client, ak string, sk string, rk string) Use func (u *User) PreMarshal() User { u.UserExtra = UserExtra{ QuotaPerDay: u.QuotaPerDay(), + QuotaUsed: u.QuotaUsedToday(), QuotaRemaining: u.QuotaRemainingToday(), DefaultChannel: u.DefaultChannel(), MaxBodySize: u.MaxContentLength(),