mirror of
https://github.com/muety/wakapi.git
synced 2023-08-10 21:12:56 +03:00
chore: introduce heartbeat max age
This commit is contained in:
@ -34,6 +34,11 @@ func (h *Heartbeat) Valid() bool {
|
||||
return h.User != nil && h.UserID != "" && h.User.ID == h.UserID && h.Time != CustomTime(time.Time{})
|
||||
}
|
||||
|
||||
func (h *Heartbeat) Timely(maxAge time.Duration) bool {
|
||||
now := time.Now()
|
||||
return now.Sub(h.Time.T()) <= maxAge && h.Time.T().Before(now)
|
||||
}
|
||||
|
||||
func (h *Heartbeat) Augment(languageMappings map[string]string) {
|
||||
maxPrec := -1 // precision / mapping complexity -> more concrete ones shall take precedence
|
||||
for ending, value := range languageMappings {
|
||||
|
Reference in New Issue
Block a user