Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Add joinability for groups #3045

Merged
merged 12 commits into from Apr 5, 2018
Merged

Add joinability for groups #3045

merged 12 commits into from Apr 5, 2018

Conversation

dbkr
Copy link
Member

@dbkr dbkr commented Mar 28, 2018

Adds API to set the 'joinable' flag, and corresponding flag in the
table.

Adds API to set the 'joinable' flag, and corresponding flag in the
table.
requester = yield self.auth.get_user_by_req(request)
requester_user_id = requester.user.to_string()

content = parse_json_object_from_request(request)
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't we evaluate that we have only have {"joinable": <bool>} as body?

@dbkr
Copy link
Member Author

dbkr commented Mar 28, 2018

I assume this is a flaky sytest?

Copy link
Member

@erikjohnston erikjohnston left a comment

Choose a reason for hiding this comment

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

Code wise, looks good.

API wise, it'd be good if this followed the same style of API as the visibility stuff, e.g.: https://github.com/matrix-org/synapse/blob/master/synapse/groups/groups_server.py#L838-L864. In particular we probably want to have a m.* prefix, e.g.:

{
  "m.join_policy": {
    "type": "invite"
  }
}

This would support us having values like invite, knock and open (I'd suggest not reusing "public"). If we do have multiple values the DB would need to support that.

@erikjohnston erikjohnston assigned dbkr and unassigned erikjohnston Mar 29, 2018
PATH = "/groups/(?P<group_id>[^/]*)/joinable$"

@defer.inlineCallbacks
def on_POST(self, origin, content, query, group_id):
Copy link
Member Author

Choose a reason for hiding this comment

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

Should this be PUT or POST? The client API is a PUT.

Copy link
Contributor

Choose a reason for hiding this comment

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

Erik said it should have the same method as the CS API. @erikjohnston, can you confirm?

@lukebarnard1 lukebarnard1 force-pushed the dbkr/group_joinable branch 2 times, most recently from 2a74640 to 52c2268 Compare April 3, 2018 15:08
@lukebarnard1 lukebarnard1 assigned erikjohnston and unassigned dbkr Apr 3, 2018
The API is now under
 /groups/$group_id/setting/m.join_policy

and expects a JSON blob of the shape

```json
{
  "m.join_policy": {
    "type": "invite"
  }
}
```

where "invite" could alternatively be "open".
@lukebarnard1
Copy link
Contributor

matrix-org/sytest#436 will need updating once these changes have landed.

Copy link
Member

@erikjohnston erikjohnston left a comment

Choose a reason for hiding this comment

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

Just a couple of small nits, actual functionality looks good

@@ -29,6 +30,18 @@


class GroupServerStore(SQLBaseStore):
def set_group_join_policy(self, group_id, join_policy):
return self._simple_update_one(
Copy link
Member

Choose a reason for hiding this comment

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

set_group_join_policy needs a docstring, especially as we only want to accept certain values so we should document what they are.

Might also be worth adding a assert join_policy in ('invite', 'open') (we should probably move some of those to constants somewhere at some point)

* NULL at the python store level as necessary so that existing
* rows are given the correct default policy.
*/
ALTER TABLE groups ADD COLUMN join_policy TEXT DEFAULT NULL;
Copy link
Member

Choose a reason for hiding this comment

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

If we can have defaults then we may as well do

ALTER TABLE groups ADD COLUMN join_policy TEXT NON NULL DEFAULT 'invite';

content):
"""Sets the join policy for a group
"""
path = PREFIX + "/groups/%s/setting/m.join_policy" % (group_id,)
Copy link
Member

Choose a reason for hiding this comment

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

(I was expecting it to be settings plural, but that's a matter of taste)

@lukebarnard1 lukebarnard1 removed their assignment Apr 5, 2018
lukebarnard1 added a commit to matrix-org/sytest that referenced this pull request Apr 5, 2018
@erikjohnston
Copy link
Member

(I didn't mean to assign @richvdh there....)

@lukebarnard1 lukebarnard1 merged commit e089100 into develop Apr 5, 2018
lukebarnard1 added a commit to matrix-org/sytest that referenced this pull request Apr 5, 2018
lukebarnard1 added a commit to matrix-org/sytest that referenced this pull request Apr 5, 2018
lukebarnard1 added a commit to matrix-org/sytest that referenced this pull request Apr 5, 2018
anoadragon453 pushed a commit to matrix-org/sytest that referenced this pull request Jun 15, 2018
@hawkowl hawkowl deleted the dbkr/group_joinable branch September 20, 2018 13:59
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants