diff options
author | Olivier Wilkinson (reivilibre) <olivier@librepush.net> | 2019-07-16 13:31:25 +0100 |
---|---|---|
committer | Olivier Wilkinson (reivilibre) <olivier@librepush.net> | 2019-07-17 09:46:01 +0100 |
commit | 181c1a6072f50d3f4a5d213108d5ff814e70b41e (patch) | |
tree | daddf6e6730ef065d441cb3cd1173ffa0416ad64 /synapse/handlers | |
parent | Create room_stats rows for new rooms. #5624 (diff) | |
download | synapse-181c1a6072f50d3f4a5d213108d5ff814e70b41e.tar.xz |
Don't decrease left_members if the user is joining for the first time.
Fixes #5423 Signed-off-by: Olivier Wilkinson (reivilibre) <olivier@librepush.net>
Diffstat (limited to 'synapse/handlers')
-rw-r--r-- | synapse/handlers/stats.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/synapse/handlers/stats.py b/synapse/handlers/stats.py index 155232e5c3..e7495f8940 100644 --- a/synapse/handlers/stats.py +++ b/synapse/handlers/stats.py @@ -153,21 +153,28 @@ class StatsHandler(StateDeltasHandler): # given we're not testing for a specific result; might as well # just grab the prev_membership and membership strings and # compare them. - prev_event_content = {} + # We take None rather than leave as a previous membership + # in the absence of a previous event because we do not want to + # reduce the leave count when a new-to-the-room user joins. + prev_membership = None if prev_event_id is not None: prev_event = yield self.store.get_event( prev_event_id, allow_none=True ) if prev_event: prev_event_content = prev_event.content + prev_membership = prev_event_content.get( + "membership", Membership.LEAVE + ) membership = event_content.get("membership", Membership.LEAVE) - prev_membership = prev_event_content.get("membership", Membership.LEAVE) if prev_membership == membership: continue - if prev_membership == Membership.JOIN: + if prev_membership is None: + logger.debug("No previous membership for this user.") + elif prev_membership == Membership.JOIN: yield self.store.update_stats_delta( now, "room", room_id, "joined_members", -1 ) |