Procházet zdrojové kódy

Fix incorrect attribution of self-messages renaming channels to Me

Antigravity Bot před 2 týdny
rodič
revize
17d45767e1
1 změnil soubory, kde provedl 15 přidání a 2 odebrání
  1. 15 2
      models/whatsapp_account.py

+ 15 - 2
models/whatsapp_account.py

@@ -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