Add matrix client well-known view

This commit is contained in:
Jake Howard 2022-08-22 14:43:58 +01:00
parent 31c370c13e
commit e74dbcc228
Signed by: jake
GPG Key ID: 57AFB45680EDD477
4 changed files with 26 additions and 0 deletions

View File

@ -0,0 +1,5 @@
{
"m.homeserver": {
"base_url": "https://matrix.jakehoward.tech"
}
}

View File

@ -59,3 +59,13 @@ class MatrixServerViewTestCase(SimpleTestCase):
self.assertEqual(response.status_code, 200)
self.assertEqual(response["Content-Type"], "application/json")
self.assertTemplateUsed(response, "matrix-server.json")
class MatrixClientViewTestCase(SimpleTestCase):
url = reverse("matrix-client")
def test_accessible(self) -> None:
response = self.client.get(self.url)
self.assertEqual(response.status_code, 200)
self.assertEqual(response["Content-Type"], "application/json")
self.assertTemplateUsed(response, "matrix-client.json")

View File

@ -59,3 +59,8 @@ class SecurityView(TemplateView):
class MatrixServerView(TemplateView):
template_name = "matrix-server.json"
content_type = "application/json"
class MatrixClientView(TemplateView):
template_name = "matrix-client.json"
content_type = "application/json"

View File

@ -8,6 +8,7 @@ from wagtail.documents import urls as wagtaildocs_urls
from wagtail.images.views.serve import ServeView
from website.common.views import (
MatrixClientView,
MatrixServerView,
RobotsView,
SecurityView,
@ -38,6 +39,11 @@ urlpatterns = [
cache_page(60 * 60)(MatrixServerView.as_view()),
name="matrix-server",
),
path(
".well-known/matrix/client",
cache_page(60 * 60)(MatrixClientView.as_view()),
name="matrix-client",
),
path("404/", page_not_found, name="404"),
]