X-Git-Url: https://git.giacomolli.uk/onechat/blobdiff_plain/0da50dc187c8b4aa23ac1ddd0418c0da779389d9..3b2bf881d484ba1a33ff77a342564b8195a75c80:/whatsapp_inbox.go diff --git a/whatsapp_inbox.go b/whatsapp_inbox.go index 5121976..06f1c55 100644 --- a/whatsapp_inbox.go +++ b/whatsapp_inbox.go @@ -228,17 +228,17 @@ func (i *WhatsAppInbox) startCatchup() { // message, so that the library does not acknowledge it, and Run stops the // 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(link WhatsAppLink, event *events.Message) bool { - ctx, cancel := context.WithTimeout(context.Background(), i.lookupTime) +func (i *WhatsAppInbox) receive(ctx context.Context, link WhatsAppLink, event *events.Message) bool { + lookupCtx, cancel := context.WithTimeout(ctx, i.lookupTime) defer cancel() - chat, message, found := whatsappMessage(ctx, link.device, link.own, event) + chat, message, found := whatsappMessage(lookupCtx, link.device, link.own, event) if !found { return true } if event.Message.GetImageMessage() != nil { - ctx, cancel := context.WithTimeout(context.Background(), i.imageTime) + ctx, cancel := context.WithTimeout(ctx, i.imageTime) defer cancel() message.Text = i.imageText(ctx, link, event, message.Text)