+// imageText stores the image of event before returning its marker and caption.
+// Failures keep the caption with a text marker. The daemon log identifies the
+// chat by a short hash, not its phone number.
+func (i *WhatsAppInbox) imageText(ctx context.Context, link WhatsAppLink, event *events.Message, caption string) string {
+ name, err := whatsappImage(ctx, link.client, i.images, event.Message.GetImageMessage())
+ if err != nil {
+ chat := event.Info.Chat.ToNonAD()
+ digest := sha256.Sum256([]byte(chat.String()))
+ redact := append(slices.Clone(link.own), chat.User)
+ i.logger.Error("image receive failed", "chat", fmt.Sprintf("%x", digest[:6]), "err", whatsappRedact(redact, err.Error()))
+
+ text := "(image not downloaded)"
+ if caption != "" {
+ text += "\n" + caption
+ }
+
+ return text
+ }
+
+ return imageText([]string{name}, caption)
+}
+