DreamStream-1 commited on
Commit
6ee0882
·
verified ·
1 Parent(s): d9c1631

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -10
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
- send_whatsjet_message(
 
2844
  from_number,
2845
- details,
2846
- media_type=media_type,
2847
- media_path=image_path,
2848
  filename=filename
2849
  )
2850
- return
 
 
 
 
 
 
 
 
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
- send_whatsjet_message(
 
3563
  from_number,
3564
- details,
3565
- media_type=media_type,
3566
- media_path=image_path,
3567
  filename=filename
3568
  )
3569
- return
 
 
 
 
 
 
 
 
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}")