From d4707196ec6b89d37c76b9ac6970c89237cbc7aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Sch=C3=A4fer?= Date: Tue, 9 Feb 2021 16:43:36 +0100 Subject: [PATCH] Include Link header and element in invite response This allows future App versions to also work with the invite page without having to screen scrape the content. Fixes #56 (at least for the portal side of things). --- snikket_web/invite.py | 10 ++++++++-- snikket_web/templates/invite_view.html | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/snikket_web/invite.py b/snikket_web/invite.py index 97bf0fb..315b0f5 100644 --- a/snikket_web/invite.py +++ b/snikket_web/invite.py @@ -53,7 +53,7 @@ async def view_old(id_: str) -> quart.Response: @bp.route("//") -async def view(id_: str) -> str: +async def view(id_: str) -> typing.Union[quart.Response, str]: try: invite = await client.get_public_invite_by_id(id_) except aiohttp.ClientResponseError as exc: @@ -84,13 +84,19 @@ async def view(id_: str) -> str: ) apple_store_url = current_app.config["APPLE_STORE_URL"] - return await render_template( + body = await render_template( "invite_view.html", invite=invite, play_store_url=play_store_url, apple_store_url=apple_store_url, invite_id=id_, ) + return quart.Response( + body, + headers={ + "Link": "<{}> rel=\"alternate\"".format(invite.xmpp_uri), + } + ) class RegisterForm(flask_wtf.FlaskForm): # type:ignore diff --git a/snikket_web/templates/invite_view.html b/snikket_web/templates/invite_view.html index 01aee73..9c7798a 100644 --- a/snikket_web/templates/invite_view.html +++ b/snikket_web/templates/invite_view.html @@ -6,6 +6,7 @@ {% trans site_name=config["SITE_NAME"] %}Invite to {{ site_name }} | Snikket{% endtrans %} + {% endblock %} {% block content %}