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

Replace /admin/v1/users_paginate endpoint with /admin/v2/users #5925

Merged
merged 12 commits into from
Dec 5, 2019

Conversation

awesome-manuel
Copy link
Contributor

Fixes #5494 and #2522.
Needs to be tested for #3666.

Pull Request Checklist

  • Pull request is based on the develop branch
  • Pull request includes a changelog file
  • Pull request includes a sign off

@awesome-manuel awesome-manuel changed the base branch from master to develop August 28, 2019 14:59
@awesome-manuel
Copy link
Contributor Author

@richvdh The pagination API is not 100% compatible to the normal users API. Pagination returns a list of users and the total amount as a separate field whereas the users API just returns a list.
We probably don't want to change the users API since this one is actually used by current clients.

@richvdh
Copy link
Member

richvdh commented Aug 30, 2019

might be a case for /admin/v2/users which solves the various problems with the current endpoints.

@awesome-manuel
Copy link
Contributor Author

@richvdh any idea why buildkite does not complete?

Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

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

Sorry for the very slow review on this! I've got some suggestions, mostly around the shape of the API.

The current API is a disaster, so I'm treating this basically as a fresh start, hence some of my comments. But also: because some of the changes I'm asking for will be incompatible, I suggest it goes onto /admin/v2/users, rather than changing the existing endpoint.

docs/admin_api/user_admin_api.rst Outdated Show resolved Hide resolved
synapse/rest/admin/users.py Outdated Show resolved Hide resolved
synapse/rest/admin/users.py Outdated Show resolved Hide resolved
synapse/rest/admin/users.py Outdated Show resolved Hide resolved
synapse/rest/admin/users.py Outdated Show resolved Hide resolved
changelog.d/5925.removal Show resolved Hide resolved
docs/admin_api/user_admin_api.rst Outdated Show resolved Hide resolved
docs/admin_api/user_admin_api.rst Outdated Show resolved Hide resolved
@richvdh
Copy link
Member

richvdh commented Oct 3, 2019

any idea why buildkite does not complete?

buildkite doesn't run on contributed PRs until someone pushes the button. It's something we're working on fixing, but haven't yet.

@awesome-manuel
Copy link
Contributor Author

awesome-manuel commented Oct 3, 2019

Sorry for the very slow review on this! I've got some suggestions, mostly around the shape of the API.

The current API is a disaster, so I'm treating this basically as a fresh start, hence some of my comments. But also: because some of the changes I'm asking for will be incompatible, I suggest it goes onto /admin/v2/users, rather than changing the existing endpoint.

I totally agree, but keeping the old API implies keeping some ugly methods in DataStore. My suggestion is to at least drop the pagination API from v1, since it never worked as intended anyway.

synapse/rest/admin/v1/__init__.py Outdated Show resolved Hide resolved
docs/admin_api/user_admin_api.rst Outdated Show resolved Hide resolved
Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

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

My suggestion is to at least drop the pagination API from v1, since it never worked as intended anyway.

I'm happy with that.

I'm afraid I can't really review this as it stands, due to the size of the patch. Sorry - please can you undo the move into a v1 package?

@richvdh
Copy link
Member

richvdh commented Oct 10, 2019

btw @awesome-manuel: it might be easier for you to drop into #synapse-dev:matrix.org if you'd like to discuss these changes?

@awesome-manuel
Copy link
Contributor Author

My suggestion is to at least drop the pagination API from v1, since it never worked as intended anyway.

I'm happy with that.

I'm afraid I can't really review this as it stands, due to the size of the patch. Sorry - please can you undo the move into a v1 package?

Yeah, that's a limitation of GitHub. You can have a look at each individual commit here: https://github.com/Awesome-Technologies/synapse/commits/user_admin
Each commit is self-contained (e.g. does not break anything). Of course you can't comment on each individual commit. Internally we use Gerrit, it's a huge improvement for the reviewer, though requires a bit more learning from the reviewee.

@erikjohnston
Copy link
Member

@awesome-manuel I'm afraid I just merged #6196 which ports the synapse.rest.admin package to use async/await, which is the cause for all the conflicts. The change is fairly mechanical, @defer.inlineCallbacks -> async def and yield -> await, but I'm happy to resolve the merge conflict and push here if it turns out to be more difficult to resolve than that

@awesome-manuel
Copy link
Contributor Author

@awesome-manuel I'm afraid I just merged #6196 which ports the synapse.rest.admin package to use async/await, which is the cause for all the conflicts. The change is fairly mechanical, @defer.inlineCallbacks -> async def and yield -> await, but I'm happy to resolve the merge conflict and push here if it turns out to be more difficult to resolve than that

I think I fixed all of these. Can someone please trigger Buildkite?

Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

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

looks like there is a lint failure from CI as well.

synapse/rest/admin/users.py Outdated Show resolved Hide resolved
synapse/rest/admin/__init__.py Outdated Show resolved Hide resolved
@awesome-manuel
Copy link
Contributor Author

What do you think about the @deprecation decorator to mark "old" functions?
https://pypi.org/project/deprecation/

Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

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

this is definitely shaping up. I'm afraid I've still got a few requests though.

docs/admin_api/user_admin_api.rst Show resolved Hide resolved
synapse/rest/admin/users.py Outdated Show resolved Hide resolved
synapse/storage/_base.py Show resolved Hide resolved
synapse/storage/_base.py Outdated Show resolved Hide resolved
@richvdh
Copy link
Member

richvdh commented Dec 4, 2019

Agreed. Would you prefer a fixup commit upon the existing ones, or changing the relevant commits but without rebase?

I'd prefer additional fixup commits. I'll squash them all down when I merge.

docs/admin_api/user_admin_api.rst Outdated Show resolved Hide resolved
synapse/storage/_base.py Outdated Show resolved Hide resolved
docs/admin_api/user_admin_api.rst Outdated Show resolved Hide resolved
Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

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

hurrah! 🍾 🚢 🎉

@richvdh richvdh changed the title Integrate admin endpoint users_paginate into users Replace /admin/v1/users_paginate endpoint with /admin/v2/users Dec 5, 2019
@richvdh richvdh merged commit 649b6bc into matrix-org:develop Dec 5, 2019
@richvdh
Copy link
Member

richvdh commented Dec 5, 2019

Thanks for your perseverence @awesome-manuel !

@awesome-manuel
Copy link
Contributor Author

I definitely appreciate your input, @richvdh

neilisfragile added a commit that referenced this pull request Dec 9, 2019
Synapse 1.7.0rc1 (2019-12-09)
=============================

Features
--------

- Implement per-room message retention policies. ([\#5815](#5815), [\#6436](#6436))
- Add etag and count fields to key backup endpoints to help clients guess if there are new keys. ([\#5858](#5858))
- Add `/admin/v2/users` endpoint with pagination. Contributed by Awesome Technologies Innovationslabor GmbH. ([\#5925](#5925))
- Require User-Interactive Authentication for `/account/3pid/add`, meaning the user's password will be required to add a third-party ID to their account. ([\#6119](#6119))
- Implement the `/_matrix/federation/unstable/net.atleastfornow/state/<context>` API as drafted in MSC2314. ([\#6176](#6176))
- Configure privacy-preserving settings by default for the room directory. ([\#6354](#6354))
- Add ephemeral messages support by partially implementing [MSC2228](matrix-org/matrix-spec-proposals#2228). ([\#6409](#6409))
- Add support for [MSC 2367](matrix-org/matrix-spec-proposals#2367), which allows specifying a reason on all membership events. ([\#6434](#6434))

Bugfixes
--------

- Transfer non-standard power levels on room upgrade. ([\#6237](#6237))
- Fix error from the Pillow library when uploading RGBA images. ([\#6241](#6241))
- Correctly apply the event filter to the `state`, `events_before` and `events_after` fields in the response to `/context` requests. ([\#6329](#6329))
- Fix caching devices for remote users when using workers, so that we don't attempt to refetch (and potentially fail) each time a user requests devices. ([\#6332](#6332))
- Prevent account data syncs getting lost across TCP replication. ([\#6333](#6333))
- Fix bug: TypeError in `register_user()` while using LDAP auth module. ([\#6406](#6406))
- Fix an intermittent exception when handling read-receipts. ([\#6408](#6408))
- Fix broken guest registration when there are existing blocks of numeric user IDs. ([\#6420](#6420))
- Fix startup error when http proxy is defined. ([\#6421](#6421))
- Fix error when using synapse_port_db on a vanilla synapse db. ([\#6449](#6449))
- Fix uploading multiple cross signing signatures for the same user. ([\#6451](#6451))
- Fix bug which lead to exceptions being thrown in a loop when a cross-signed device is deleted. ([\#6462](#6462))
- Fix `synapse_port_db` not exiting with a 0 code if something went wrong during the port process. ([\#6470](#6470))
- Improve sanity-checking when receiving events over federation. ([\#6472](#6472))
- Fix inaccurate per-block Prometheus metrics. ([\#6491](#6491))
- Fix small performance regression for sending invites. ([\#6493](#6493))
- Back out cross-signing code added in Synapse 1.5.0, which caused a performance regression. ([\#6494](#6494))

Improved Documentation
----------------------

- Update documentation and variables in user contributed systemd reference file. ([\#6369](#6369), [\#6490](#6490))
- Fix link in the user directory documentation. ([\#6388](#6388))
- Add build instructions to the docker readme. ([\#6390](#6390))
- Switch Ubuntu package install recommendation to use python3 packages in INSTALL.md. ([\#6443](#6443))
- Write some docs for the quarantine_media api. ([\#6458](#6458))
- Convert CONTRIBUTING.rst to markdown (among other small fixes). ([\#6461](#6461))

Deprecations and Removals
-------------------------

- Remove admin/v1/users_paginate endpoint. Contributed by Awesome Technologies Innovationslabor GmbH. ([\#5925](#5925))
- Remove fallback for federation with old servers which lack the /federation/v1/state_ids API. ([\#6488](#6488))

Internal Changes
----------------

- Add benchmarks for structured logging and improve output performance. ([\#6266](#6266))
- Improve the performance of outputting structured logging. ([\#6322](#6322))
- Refactor some code in the event authentication path for clarity. ([\#6343](#6343), [\#6468](#6468), [\#6480](#6480))
- Clean up some unnecessary quotation marks around the codebase. ([\#6362](#6362))
- Complain on startup instead of 500'ing during runtime when `public_baseurl` isn't set when necessary. ([\#6379](#6379))
- Add a test scenario to make sure room history purges don't break `/messages` in the future. ([\#6392](#6392))
- Clarifications for the email configuration settings. ([\#6423](#6423))
- Add more tests to the blacklist when running in worker mode. ([\#6429](#6429))
- Refactor data store layer to support multiple databases in the future. ([\#6454](#6454), [\#6464](#6464), [\#6469](#6469), [\#6487](#6487))
- Port synapse.rest.client.v1 to async/await. ([\#6482](#6482))
- Port synapse.rest.client.v2_alpha to async/await. ([\#6483](#6483))
- Port SyncHandler to async/await. ([\#6484](#6484))
erikjohnston added a commit that referenced this pull request Dec 13, 2019
Synapse 1.7.0 (2019-12-13)
==========================

This release changes the default settings so that only local authenticated users can query the server's room directory. See the [upgrade notes](UPGRADE.rst#upgrading-to-v170) for details.

Support for SQLite versions before 3.11 is now deprecated. A future release will refuse to start if used with an SQLite version before 3.11.

Administrators are reminded that SQLite should not be used for production instances. Instructions for migrating to Postgres are available [here](docs/postgres.md). A future release of synapse will, by default, disable federation for servers using SQLite.

No significant changes since 1.7.0rc2.

Synapse 1.7.0rc2 (2019-12-11)
=============================

Bugfixes
--------

- Fix incorrect error message for invalid requests when setting user's avatar URL. ([\#6497](#6497))
- Fix support for SQLite 3.7. ([\#6499](#6499))
- Fix regression where sending email push would not work when using a pusher worker. ([\#6507](#6507), [\#6509](#6509))

Synapse 1.7.0rc1 (2019-12-09)
=============================

Features
--------

- Implement per-room message retention policies. ([\#5815](#5815), [\#6436](#6436))
- Add etag and count fields to key backup endpoints to help clients guess if there are new keys. ([\#5858](#5858))
- Add `/admin/v2/users` endpoint with pagination. Contributed by Awesome Technologies Innovationslabor GmbH. ([\#5925](#5925))
- Require User-Interactive Authentication for `/account/3pid/add`, meaning the user's password will be required to add a third-party ID to their account. ([\#6119](#6119))
- Implement the `/_matrix/federation/unstable/net.atleastfornow/state/<context>` API as drafted in MSC2314. ([\#6176](#6176))
- Configure privacy-preserving settings by default for the room directory. ([\#6355](#6355))
- Add ephemeral messages support by partially implementing [MSC2228](matrix-org/matrix-spec-proposals#2228). ([\#6409](#6409))
- Add support for [MSC 2367](matrix-org/matrix-spec-proposals#2367), which allows specifying a reason on all membership events. ([\#6434](#6434))

Bugfixes
--------

- Transfer non-standard power levels on room upgrade. ([\#6237](#6237))
- Fix error from the Pillow library when uploading RGBA images. ([\#6241](#6241))
- Correctly apply the event filter to the `state`, `events_before` and `events_after` fields in the response to `/context` requests. ([\#6329](#6329))
- Fix caching devices for remote users when using workers, so that we don't attempt to refetch (and potentially fail) each time a user requests devices. ([\#6332](#6332))
- Prevent account data syncs getting lost across TCP replication. ([\#6333](#6333))
- Fix bug: TypeError in `register_user()` while using LDAP auth module. ([\#6406](#6406))
- Fix an intermittent exception when handling read-receipts. ([\#6408](#6408))
- Fix broken guest registration when there are existing blocks of numeric user IDs. ([\#6420](#6420))
- Fix startup error when http proxy is defined. ([\#6421](#6421))
- Fix error when using synapse_port_db on a vanilla synapse db. ([\#6449](#6449))
- Fix uploading multiple cross signing signatures for the same user. ([\#6451](#6451))
- Fix bug which lead to exceptions being thrown in a loop when a cross-signed device is deleted. ([\#6462](#6462))
- Fix `synapse_port_db` not exiting with a 0 code if something went wrong during the port process. ([\#6470](#6470))
- Improve sanity-checking when receiving events over federation. ([\#6472](#6472))
- Fix inaccurate per-block Prometheus metrics. ([\#6491](#6491))
- Fix small performance regression for sending invites. ([\#6493](#6493))
- Back out cross-signing code added in Synapse 1.5.0, which caused a performance regression. ([\#6494](#6494))

Improved Documentation
----------------------

- Update documentation and variables in user contributed systemd reference file. ([\#6369](#6369), [\#6490](#6490))
- Fix link in the user directory documentation. ([\#6388](#6388))
- Add build instructions to the docker readme. ([\#6390](#6390))
- Switch Ubuntu package install recommendation to use python3 packages in INSTALL.md. ([\#6443](#6443))
- Write some docs for the quarantine_media api. ([\#6458](#6458))
- Convert CONTRIBUTING.rst to markdown (among other small fixes). ([\#6461](#6461))

Deprecations and Removals
-------------------------

- Remove admin/v1/users_paginate endpoint. Contributed by Awesome Technologies Innovationslabor GmbH. ([\#5925](#5925))
- Remove fallback for federation with old servers which lack the /federation/v1/state_ids API. ([\#6488](#6488))

Internal Changes
----------------

- Add benchmarks for structured logging and improve output performance. ([\#6266](#6266))
- Improve the performance of outputting structured logging. ([\#6322](#6322))
- Refactor some code in the event authentication path for clarity. ([\#6343](#6343), [\#6468](#6468), [\#6480](#6480))
- Clean up some unnecessary quotation marks around the codebase. ([\#6362](#6362))
- Complain on startup instead of 500'ing during runtime when `public_baseurl` isn't set when necessary. ([\#6379](#6379))
- Add a test scenario to make sure room history purges don't break `/messages` in the future. ([\#6392](#6392))
- Clarifications for the email configuration settings. ([\#6423](#6423))
- Add more tests to the blacklist when running in worker mode. ([\#6429](#6429))
- Refactor data store layer to support multiple databases in the future. ([\#6454](#6454), [\#6464](#6464), [\#6469](#6469), [\#6487](#6487))
- Port synapse.rest.client.v1 to async/await. ([\#6482](#6482))
- Port synapse.rest.client.v2_alpha to async/await. ([\#6483](#6483))
- Port SyncHandler to async/await. ([\#6484](#6484))
@richvdh
Copy link
Member

richvdh commented Dec 16, 2019

this seems to be broken on (at least) postgres: #6552. I guess we should have written some tests :/

@awesome-manuel awesome-manuel deleted the user_admin branch December 18, 2019 12:48
richvdh pushed a commit that referenced this pull request Apr 9, 2021
Related: #8334
Deprecated in: #9429 - Synapse 1.28.0 (2021-02-25)

`GET /_synapse/admin/v1/users/<user_id>` has no
- unit tests
- documentation

API in v2 is available (#5925 - 12/2019, v1.7.0).
API is misleading. It expects `user_id` and returns a list of all users.

Signed-off-by: Dirk Klimpel dirk@klimpel.org
babolivier pushed a commit that referenced this pull request Sep 1, 2021
* commit '649b6bc08':
  Replace /admin/v1/users_paginate endpoint with /admin/v2/users (#5925)
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

3 participants