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).
This commit is contained in:
Jonas Schäfer
2021-02-09 16:43:36 +01:00
parent 8a8d4c54bd
commit d4707196ec
2 changed files with 9 additions and 2 deletions

View File

@@ -53,7 +53,7 @@ async def view_old(id_: str) -> quart.Response:
@bp.route("/<id_>/")
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

View File

@@ -6,6 +6,7 @@
<title>{% trans site_name=config["SITE_NAME"] %}Invite to {{ site_name }} | Snikket{% endtrans %}</title>
<script async type="text/javascript" src="{{ url_for("static", filename="js/invite-magic.js") }}"></script>
<script async type="text/javascript" src="{{ url_for("static", filename="js/qrcode.min.js") }}"></script>
<link rel="alternate" href="{{ invite.xmpp_uri }}">
{% endblock %}
{% block content %}
<div class="elevated box el-3">