1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00

chore: show warning message when data about to expire

This commit is contained in:
Ferdinand Mütsch
2023-01-18 01:27:07 +01:00
parent 934178412e
commit 8ccfcef8e3
7 changed files with 713 additions and 679 deletions

View File

@ -1,6 +1,10 @@
package view
import "github.com/muety/wakapi/models"
import (
conf "github.com/muety/wakapi/config"
"github.com/muety/wakapi/models"
"time"
)
type SummaryViewModel struct {
Messages
@ -13,6 +17,16 @@ type SummaryViewModel struct {
OSColors map[string]string
ApiKey string
RawQuery string
UserFirstData time.Time
}
func (s SummaryViewModel) UserDataExpiring() bool {
cfg := conf.Get()
return cfg.Subscriptions.Enabled &&
cfg.App.DataRetentionMonths > 0 &&
!s.UserFirstData.IsZero() &&
!s.User.HasActiveSubscription() &&
time.Now().AddDate(0, -cfg.App.DataRetentionMonths, 0).After(s.UserFirstData)
}
func (s *SummaryViewModel) WithSuccess(m string) *SummaryViewModel {