Skip to content

Conversation

@slipeer
Copy link

@slipeer slipeer commented Jul 12, 2018

This PR adds:

  • Ability to set a parameter 'm.federate' when creating a room
  • Ability to set name when creating a room
  • Test for createRooom api method

@slipeer slipeer force-pushed the mfederate_support branch from 751f29c to d9d4970 Compare July 12, 2018 10:17
Copy link
Collaborator

@Half-Shot Half-Shot left a 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
Copy link
Collaborator

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?

Copy link
Author

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.

Copy link
Collaborator

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.

Copy link
Author

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
Copy link
Collaborator

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

Copy link
Author

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.

Copy link
Collaborator

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?

Copy link
Author

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.

Copy link
Collaborator

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.

Copy link
Collaborator

@non-Jedi non-Jedi Jul 13, 2018

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:
Copy link
Collaborator

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

Copy link
Author

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,
Copy link
Collaborator

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
Copy link
Collaborator

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):
Copy link
Collaborator

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

@slipeer
Copy link
Author

slipeer commented Jul 12, 2018

@Half-Shot That's better?

@Half-Shot
Copy link
Collaborator

Half-Shot commented Jul 12, 2018

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.

@Half-Shot Half-Shot assigned Half-Shot and non-Jedi and unassigned Half-Shot Jul 13, 2018
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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spelling

@non-Jedi
Copy link
Collaborator

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?

Args:
alias (str): Optional. The room alias name to set for this room.
name (str): Optional. Name for neq room.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spelling

@slipeer slipeer force-pushed the mfederate_support branch from 38f0764 to 4a5d698 Compare July 16, 2018 05:20
@slipeer
Copy link
Author

slipeer commented Jul 16, 2018

@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.
Copy link
Collaborator

@non-Jedi non-Jedi Jul 16, 2018

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.

Copy link
Author

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)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@non-Jedi included.

Copy link
Collaborator

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's better?

Copy link
Collaborator

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
Copy link
Collaborator

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.

@slipeer slipeer force-pushed the mfederate_support branch 2 times, most recently from 5d6aaa5 to 0ba73e2 Compare July 16, 2018 14:49
…eateRoom

Added test for createRoom api method
@slipeer slipeer force-pushed the mfederate_support branch from 0ba73e2 to 11bf397 Compare July 16, 2018 15:25
@non-Jedi
Copy link
Collaborator

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.

@slipeer
Copy link
Author

slipeer commented Jul 18, 2018

Signed-off-by: Pavel Kardash slipeer@gmail.com

@non-Jedi
Copy link
Collaborator

Cherry-picked into master. Thanks!

@non-Jedi non-Jedi closed this Jul 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants