Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -2840,14 +2840,21 @@ async def send_product_image_with_caption(from_number: str, product: Dict[str, A
|
|
2840 |
# If it's a public URL, send as image+caption
|
2841 |
if image_path.startswith('http'):
|
2842 |
logger.info(f"[Product] Sending normalized cPanel public URL with caption: {image_path}")
|
2843 |
-
|
|
|
2844 |
from_number,
|
2845 |
-
|
2846 |
-
media_type=media_type,
|
2847 |
-
media_path=image_path,
|
2848 |
filename=filename
|
2849 |
)
|
2850 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2851 |
# Otherwise, treat as local file
|
2852 |
elif os.path.exists(image_path):
|
2853 |
logger.info(f"[Product] Sending local file with caption: {image_path}")
|
@@ -3559,14 +3566,21 @@ async def send_product_image_with_caption(from_number: str, product: Dict[str, A
|
|
3559 |
# If it's a public URL, send as image+caption
|
3560 |
if image_path.startswith('http'):
|
3561 |
logger.info(f"[Product] Sending normalized cPanel public URL with caption: {image_path}")
|
3562 |
-
|
|
|
3563 |
from_number,
|
3564 |
-
|
3565 |
-
media_type=media_type,
|
3566 |
-
media_path=image_path,
|
3567 |
filename=filename
|
3568 |
)
|
3569 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3570 |
# Otherwise, treat as local file
|
3571 |
elif os.path.exists(image_path):
|
3572 |
logger.info(f"[Product] Sending local file with caption: {image_path}")
|
|
|
2840 |
# If it's a public URL, send as image+caption
|
2841 |
if image_path.startswith('http'):
|
2842 |
logger.info(f"[Product] Sending normalized cPanel public URL with caption: {image_path}")
|
2843 |
+
# Send image first using the correct method for URLs
|
2844 |
+
image_success = send_whatsjet_media_image_only(
|
2845 |
from_number,
|
2846 |
+
image_path,
|
|
|
|
|
2847 |
filename=filename
|
2848 |
)
|
2849 |
+
if image_success:
|
2850 |
+
logger.info(f"[Product] Image sent successfully, now sending product details")
|
2851 |
+
# Send product details as text
|
2852 |
+
send_whatsjet_message(from_number, details)
|
2853 |
+
return
|
2854 |
+
else:
|
2855 |
+
logger.warning(f"[Product] Failed to send image, sending text only")
|
2856 |
+
send_whatsjet_message(from_number, details)
|
2857 |
+
return
|
2858 |
# Otherwise, treat as local file
|
2859 |
elif os.path.exists(image_path):
|
2860 |
logger.info(f"[Product] Sending local file with caption: {image_path}")
|
|
|
3566 |
# If it's a public URL, send as image+caption
|
3567 |
if image_path.startswith('http'):
|
3568 |
logger.info(f"[Product] Sending normalized cPanel public URL with caption: {image_path}")
|
3569 |
+
# Send image first using the correct method for URLs
|
3570 |
+
image_success = send_whatsjet_media_image_only(
|
3571 |
from_number,
|
3572 |
+
image_path,
|
|
|
|
|
3573 |
filename=filename
|
3574 |
)
|
3575 |
+
if image_success:
|
3576 |
+
logger.info(f"[Product] Image sent successfully, now sending product details")
|
3577 |
+
# Send product details as text
|
3578 |
+
send_whatsjet_message(from_number, details)
|
3579 |
+
return
|
3580 |
+
else:
|
3581 |
+
logger.warning(f"[Product] Failed to send image, sending text only")
|
3582 |
+
send_whatsjet_message(from_number, details)
|
3583 |
+
return
|
3584 |
# Otherwise, treat as local file
|
3585 |
elif os.path.exists(image_path):
|
3586 |
logger.info(f"[Product] Sending local file with caption: {image_path}")
|