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