1313# See the License for the specific language governing permissions and
1414# limitations under the License.
1515import logging
16- import re
1716
1817from synapse .api .errors import NotFoundError , SynapseError
1918from synapse .http .servlet import (
2019 RestServlet ,
2120 assert_params_in_dict ,
2221 parse_json_object_from_request ,
2322)
24- from synapse .rest .admin ._base import assert_requester_is_admin
23+ from synapse .rest .admin ._base import admin_patterns , assert_requester_is_admin
2524from synapse .types import UserID
2625
2726logger = logging .getLogger (__name__ )
@@ -32,10 +31,8 @@ class DeviceRestServlet(RestServlet):
3231 Get, update or delete the given user's device
3332 """
3433
35- PATTERNS = (
36- re .compile (
37- "^/_synapse/admin/v2/users/(?P<user_id>[^/]*)/devices/(?P<device_id>[^/]*)$"
38- ),
34+ PATTERNS = admin_patterns (
35+ "/users/(?P<user_id>[^/]*)/devices/(?P<device_id>[^/]*)$" , "v2"
3936 )
4037
4138 def __init__ (self , hs ):
@@ -98,7 +95,7 @@ class DevicesRestServlet(RestServlet):
9895 Retrieve the given user's devices
9996 """
10097
101- PATTERNS = ( re . compile ( "^/_synapse/admin/v2/ users/(?P<user_id>[^/]*)/devices$"), )
98+ PATTERNS = admin_patterns ( "/ users/(?P<user_id>[^/]*)/devices$", "v2" )
10299
103100 def __init__ (self , hs ):
104101 """
@@ -131,9 +128,7 @@ class DeleteDevicesRestServlet(RestServlet):
131128 key which lists the device_ids to delete.
132129 """
133130
134- PATTERNS = (
135- re .compile ("^/_synapse/admin/v2/users/(?P<user_id>[^/]*)/delete_devices$" ),
136- )
131+ PATTERNS = admin_patterns ("/users/(?P<user_id>[^/]*)/delete_devices$" , "v2" )
137132
138133 def __init__ (self , hs ):
139134 self .hs = hs
0 commit comments