Merge pull request #2279 from matrix-org/erikj/fix_user_dir
Fix user directory insertion due to missing room_id
This commit is contained in:
commit
6c6b9689bb
|
@ -203,7 +203,9 @@ class UserDirectoyHandler(object):
|
||||||
|
|
||||||
if change is None:
|
if change is None:
|
||||||
# Handle any profile changes
|
# Handle any profile changes
|
||||||
yield self._handle_profile_change(state_key, prev_event_id, event_id)
|
yield self._handle_profile_change(
|
||||||
|
state_key, room_id, prev_event_id, event_id,
|
||||||
|
)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if not change:
|
if not change:
|
||||||
|
@ -372,7 +374,7 @@ class UserDirectoyHandler(object):
|
||||||
yield self.store.remove_from_user_in_public_room(user_id)
|
yield self.store.remove_from_user_in_public_room(user_id)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def _handle_profile_change(self, user_id, prev_event_id, event_id):
|
def _handle_profile_change(self, user_id, room_id, prev_event_id, event_id):
|
||||||
"""Check member event changes for any profile changes and update the
|
"""Check member event changes for any profile changes and update the
|
||||||
database if there are.
|
database if there are.
|
||||||
"""
|
"""
|
||||||
|
@ -395,7 +397,9 @@ class UserDirectoyHandler(object):
|
||||||
new_avatar = event.content.get("avatar_url")
|
new_avatar = event.content.get("avatar_url")
|
||||||
|
|
||||||
if prev_name != new_name or prev_avatar != new_avatar:
|
if prev_name != new_name or prev_avatar != new_avatar:
|
||||||
yield self.store.update_profile_in_user_dir(user_id, new_name, new_avatar)
|
yield self.store.update_profile_in_user_dir(
|
||||||
|
user_id, new_name, new_avatar, room_id,
|
||||||
|
)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def _get_key_change(self, prev_event_id, event_id, key_name, public_value):
|
def _get_key_change(self, prev_event_id, event_id, key_name, public_value):
|
||||||
|
|
|
@ -149,12 +149,13 @@ class UserDirectoryStore(SQLBaseStore):
|
||||||
)
|
)
|
||||||
self.get_user_in_directory.invalidate((user_id,))
|
self.get_user_in_directory.invalidate((user_id,))
|
||||||
|
|
||||||
def update_profile_in_user_dir(self, user_id, display_name, avatar_url):
|
def update_profile_in_user_dir(self, user_id, display_name, avatar_url, room_id):
|
||||||
def _update_profile_in_user_dir_txn(txn):
|
def _update_profile_in_user_dir_txn(txn):
|
||||||
new_entry = self._simple_upsert_txn(
|
new_entry = self._simple_upsert_txn(
|
||||||
txn,
|
txn,
|
||||||
table="user_directory",
|
table="user_directory",
|
||||||
keyvalues={"user_id": user_id},
|
keyvalues={"user_id": user_id},
|
||||||
|
insertion_values={"room_id": room_id},
|
||||||
values={"display_name": display_name, "avatar_url": avatar_url},
|
values={"display_name": display_name, "avatar_url": avatar_url},
|
||||||
lock=False, # We're only inserter
|
lock=False, # We're only inserter
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue