-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Migrate direct message and tag state on room upgrade #4412
Conversation
1707fe3
to
db9e7df
Compare
Done. |
Codecov Report
@@ Coverage Diff @@
## develop #4412 +/- ##
===========================================
+ Coverage 74.73% 74.75% +0.02%
===========================================
Files 336 336
Lines 34122 34138 +16
Branches 5547 5552 +5
===========================================
+ Hits 25500 25521 +21
+ Misses 7048 7041 -7
- Partials 1574 1576 +2 |
d40d531
to
46718b1
Compare
Signed-off-by: Andrew Morgan <andrew@amorgan.xyz>
2c5f453
to
d9bcecf
Compare
d9bcecf
to
8086a5c
Compare
So this seems to be failing due to a timeout on sending a Ctrl-F for This PR does add logic to when someone joins a room. Not sure if that has to do with |
ab2f127
to
766a172
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
generally looks good, but a few suggestions for cleanups here.
synapse/handlers/room_member.py
Outdated
return | ||
create_event = yield self.store.get_event(create_id) | ||
|
||
if "predecessor" in create_event["content"]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
presumably we can use the method from the search PR for this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, we can but it's inside SearchHandler
:
synapse/synapse/handlers/search.py
Lines 41 to 56 in b1b6dba
def get_old_rooms_from_upgraded_room(self, room_id): | |
"""Retrieves room IDs of old rooms in the history of an upgraded room. | |
We do so by checking the m.room.create event of the room for a | |
`predecessor` key. If it exists, we add the room ID to our return | |
list and then check that room for a m.room.create event and so on | |
until we can no longer find any more previous rooms. | |
The full list of all found rooms in then returned. | |
Args: | |
room_id (str): id of the room to search through. | |
Returns: | |
Deferred[iterable[unicode]]: predecessor room ids | |
""" |
Shall I move it to the store instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking specifically of get_room_predecessor
, which is in the Store I think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, so it is. Will add, thanks.
synapse/handlers/room_member.py
Outdated
user_account_data = yield self.store.get_account_data_for_user( | ||
user_id, | ||
) | ||
room_tags = yield self.store.get_tags_for_room( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
feels weird when this is up here and not used until later on
synapse/handlers/room_member.py
Outdated
break | ||
|
||
# Copy room tags if applicable | ||
if room_tags: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
think this condition is redundant? get_tags_for_room
always returns a dict, even if it's empty.
synapse/handlers/room_member.py
Outdated
old_room_id = create_event["content"]["predecessor"]["room_id"] | ||
|
||
# Retrieve room account data for predecessor room | ||
user_account_data = yield self.store.get_account_data_for_user( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
given you just want the first item in the tuple you can write:
user_account_data, _ = yield ...
which then saves the slightly cryptic [0]
indexes later
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ohh, nice one. I love destructuring.
synapse/handlers/room_member.py
Outdated
) | ||
|
||
# Copy direct message state if applicable | ||
if user_account_data and "m.direct" in user_account_data[0]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggest you do direct_rooms = user_account_data.get("m.direct", {})
and you can drop these conditions.
HOWEVER it may be worth sanity-checking that nobody has decided to make m.direct
a list or something else other than a dict, so if isinstance(direct_rooms, dict)
.
synapse/handlers/room_member.py
Outdated
# Copy room tags if applicable | ||
if room_tags: | ||
# Copy each room tag to the new room | ||
for tag in room_tags.keys(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for tag, tag_content in room_tags.items():
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oof, I think I got lost in thinking how the tag data was structured to realize how clunky that code was.
Thanks for pointing it out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm otherwise
synapse/handlers/room_member.py
Outdated
user_id (str) | ||
|
||
Returns: | ||
Deferred|None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ITYM Deferred[None]
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, it was just copied from another method. We seem to have several different ways of writing the same thing spread across different methods?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deferred|None
means: "either a Deferred (of unspecified value type), or None", which is different to what your method does
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh, I see, thank you.
Pull Request Checklist
Sytest PR: matrix-org/sytest#547