Add view to serve matrix server well-known URL
This commit is contained in:
parent
10b32da3e0
commit
521595a781
4 changed files with 27 additions and 1 deletions
1
website/common/templates/matrix-server.json
Normal file
1
website/common/templates/matrix-server.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"m.server": "matrix.jakehoward.tech:443"}
|
|
@ -49,3 +49,13 @@ class SecurityViewTestCase(TestCase):
|
|||
response.context["security_txt"],
|
||||
"http://testserver/.well-known/security.txt",
|
||||
)
|
||||
|
||||
|
||||
class MatrixServerViewTestCase(SimpleTestCase):
|
||||
url = reverse("matrix-server")
|
||||
|
||||
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-server.json")
|
||||
|
|
|
@ -54,3 +54,8 @@ class SecurityView(TemplateView):
|
|||
(timezone.now() + self.expires).replace(microsecond=0).isoformat()
|
||||
)
|
||||
return context
|
||||
|
||||
|
||||
class MatrixServerView(TemplateView):
|
||||
template_name = "matrix-server.json"
|
||||
content_type = "application/json"
|
||||
|
|
|
@ -7,7 +7,12 @@ from wagtail.contrib.sitemaps.views import sitemap
|
|||
from wagtail.documents import urls as wagtaildocs_urls
|
||||
from wagtail.images.views.serve import ServeView
|
||||
|
||||
from website.common.views import RobotsView, SecurityView, page_not_found
|
||||
from website.common.views import (
|
||||
MatrixServerView,
|
||||
RobotsView,
|
||||
SecurityView,
|
||||
page_not_found,
|
||||
)
|
||||
|
||||
urlpatterns = [
|
||||
path("admin/", include(wagtailadmin_urls)),
|
||||
|
@ -28,6 +33,11 @@ urlpatterns = [
|
|||
cache_page(SecurityView.expires.total_seconds())(SecurityView.as_view()),
|
||||
name="securitytxt",
|
||||
),
|
||||
path(
|
||||
".well-known/matrix/server",
|
||||
cache_page(60 * 60)(MatrixServerView.as_view()),
|
||||
name="matrix-server",
|
||||
),
|
||||
path("404/", page_not_found, name="404"),
|
||||
]
|
||||
|
||||
|
|
Loading…
Reference in a new issue