mirror of
https://github.com/muety/wakapi.git
synced 2023-08-10 21:12:56 +03:00
41 lines
906 B
Go
41 lines
906 B
Go
package view
|
|
|
|
import (
|
|
conf "github.com/muety/wakapi/config"
|
|
"github.com/muety/wakapi/models"
|
|
"time"
|
|
)
|
|
|
|
type SummaryViewModel struct {
|
|
Messages
|
|
*models.Summary
|
|
*models.SummaryParams
|
|
User *models.User
|
|
AvatarURL string
|
|
EditorColors map[string]string
|
|
LanguageColors map[string]string
|
|
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 {
|
|
s.SetSuccess(m)
|
|
return s
|
|
}
|
|
|
|
func (s *SummaryViewModel) WithError(m string) *SummaryViewModel {
|
|
s.SetError(m)
|
|
return s
|
|
}
|