|
|
@@ -187,8 +187,21 @@ class WhatsAppAccount(models.Model):
|
|
|
is_self_message = True
|
|
|
|
|
|
# Check phone ID match as fallback
|
|
|
- if not is_self_message and my_phone_id and sender_mobile == my_phone_id:
|
|
|
- is_self_message = True
|
|
|
+ # Check phone ID match as fallback ( Metadata OR stored phone_uid)
|
|
|
+ if not is_self_message:
|
|
|
+ sender_clean = sender_mobile.replace("@c.us", "")
|
|
|
+
|
|
|
+ # Compare vs Metadata ID
|
|
|
+ if my_phone_id:
|
|
|
+ my_clean = my_phone_id.replace("@c.us", "")
|
|
|
+ if sender_clean == my_clean:
|
|
|
+ is_self_message = True
|
|
|
+
|
|
|
+ # Compare vs Account Phone UID (if metadata failed/missing)
|
|
|
+ if not is_self_message and self.phone_uid:
|
|
|
+ account_clean = self.phone_uid.replace("@c.us", "")
|
|
|
+ if sender_clean == account_clean:
|
|
|
+ is_self_message = True
|
|
|
|
|
|
if is_self_message:
|
|
|
# Intentar obtener el destinatario real
|