Skip to content

Commit 0c5deba

Browse files
committed
Deduplicate bridge states more
1 parent dd3e118 commit 0c5deba

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

mautrix/util/bridge_state.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ class BridgeStateEvent(SerializableEnum):
6262
class BridgeState(SerializableAttrs):
6363
human_readable_errors: ClassVar[Dict[Optional[str], str]] = {}
6464
default_source: ClassVar[str] = "bridge"
65-
default_error_ttl: ClassVar[int] = 60
66-
default_ok_ttl: ClassVar[int] = 240
65+
default_error_ttl: ClassVar[int] = 3600
66+
default_ok_ttl: ClassVar[int] = 21600
6767

6868
state_event: BridgeStateEvent
6969
user_id: Optional[UserID] = None
@@ -106,8 +106,8 @@ def should_deduplicate(self, prev_state: Optional["BridgeState"]) -> bool:
106106
):
107107
# If there's no previous state or the state was different, send this one.
108108
return False
109-
# If there's more than ⅘ of the previous pong's time-to-live left, drop this one
110-
return prev_state.timestamp + (prev_state.ttl / 5) > self.timestamp
109+
# If the previous state is recent, drop this one
110+
return prev_state.timestamp + prev_state.ttl > self.timestamp
111111

112112
async def send(self, url: str, token: str, log: logging.Logger, log_sent: bool = True) -> bool:
113113
if not url:

0 commit comments

Comments
 (0)