mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-10-01 11:49:51 -04:00
Use update_membership to kick guests
This commit is contained in:
parent
150fcde0dc
commit
1bbb67c452
@ -18,7 +18,7 @@ from twisted.internet import defer
|
|||||||
from synapse.api.errors import LimitExceededError, SynapseError, AuthError
|
from synapse.api.errors import LimitExceededError, SynapseError, AuthError
|
||||||
from synapse.crypto.event_signing import add_hashes_and_signatures
|
from synapse.crypto.event_signing import add_hashes_and_signatures
|
||||||
from synapse.api.constants import Membership, EventTypes
|
from synapse.api.constants import Membership, EventTypes
|
||||||
from synapse.types import UserID, RoomAlias
|
from synapse.types import UserID, RoomAlias, Requester
|
||||||
from synapse.push.action_generator import ActionGenerator
|
from synapse.push.action_generator import ActionGenerator
|
||||||
|
|
||||||
from synapse.util.logcontext import PreserveLoggingContext
|
from synapse.util.logcontext import PreserveLoggingContext
|
||||||
@ -319,7 +319,8 @@ class BaseHandler(object):
|
|||||||
if member_event.type != EventTypes.Member:
|
if member_event.type != EventTypes.Member:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if not self.hs.is_mine(UserID.from_string(member_event.state_key)):
|
target_user = UserID.from_string(member_event.state_key)
|
||||||
|
if not self.hs.is_mine(target_user):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if member_event.content["membership"] not in {
|
if member_event.content["membership"] not in {
|
||||||
@ -341,18 +342,13 @@ class BaseHandler(object):
|
|||||||
# and having homeservers have their own users leave keeps more
|
# and having homeservers have their own users leave keeps more
|
||||||
# of that decision-making and control local to the guest-having
|
# of that decision-making and control local to the guest-having
|
||||||
# homeserver.
|
# homeserver.
|
||||||
message_handler = self.hs.get_handlers().message_handler
|
requester = Requester(target_user, "", True)
|
||||||
yield message_handler.create_and_send_event(
|
handler = self.hs.get_handlers().room_member_handler
|
||||||
{
|
yield handler.update_membership(
|
||||||
"type": EventTypes.Member,
|
requester,
|
||||||
"state_key": member_event.state_key,
|
target_user,
|
||||||
"content": {
|
member_event.room_id,
|
||||||
"membership": Membership.LEAVE,
|
"leave",
|
||||||
"kind": "guest"
|
|
||||||
},
|
|
||||||
"room_id": member_event.room_id,
|
|
||||||
"sender": member_event.state_key
|
|
||||||
},
|
|
||||||
ratelimit=False,
|
ratelimit=False,
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -404,7 +404,14 @@ class RoomMemberHandler(BaseHandler):
|
|||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def update_membership(
|
def update_membership(
|
||||||
self, requester, target, room_id, action, txn_id=None, room_hosts=None
|
self,
|
||||||
|
requester,
|
||||||
|
target,
|
||||||
|
room_id,
|
||||||
|
action,
|
||||||
|
txn_id=None,
|
||||||
|
room_hosts=None,
|
||||||
|
ratelimit=True,
|
||||||
):
|
):
|
||||||
effective_membership_state = action
|
effective_membership_state = action
|
||||||
if action in ["kick", "unban"]:
|
if action in ["kick", "unban"]:
|
||||||
@ -451,7 +458,7 @@ class RoomMemberHandler(BaseHandler):
|
|||||||
yield msg_handler.send_event(
|
yield msg_handler.send_event(
|
||||||
event,
|
event,
|
||||||
context,
|
context,
|
||||||
ratelimit=True,
|
ratelimit=ratelimit,
|
||||||
is_guest=requester.is_guest,
|
is_guest=requester.is_guest,
|
||||||
room_hosts=room_hosts,
|
room_hosts=room_hosts,
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user