)
const (
- // whatsappLookupTime is the longest time of a read of names in the
- // session.
- whatsappLookupTime = 10 * time.Second
+ // whatsappContactLookupTimeout is the longest time of a read of names
+ // in the session.
+ whatsappContactLookupTimeout = 10 * time.Second
- // whatsappImageTime is the longest time of an image download.
- whatsappImageTime = 2 * time.Minute
+ // whatsappImageDownloadTimeout is the longest time of an image
+ // download.
+ whatsappImageDownloadTimeout = 2 * time.Minute
// whatsappSource is the source of the work events of the batches.
whatsappSource = "whatsapp"
- // whatsappCatchupLimit is the longest wait for the end of the catch-up
- // after a connection.
- whatsappCatchupLimit = time.Minute
+ // whatsappCatchupTimeout is the longest wait for the end of the
+ // catch-up after a connection.
+ whatsappCatchupTimeout = time.Minute
)
// newWhatsAppInbox returns the inbox of the batches in state, with clock for
//
// After each connection, the servers send the messages that came while the
// daemon was away, and then OfflineSyncCompleted. Until then, or until
-// whatsappCatchupLimit passes, the closed batches wait in the state file. At
+// whatsappCatchupTimeout passes, the closed batches wait in the state file. At
// the end of the catch-up, deliver closes all batches and logs them. It wakes
// the root once for its batches, so their catch-up gives one turn, not one for
// each chat. The batches of the state file at the start wait for the first
}
// startCatchup starts the catch-up of a new connection, which ends at
-// endCatchup or after whatsappCatchupLimit.
+// endCatchup or after whatsappCatchupTimeout.
func (i *WhatsAppInbox) startCatchup() {
i.mutex.Lock()
defer i.mutex.Unlock()
i.catchupTimer.Stop()
}
- i.catchupTimer = time.AfterFunc(whatsappCatchupLimit, func() {
+ i.catchupTimer = time.AfterFunc(whatsappCatchupTimeout, func() {
i.caughtUpBy(catchups)
})
}
// daemon. An image that cannot be downloaded or stored gets a text marker. A
// message that the batches do not take is handled with nothing to do.
func (i *WhatsAppInbox) receive(ctx context.Context, link WhatsAppLink, event *events.Message) bool {
- lookupCtx, cancel := context.WithTimeout(ctx, whatsappLookupTime)
+ lookupCtx, cancel := context.WithTimeout(ctx, whatsappContactLookupTimeout)
defer cancel()
chat, message, found := whatsappMessage(lookupCtx, link.device, link.own, event)
}
if event.Message.GetImageMessage() != nil {
- ctx, cancel := context.WithTimeout(ctx, whatsappImageTime)
+ ctx, cancel := context.WithTimeout(ctx, whatsappImageDownloadTimeout)
defer cancel()
message.Text = i.imageText(ctx, link, event, message.Text)