diff options
author | Patrick Cloke <clokep@users.noreply.github.com> | 2020-09-17 07:04:15 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-17 07:04:15 -0400 |
commit | c3c9732c5363ef007dd838dea016719d3ab07a89 (patch) | |
tree | c0693f1120b6240e3b823f4b438c70085a4d7445 /synapse/rest/admin/server_notice_servlet.py | |
parent | Fix a potential bug of UnboundLocalError (#8329) (diff) | |
download | synapse-c3c9732c5363ef007dd838dea016719d3ab07a89.tar.xz |
Use admin_patterns for all admin APIs. (#8331)
This reduces duplication of the admin prefix in regular expressions.
Diffstat (limited to 'synapse/rest/admin/server_notice_servlet.py')
-rw-r--r-- | synapse/rest/admin/server_notice_servlet.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/synapse/rest/admin/server_notice_servlet.py b/synapse/rest/admin/server_notice_servlet.py index 6e9a874121..375d055445 100644 --- a/synapse/rest/admin/server_notice_servlet.py +++ b/synapse/rest/admin/server_notice_servlet.py @@ -12,8 +12,6 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -import re - from synapse.api.constants import EventTypes from synapse.api.errors import SynapseError from synapse.http.servlet import ( @@ -22,6 +20,7 @@ from synapse.http.servlet import ( parse_json_object_from_request, ) from synapse.rest.admin import assert_requester_is_admin +from synapse.rest.admin._base import admin_patterns from synapse.rest.client.transactions import HttpTransactionCache from synapse.types import UserID @@ -56,13 +55,13 @@ class SendServerNoticeServlet(RestServlet): self.snm = hs.get_server_notices_manager() def register(self, json_resource): - PATTERN = "^/_synapse/admin/v1/send_server_notice" + PATTERN = "/send_server_notice" json_resource.register_paths( - "POST", (re.compile(PATTERN + "$"),), self.on_POST, self.__class__.__name__ + "POST", admin_patterns(PATTERN + "$"), self.on_POST, self.__class__.__name__ ) json_resource.register_paths( "PUT", - (re.compile(PATTERN + "/(?P<txn_id>[^/]*)$"),), + admin_patterns(PATTERN + "/(?P<txn_id>[^/]*)$"), self.on_PUT, self.__class__.__name__, ) |