mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2025-05-08 00:45:04 -04:00
Use admin_patterns for all admin APIs. (#8331)
This reduces duplication of the admin prefix in regular expressions.
This commit is contained in:
parent
53284c425e
commit
c3c9732c53
7 changed files with 20 additions and 26 deletions
|
@ -13,7 +13,6 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
import logging
|
||||
import re
|
||||
|
||||
from synapse.api.errors import NotFoundError, SynapseError
|
||||
from synapse.http.servlet import (
|
||||
|
@ -21,7 +20,7 @@ from synapse.http.servlet import (
|
|||
assert_params_in_dict,
|
||||
parse_json_object_from_request,
|
||||
)
|
||||
from synapse.rest.admin._base import assert_requester_is_admin
|
||||
from synapse.rest.admin._base import admin_patterns, assert_requester_is_admin
|
||||
from synapse.types import UserID
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -32,10 +31,8 @@ class DeviceRestServlet(RestServlet):
|
|||
Get, update or delete the given user's device
|
||||
"""
|
||||
|
||||
PATTERNS = (
|
||||
re.compile(
|
||||
"^/_synapse/admin/v2/users/(?P<user_id>[^/]*)/devices/(?P<device_id>[^/]*)$"
|
||||
),
|
||||
PATTERNS = admin_patterns(
|
||||
"/users/(?P<user_id>[^/]*)/devices/(?P<device_id>[^/]*)$", "v2"
|
||||
)
|
||||
|
||||
def __init__(self, hs):
|
||||
|
@ -98,7 +95,7 @@ class DevicesRestServlet(RestServlet):
|
|||
Retrieve the given user's devices
|
||||
"""
|
||||
|
||||
PATTERNS = (re.compile("^/_synapse/admin/v2/users/(?P<user_id>[^/]*)/devices$"),)
|
||||
PATTERNS = admin_patterns("/users/(?P<user_id>[^/]*)/devices$", "v2")
|
||||
|
||||
def __init__(self, hs):
|
||||
"""
|
||||
|
@ -131,9 +128,7 @@ class DeleteDevicesRestServlet(RestServlet):
|
|||
key which lists the device_ids to delete.
|
||||
"""
|
||||
|
||||
PATTERNS = (
|
||||
re.compile("^/_synapse/admin/v2/users/(?P<user_id>[^/]*)/delete_devices$"),
|
||||
)
|
||||
PATTERNS = admin_patterns("/users/(?P<user_id>[^/]*)/delete_devices$", "v2")
|
||||
|
||||
def __init__(self, hs):
|
||||
self.hs = hs
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue