]> git.giacomolli.uk - onechat/blobdiff - whatsapp_groups.go
Keep time limits with their operations
[onechat] / whatsapp_groups.go
index ec5c892309e4aa282412730f5be35f95125acdb0..4d6c7e588be6501bb4c7e06745ba2fb6a427e892 100644 (file)
@@ -9,6 +9,10 @@ import (
 )
 
 const (
 )
 
 const (
+       // whatsappGroupsLookupTime is the longest time of a read of group
+       // names.
+       whatsappGroupsLookupTime = 10 * time.Second
+
        // whatsappGroupsRefresh is the shortest time between two reads of the
        // groups from WhatsApp for a group with no name.
        whatsappGroupsRefresh = time.Minute
        // whatsappGroupsRefresh is the shortest time between two reads of the
        // groups from WhatsApp for a group with no name.
        whatsappGroupsRefresh = time.Minute
@@ -77,7 +81,7 @@ func (g *WhatsAppGroups) read(ctx context.Context, link WhatsAppLink) bool {
                return false
        }
 
                return false
        }
 
-       ctx, cancel := context.WithTimeout(ctx, whatsappLookupTime)
+       ctx, cancel := context.WithTimeout(ctx, whatsappGroupsLookupTime)
        defer cancel()
 
        groups, err := link.client.GetJoinedGroups(ctx)
        defer cancel()
 
        groups, err := link.client.GetJoinedGroups(ctx)