-
Notifications
You must be signed in to change notification settings - Fork 121
Add support for "m.federate" and room name in createRoom API method #245
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
Conversation
751f29c to
d9d4970
Compare
Half-Shot
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.
Not sure why the .travis.yml got changed, if it was causing grief then I doubt sudo is going to help.
Generally speaking the code is good but the tests need some work.
| @@ -1,4 +1,4 @@ | |||
| sudo: false | |||
| sudo: required | |||
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.
Why has this been changed?
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.
without it travis was fail at olm make install - check travis build history.
I can revert but it will brake travis build.
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 see that now. Don't put sudo in here anyway, this needs fixing by the maintainer.
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.
Ok. Now I'll take it away.
| name=None, | ||
| is_public=False, | ||
| invitees=None, | ||
| federate=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 don't like leaving booleans as None. You should set this to true, so that users of the API know that federation is on by default. I'd actually argue None is closer to False, which is obviously dangerously wrong.
https://matrix.org/docs/spec/client_server/unstable.html#m-room-create
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.
On my homeservet it's off by default...
I prefer to give a choice of three options: explicitly turn on, explicitly turn off and leave by default.
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.
The default given in the spec is True. If your homeserver does something different then it's non-conforming?
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.
We discuss about SDK implementation or about settings on my homeserver? I gave an example to show that the behavior of the server is not always obvious and it is useful to give the developer the opportunity to explicitly set this parameter.
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.
We should specify the matrix spec default in the methods docstring. None is fine as default kwarg; we just need to be explicit that according to matrix spec this defaults to True in the docstring. If servers have a setting that can change the default value of this and that's considered part of the spec, it's a spec bug that the setting isn't mentioned at the place @Half-Shot linked.
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.
So based on a conversation with @ara4n in #matrix-spec:matrix.org, a server that had a default value other than True for room federation would be non-compliant with the matrix spec. I'm fine with including this distinction between None and False if it's useful to you, but the docstring for this method needs to explicitly say that True is the default.
https://matrix.to/#/!YkZelGRiqijtzXZODa:matrix.org/$1531495739346932GaxTh:matrix.org
| content["invite"] = invitees | ||
| if name: | ||
| content["name"] = name | ||
| if federate is not 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.
wrt above comment: if federate is 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.
feredate can be True, False or None. If it's None we do not add it to json.
test/api_test.py
Outdated
| self.cli.api.create_room( | ||
| name="test", | ||
| alias="#test:example.com", | ||
| is_public=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.
Please don't combine two tests here. If you are also trying to test is_public, create two new tests toggling that behavior.
| federate=True | ||
| ) | ||
| self.cli.api.create_room(name="test3") | ||
| req = responses.calls[0].request |
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.
Spacing
test/api_test.py
Outdated
| room_id = "#foo:matrix.org" | ||
|
|
||
| @responses.activate | ||
| def test_create_room(self): |
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 argue we should be splitting up tests if you are testing different behaviours. E.g. test_create_room_federate, test_create_room_visibility
|
@Half-Shot That's better? |
|
Much better, thank you 😄 . Regarding the travis issues..I need to find out the situation from @non-Jedi. Regarding the True/False/None issue, I guess you have a valid point if your homeserver does something different. I'm approving the changes but I want to see if we can fix the travis issues first. |
matrix_client/api.py
Outdated
| name (str): Optional. Name for neq room. | ||
| is_public (bool): Optional. The public/private visibility. | ||
| invitees (list<str>): Optional. The list of user IDs to invite. | ||
| federate (bool): Optional. Сan a room be deferated. |
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.
spelling
|
In addition to the docstring update, could you please also rebase this on master (so Travis runs successfully) and squash down some of the extra commits? |
matrix_client/api.py
Outdated
| Args: | ||
| alias (str): Optional. The room alias name to set for this room. | ||
| name (str): Optional. Name for neq 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.
spelling
38f0764 to
4a5d698
Compare
|
@non-Jedi Now everything is correct? |
| name (str): Optional. Name for new room. | ||
| is_public (bool): Optional. The public/private visibility. | ||
| invitees (list<str>): Optional. The list of user IDs to invite. | ||
| federate (bool): Optional. Сan a room be federated. |
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.
Please include that this defaults to 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 already explained for Half-Shot why I left three options:
#245 (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.
@non-Jedi included.
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.
Sorry to be anal about this, but the spec says that homeservers default to true on that parameter if it isn't included. It's not a synapse-specific behavior, and we need to document the behavior of a spec-compliant HS. So something like: "Defaults to True if not specified" is what I'm after here.
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.
That's better?
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.
Yep. That's fine. Thanks @slipeer. I'll merge when I'm at a computer I've set up with ssh to my github profile.
.travis.yml
Outdated
| @@ -1,4 +1,4 @@ | |||
| sudo: required | |||
| sudo: 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.
Please remove this change from the commit.
5d6aaa5 to
0ba73e2
Compare
…eateRoom Added test for createRoom api method
0ba73e2 to
11bf397
Compare
|
Forgot to ask for this sooner. Sorry. Could you signoff per the CONTRIBUTING.rst please? https://github.com/matrix-org/matrix-python-sdk/blob/master/CONTRIBUTING.rst Will have to do for each PR before I can merge. Simplest way is to just signoff in a comment. |
|
Signed-off-by: Pavel Kardash slipeer@gmail.com |
|
Cherry-picked into master. Thanks! |
This PR adds: