mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-02 17:54:48 -04:00
Merge pull request #700 from matrix-org/erikj/deduplicate_joins
Deduplicate membership changes
This commit is contained in:
commit
a294b04bf0
4 changed files with 125 additions and 2 deletions
|
@ -24,6 +24,7 @@ from synapse.api.constants import (
|
|||
)
|
||||
from synapse.api.errors import AuthError, SynapseError, Codes
|
||||
from synapse.util.logcontext import preserve_context_over_fn
|
||||
from synapse.util.async import Linearizer
|
||||
|
||||
from signedjson.sign import verify_signed_json
|
||||
from signedjson.key import decode_verify_key_bytes
|
||||
|
@ -60,6 +61,8 @@ class RoomMemberHandler(BaseHandler):
|
|||
def __init__(self, hs):
|
||||
super(RoomMemberHandler, self).__init__(hs)
|
||||
|
||||
self.member_linearizer = Linearizer()
|
||||
|
||||
self.clock = hs.get_clock()
|
||||
|
||||
self.distributor = hs.get_distributor()
|
||||
|
@ -182,6 +185,34 @@ class RoomMemberHandler(BaseHandler):
|
|||
remote_room_hosts=None,
|
||||
third_party_signed=None,
|
||||
ratelimit=True,
|
||||
):
|
||||
key = (target, room_id,)
|
||||
|
||||
with (yield self.member_linearizer.queue(key)):
|
||||
result = yield self._update_membership(
|
||||
requester,
|
||||
target,
|
||||
room_id,
|
||||
action,
|
||||
txn_id=txn_id,
|
||||
remote_room_hosts=remote_room_hosts,
|
||||
third_party_signed=third_party_signed,
|
||||
ratelimit=ratelimit,
|
||||
)
|
||||
|
||||
defer.returnValue(result)
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def _update_membership(
|
||||
self,
|
||||
requester,
|
||||
target,
|
||||
room_id,
|
||||
action,
|
||||
txn_id=None,
|
||||
remote_room_hosts=None,
|
||||
third_party_signed=None,
|
||||
ratelimit=True,
|
||||
):
|
||||
effective_membership_state = action
|
||||
if action in ["kick", "unban"]:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue