mirror of
https://mau.dev/maunium/synapse.git
synced 2024-12-16 21:43:52 +01:00
Revert recent changes to RoomMemberStore
This commit is contained in:
parent
a840ff8f3f
commit
a87eac4308
2 changed files with 10 additions and 28 deletions
|
@ -154,7 +154,7 @@ class DataStore(RoomMemberStore, RoomStore,
|
||||||
@log_function
|
@log_function
|
||||||
def _persist_event_txn(self, txn, event, backfilled, stream_ordering=None):
|
def _persist_event_txn(self, txn, event, backfilled, stream_ordering=None):
|
||||||
if event.type == RoomMemberEvent.TYPE:
|
if event.type == RoomMemberEvent.TYPE:
|
||||||
self._store_room_member_from_event_txn(txn, event)
|
self._store_room_member_txn(txn, event)
|
||||||
elif event.type == FeedbackEvent.TYPE:
|
elif event.type == FeedbackEvent.TYPE:
|
||||||
self._store_feedback_txn(txn, event)
|
self._store_feedback_txn(txn, event)
|
||||||
elif event.type == RoomNameEvent.TYPE:
|
elif event.type == RoomNameEvent.TYPE:
|
||||||
|
|
|
@ -26,55 +26,37 @@ logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
class RoomMemberStore(SQLBaseStore):
|
class RoomMemberStore(SQLBaseStore):
|
||||||
|
|
||||||
def _store_room_member_from_event_txn(self, txn, event):
|
def _store_room_member_txn(self, txn, event):
|
||||||
self._store_room_member_txn(txn,
|
|
||||||
target_user_id=event.state_key,
|
|
||||||
sender_user_id=event.user_id,
|
|
||||||
room_id=event.room_id,
|
|
||||||
event_id=event.event_id,
|
|
||||||
membership=event.membership,
|
|
||||||
)
|
|
||||||
|
|
||||||
def _store_room_member_txn(self, txn, target_user_id, sender_user_id,
|
|
||||||
room_id, event_id, membership):
|
|
||||||
"""Store a room member in the database.
|
"""Store a room member in the database.
|
||||||
"""
|
"""
|
||||||
|
target_user_id = event.state_key
|
||||||
domain = self.hs.parse_userid(target_user_id).domain
|
domain = self.hs.parse_userid(target_user_id).domain
|
||||||
|
|
||||||
self._simple_insert_txn(
|
self._simple_insert_txn(
|
||||||
txn,
|
txn,
|
||||||
"room_memberships",
|
"room_memberships",
|
||||||
{
|
{
|
||||||
"event_id": event_id,
|
"event_id": event.event_id,
|
||||||
"user_id": target_user_id,
|
"user_id": target_user_id,
|
||||||
"sender": sender_user_id,
|
"sender": event.user_id,
|
||||||
"room_id": room_id,
|
"room_id": event.room_id,
|
||||||
"membership": membership,
|
"membership": event.membership,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
# Update room hosts table
|
# Update room hosts table
|
||||||
# TODO(paul): This code is massively broken currently as it doesn't
|
if event.membership == Membership.JOIN:
|
||||||
# count users per room - meaning it'll delete on the FIRST user to
|
|
||||||
# have a membership other than JOIN - say, LEAVE, or even INVITE.
|
|
||||||
# FIXME
|
|
||||||
if membership == Membership.JOIN:
|
|
||||||
sql = (
|
sql = (
|
||||||
"INSERT OR IGNORE INTO room_hosts (room_id, host) "
|
"INSERT OR IGNORE INTO room_hosts (room_id, host) "
|
||||||
"VALUES (?, ?)"
|
"VALUES (?, ?)"
|
||||||
)
|
)
|
||||||
txn.execute(sql, (room_id, domain))
|
txn.execute(sql, (event.room_id, domain))
|
||||||
else:
|
else:
|
||||||
sql = (
|
sql = (
|
||||||
"DELETE FROM room_hosts WHERE room_id = ? AND host = ?"
|
"DELETE FROM room_hosts WHERE room_id = ? AND host = ?"
|
||||||
)
|
)
|
||||||
|
|
||||||
txn.execute(sql, (room_id, domain))
|
txn.execute(sql, (event.room_id, domain))
|
||||||
|
|
||||||
def store_room_member(self, user_id, room_id, event_id, membership):
|
|
||||||
return self.runInteraction(self._store_room_member_txn,
|
|
||||||
user_id, user_id, room_id, event_id, membership
|
|
||||||
)
|
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def get_room_member(self, user_id, room_id):
|
def get_room_member(self, user_id, room_id):
|
||||||
|
|
Loading…
Reference in a new issue