Merge branch 'release-v1.22.0' into develop

This commit is contained in:
Erik Johnston 2020-10-26 15:02:55 +00:00
commit ff7f0e8a14
4 changed files with 11 additions and 7 deletions

1
changelog.d/8654.bugfix Normal file
View File

@ -0,0 +1 @@
Fix `user_daily_visits` to not have duplicate rows for UA. Broke in v1.22.0rc1.

1
changelog.d/8656.bugfix Normal file
View File

@ -0,0 +1 @@
Fix a bug introduced in v1.22.0rc1 where presence events were not properly passed to application services.

View File

@ -288,7 +288,7 @@ class ApplicationServicesHandler:
user=user, service=service, from_key=from_key, user=user, service=service, from_key=from_key,
) )
time_now = self.clock.time_msec() time_now = self.clock.time_msec()
presence_events = [ events.extend(
{ {
"type": "m.presence", "type": "m.presence",
"sender": event.user_id, "sender": event.user_id,
@ -297,8 +297,9 @@ class ApplicationServicesHandler:
), ),
} }
for event in presence_events for event in presence_events
] )
events = events + presence_events
return events
async def query_user_exists(self, user_id): async def query_user_exists(self, user_id):
"""Check if any application service knows this user_id exists. """Check if any application service knows this user_id exists.

View File

@ -282,9 +282,10 @@ class ServerMetricsStore(EventPushActionsWorkerStore, SQLBaseStore):
now = self._clock.time_msec() now = self._clock.time_msec()
# A note on user_agent. Technically a given device can have multiple # A note on user_agent. Technically a given device can have multiple
# user agents, so we need to decide which one to pick. We could have handled this # user agents, so we need to decide which one to pick. We could have
# in number of ways, but given that we don't _that_ much have gone for MAX() # handled this in number of ways, but given that we don't care
# For more details of the other options considered see # _that_ much we have gone for MAX(). For more details of the other
# options considered see
# https://github.com/matrix-org/synapse/pull/8503#discussion_r502306111 # https://github.com/matrix-org/synapse/pull/8503#discussion_r502306111
sql = """ sql = """
INSERT INTO user_daily_visits (user_id, device_id, timestamp, user_agent) INSERT INTO user_daily_visits (user_id, device_id, timestamp, user_agent)
@ -299,7 +300,7 @@ class ServerMetricsStore(EventPushActionsWorkerStore, SQLBaseStore):
WHERE last_seen > ? AND last_seen <= ? WHERE last_seen > ? AND last_seen <= ?
AND udv.timestamp IS NULL AND users.is_guest=0 AND udv.timestamp IS NULL AND users.is_guest=0
AND users.appservice_id IS NULL AND users.appservice_id IS NULL
GROUP BY u.user_id, u.device_id, u.user_agent GROUP BY u.user_id, u.device_id
""" """
# This means that the day has rolled over but there could still # This means that the day has rolled over but there could still