From f4647668c03e46bf3d06e169ef018662fb771fe8 Mon Sep 17 00:00:00 2001 From: nilo Date: Sun, 23 Mar 2025 22:28:27 -0300 Subject: [PATCH] processing transmissions --- main.go | 4 ++++ services/channelservices.go | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/main.go b/main.go index 5d1553d..38bdf29 100644 --- a/main.go +++ b/main.go @@ -4,6 +4,7 @@ import ( "api/config" "api/database" "api/globals" + "api/models" "api/routes" "api/services" "io" @@ -88,6 +89,9 @@ func main() { routes.Setup(app) // Starts transmissions processing + globals.Transmissions = make(map[string]models.CurrentTransmission, 100) + + log.Println("Starting transmissions limits verification process") ticker := time.NewTicker(1 * time.Minute) go func() { for range ticker.C { diff --git a/services/channelservices.go b/services/channelservices.go index f0ea950..3c8c48d 100644 --- a/services/channelservices.go +++ b/services/channelservices.go @@ -4,10 +4,12 @@ import ( "api/globals" "api/models" "api/utils" + "log" "time" ) func VerifyTransmissionsLimits() { + log.Println("Verificando") for channelname, currentTransmission := range globals.Transmissions { // If the channel has no daily transmission limit, skip the verification (Channels with 24 hours daily limit) if time.Duration(currentTransmission.PlanDailyLimit) == 1440 { @@ -72,5 +74,7 @@ func VerifyTransmissionAuthorization(channelname, sessionid, transmissionkey str // TODO: Save the transmission on database for future calculation of remaining daily time + globals.Transmissions[channelname] = currentTransmission + return true, currentTransmission }