async def on_edu(self, edu_type: str, origin: str, content: dict): if not self.config.use_presence and edu_type == "m.presence": return # Check if we have a handler on this instance handler = self.edu_handlers.get(edu_type) if handler: with start_active_span_from_edu(content, "handle_edu"): try: await handler(origin, content) except SynapseError as e: logger.info("Failed to handle edu %r: %r", edu_type, e) except Exception: logger.exception("Failed to handle edu %r", edu_type) return # Check if we can route it somewhere else that isn't us route_to = self._edu_type_to_instance.get(edu_type, "master") if route_to != self._instance_name: try: await self._send_edu( instance_name=route_to, edu_type=edu_type, origin=origin, content=content, ) except SynapseError as e: logger.info("Failed to handle edu %r: %r", edu_type, e) except Exception: logger.exception("Failed to handle edu %r", edu_type) return # Oh well, let's just log and move on. logger.warning("No handler registered for EDU type %s", edu_type)
async def on_edu(self, edu_type, origin, content): handler = self.edu_handlers.get(edu_type) if not handler: logger.warning("No handler registered for EDU type %s", edu_type) with start_active_span_from_edu(content, "handle_edu"): try: await handler(origin, content) except SynapseError as e: logger.info("Failed to handle edu %r: %r", edu_type, e) except Exception: logger.exception("Failed to handle edu %r", edu_type)
async def on_edu(self, edu_type: str, origin: str, content: dict): if not self.config.use_presence and edu_type == EduTypes.Presence: return # If the incoming room key requests from a particular origin are over # the limit, drop them. if ( edu_type == EduTypes.RoomKeyRequest and not self._room_key_request_rate_limiter.can_do_action(origin) ): return # Check if we have a handler on this instance handler = self.edu_handlers.get(edu_type) if handler: with start_active_span_from_edu(content, "handle_edu"): try: await handler(origin, content) except SynapseError as e: logger.info("Failed to handle edu %r: %r", edu_type, e) except Exception: logger.exception("Failed to handle edu %r", edu_type) return # Check if we can route it somewhere else that isn't us instances = self._edu_type_to_instance.get(edu_type, ["master"]) if self._instance_name not in instances: # Pick an instance randomly so that we don't overload one. route_to = random.choice(instances) try: await self._send_edu( instance_name=route_to, edu_type=edu_type, origin=origin, content=content, ) except SynapseError as e: logger.info("Failed to handle edu %r: %r", edu_type, e) except Exception: logger.exception("Failed to handle edu %r", edu_type) return # Oh well, let's just log and move on. logger.warning("No handler registered for EDU type %s", edu_type)