add invitee name

This commit is contained in:
b1ek 2024-04-21 16:12:01 +10:00
parent bc85030ad3
commit db689dcde7
Signed by: blek
GPG Key ID: 14546221E3595D0C
2 changed files with 9 additions and 6 deletions

View File

@ -7,11 +7,12 @@ use warp::{http::StatusCode, reject::Rejection, reply::{html, json, with_status,
#[derive(Debug, Clone, Template)]
#[template(path = "invite.html")]
struct Invite {
pub name: String
pub name: String,
pub invitee: String
}
async fn gen(name: String) -> Result<Box<dyn Reply>, Rejection> {
let inv = Invite { name };
async fn gen(name: String, invitee: String) -> Result<Box<dyn Reply>, Rejection> {
let inv = Invite { name, invitee };
let rendered = inv.render();
if let Err(err) = rendered {
Ok(
@ -26,6 +27,8 @@ async fn gen(name: String) -> Result<Box<dyn Reply>, Rejection> {
#[tokio::main]
async fn main() {
let route = warp::path!("gen" / String).and_then(gen);
warp::serve(route).bind(env::var("LISTEN").unwrap_or("0.0.0.0:80".into()).parse::<SocketAddrV4>().expect("Invalid LISTEN url")).await;
let route = warp::path!("gen" / String / String).and_then(gen);
let url = env::var("LISTEN").unwrap_or("0.0.0.0:80".into()).parse::<SocketAddrV4>().expect("Invalid LISTEN url");
println!("Listening on {url}");
warp::serve(route).bind(url).await;
}

View File

@ -16,7 +16,7 @@
<body>
<h1>you have been invited to join blek! cc!</h1>
<p>
a trusted member {{ name }} has invited you to join blek! cc
a trusted member {{ name }} has invited you ({{ invitee }}) to join blek! cc
</p>
<p>
if you want to create an account, please follow these instructions: