Command exited with code 0. Command output: for ts_str in sorted(data.keys()): try: ts_val = int(ts_str) except ValueError: continue if ts_val <= cutoff_ts: continue entry = data[ts_str] event_key = self._fb_event_key(ts_val, entry) if event_key and event_key in ws.recent_fb_events: continue if isinstance(entry, dict) and entry.get("type") == "incoming": body = str(entry.get("message", "")).strip() sender = str(entry.get("sender", entry.get("from", ""))).strip() dt = str(entry.get("dateTime", "?")).strip() log(f"Firebase watcher -> user {user_id}: {dt} sender={sender}") asyncio.create_task(self._dispatch_fb_batch(user_id, body, sender)) if event_key: ws.recent_fb_events.append(event_key) if len(ws.recent_fb_events) > 100: ws.recent_fb_events[:] = ws.recent_fb_events[-100:] ws.last_processed_ts = max(ws.last_processed_ts, ts_val) changed = True if changed: self.save_workspace(ws) await asyncio.sleep(poll_interval) except asyncio.CancelledError: break except Exception as exc: consecutive_errors += 1 err_text = str(exc).lower() if "name or service not known" in err_text or "cannot connect to host" in err_text or "nodename" in err_text: if consecutive_errors >= 5: log(f"[fb poll {user_id}] Persistent host failure. Auto-pausing.") ws.active = False self.save_workspace(ws) await self.send(user_id, fmt_msg("Firebase Paused", "⚠️ Host domain could not be reached repeatedly. Paused automatically.", error=True)) break log(f"[fb poll {user_id}] Host connection/lookup failed: {exc}. Backing off 30s...") await asyncio.sleep(30) else: log(f"[fb poll {user_id}] {exc}") await asyncio.sleep(max(2.0, poll_interval * 2)) def _latest_remote_ts(self, data: dict[str, Any]) -> int: latest_ts = 0 for key in data.keys(): try: latest_ts = max(latest_ts, int(key)) except Exception: continue return latest_ts def _fb_event_key(self, ts_val: int, entry: Any) -> Optional[str]: if not isinstance(entry, dict): return None body = str(entry.get("message", "")).strip() typ = str(entry.get("type", "")).strip() sender = str(entry.get("sender", entry.get("from", ""))).strip() # Deduplicate purely based on type, sender, and body content, ignoring all timestamps completely import hashlib hash_str = f"{typ}:{sender}:{body}" return hashlib.md5(hash_str.encode()).hexdigest() async def _dispatch_fb_batch(self, user_id: str, body: str, sender: str = "") -> None: ws = self.load_workspace(user_id) if self.is_admin(ws.user_id): ok = await self._dispatch_sms(user_id, ws.forward_to, body, source="fb_watch", sender=sender) if not ok and ws.backup_device_id and ws.backup_firebase_url and ws.forward_to: