startCleanupTask starts a background task to clean up expired entries
()
| 28 | |
| 29 | // startCleanupTask starts a background task to clean up expired entries |
| 30 | func startCleanupTask() { |
| 31 | gopool.Go(func() { |
| 32 | for { |
| 33 | time.Sleep(time.Hour) |
| 34 | now := time.Now() |
| 35 | notifyLimitStore.Range(func(key, value interface{}) bool { |
| 36 | if limit, ok := value.(limitCount); ok { |
| 37 | if now.Sub(limit.Timestamp) >= getDuration() { |
| 38 | notifyLimitStore.Delete(key) |
| 39 | } |
| 40 | } |
| 41 | return true |
| 42 | }) |
| 43 | } |
| 44 | }) |
| 45 | } |
| 46 | |
| 47 | // CheckNotificationLimit checks if the user has exceeded their notification limit |
| 48 | // Returns true if the user can send notification, false if limit exceeded |
nothing calls this directly
no test coverage detected