-
Notifications
You must be signed in to change notification settings - Fork 121
Handle all m.room.aliases chunk, not only first #270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
non-Jedi
left a comment
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.
Other than comment, this LGTM. Note that this doesn't close #106 because the _process_state_event method also needs to be changed to account for multiple m.room.aliases state events.
matrix_client/room.py
Outdated
| Returns: | ||
| boolean: True if the aliases changed, False if not | ||
| """ | ||
| response = 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.
I'm having trouble understanding why this is necessary. If try block below is successful, response will be bound to something, and if it isn't successful, the method terminates without going further.
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 agree this is an excessive reinsurance
test/client_test.py
Outdated
| room.name = False | ||
| room.topic = False | ||
| room.aliases = False | ||
| room.aliases = [] |
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 found that when initializing aliases in rooms.py used empty list
matrix-python-sdk/matrix_client/room.py
Line 43 in 00186ba
| self.aliases = [] |
False here doesn't look correct.
| ev["content"]["aliases"] = aliases | ||
| room._process_state_event(ev) | ||
| assert room.aliases is aliases | ||
| assert room.aliases == aliases |
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.
Since now we are processing list element by element, is will no longer work here.
| ev["type"] = "m.room.aliases" | ||
| room._process_state_event(ev) | ||
| assert room.aliases is None | ||
| assert room.aliases == [] |
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.
Since aliases is initialized as an empty list, it can no longer be None.
|
|
||
| room.name = False | ||
| room.topic = False | ||
| room.aliases = False |
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 found that when initializing aliases in rooms.py used empty list
matrix-python-sdk/matrix_client/room.py
Line 43 in 00186ba
| self.aliases = [] |
False here doesn't look correct.
Zil0
left a comment
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.
This looks nice if not for the small bug underlined :)
| return False | ||
| except MatrixRequestError: | ||
| return False | ||
| self.aliases = [] |
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'd rather have self.aliases.clear() here.
| for alias in chunk["content"]["aliases"]: | ||
| if alias not in self.aliases: | ||
| self.aliases.append(alias) | ||
| changed = True |
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 don't think this works as expected. Since self.aliases will always be empty because of self.aliases = [] above, changed will always be True as long as there is at least one alias, even if it's the same as before.
|
Is there a reason why |
This is fix for #106 issue
Rooom state server reply may contain more then one
m.room.aliasesupdate_aliases() method must collect aliases from all of them.Additionally in this code only
get_room_state()can raiseMatrixRequestError- there is no need to enclose to try block more strings.Signed-off-by: Pavel Kardash [email protected]