Nicer /new URL for new accounts and redirect GET requests

If user types in https://nine.testrun.org/new manually
in the browser, at least Firefox and Brave suggest
to open the app after following the redirect.
This commit is contained in:
link2xt 2024-01-15 11:06:35 +00:00
parent 700256c273
commit 24fb9eb65b
3 changed files with 18 additions and 4 deletions

View File

@ -6,7 +6,7 @@ import io
def gen_qr_png_data(maildomain): def gen_qr_png_data(maildomain):
url = f"DCACCOUNT:https://{maildomain}/cgi-bin/newemail.py" url = f"DCACCOUNT:https://{maildomain}/new"
image = gen_qr(maildomain, url) image = gen_qr(maildomain, url)
temp = io.BytesIO() temp = io.BytesIO()
image.save(temp, format="png") image.save(temp, format="png")

View File

@ -45,8 +45,22 @@ http {
default_type text/plain; default_type text/plain;
} }
# add cgi-bin support location /new {
include /usr/share/doc/fcgiwrap/examples/nginx.conf; if ($request_method = GET) {
# Redirect to Delta Chat,
# which will in turn do a POST request.
return 301 dcaccount:https://{{ config.domain_name }}/new;
}
fastcgi_pass unix:/run/fcgiwrap.socket;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME /usr/lib/cgi-bin/newemail.py;
}
# Old URL for compatibility with e.g. printed QR codes.
location /cgi-bin/newemail.py {
return 301 /new;
}
} }
# Redirect www. to non-www # Redirect www. to non-www

View File

@ -7,7 +7,7 @@ Welcome to instant, interoperable and [privacy-preserving](privacy.html) messagi
👉 **Tap** or scan this QR code to get a random `@{{config.mail_domain}}` e-mail address 👉 **Tap** or scan this QR code to get a random `@{{config.mail_domain}}` e-mail address
<a href="DCACCOUNT:https://{{ config.mail_domain }}/cgi-bin/newemail.py"> <a href="DCACCOUNT:https://{{ config.mail_domain }}/new">
<img width=300 style="float: none;" src="qr-chatmail-invite-{{config.mail_domain}}.png" /></a> <img width=300 style="float: none;" src="qr-chatmail-invite-{{config.mail_domain}}.png" /></a>
🐣 **Choose** your Avatar and Name 🐣 **Choose** your Avatar and Name