Only notify the target of a membership event
Naughty, but should be a big speedup in large rooms Changeloganoa/redirect_instances
parent
769406378c
commit
a7fa951876
|
@ -0,0 +1 @@
|
||||||
|
Improve performance of joining and leaving large rooms with many local users.
|
|
@ -129,6 +129,17 @@ class BulkPushRuleEvaluator:
|
||||||
Returns:
|
Returns:
|
||||||
Mapping of user ID to their push rules.
|
Mapping of user ID to their push rules.
|
||||||
"""
|
"""
|
||||||
|
# If this is a membership event, only calculate push rules for the target.
|
||||||
|
# While it's possible for users to configure push rules to respond to such an
|
||||||
|
# event, in practise nobody does this. At the cost of violating the spec a
|
||||||
|
# little, we can skip fetching a huge number of push rules in large rooms.
|
||||||
|
# This helps make joins and leaves faster.
|
||||||
|
if event.type == EventTypes.Member:
|
||||||
|
if self.hs.is_mine_id(event.state_key):
|
||||||
|
local_users = [event.state_key]
|
||||||
|
else:
|
||||||
|
return {}
|
||||||
|
else:
|
||||||
# We get the users who may need to be notified by first fetching the
|
# We get the users who may need to be notified by first fetching the
|
||||||
# local users currently in the room, finding those that have push rules,
|
# local users currently in the room, finding those that have push rules,
|
||||||
# and *then* checking which users are actually allowed to see the event.
|
# and *then* checking which users are actually allowed to see the event.
|
||||||
|
|
Loading…
Reference in New Issue