Sort emails by domain
This commit is contained in:
parent
e983079d8e
commit
7414752ddd
3 changed files with 27 additions and 4 deletions
16
src/main.rs
16
src/main.rs
|
|
@ -18,6 +18,7 @@ use base64::{engine::general_purpose, engine::Engine};
|
|||
use color_eyre::eyre;
|
||||
use cookie::{time::OffsetDateTime, SameSite};
|
||||
use futures_util::TryStreamExt;
|
||||
use itertools::Itertools;
|
||||
use jwt_simple::prelude::*;
|
||||
use once_cell::sync::Lazy;
|
||||
use openidconnect::{
|
||||
|
|
@ -519,7 +520,12 @@ async fn home(
|
|||
) -> Result<Html<String>, Error> {
|
||||
let mails = sqlx::query_as!(
|
||||
Mail,
|
||||
"SELECT mail FROM emails WHERE id = $1 AND alias = false",
|
||||
r#"
|
||||
SELECT mail
|
||||
FROM emails
|
||||
WHERE id = $1 AND alias = false
|
||||
ORDER BY lower(substring(mail from position('@' in mail)+1 )),lower(mail)
|
||||
"#,
|
||||
user
|
||||
)
|
||||
.fetch_all(&state.db)
|
||||
|
|
@ -527,7 +533,12 @@ async fn home(
|
|||
|
||||
let aliases = sqlx::query_as!(
|
||||
Mail,
|
||||
"SELECT mail FROM emails WHERE id = $1 AND alias = true",
|
||||
r#"
|
||||
SELECT mail
|
||||
FROM emails
|
||||
WHERE id = $1 AND alias = true
|
||||
ORDER BY lower(substring(mail from position('@' in mail)+1 )),lower(mail)
|
||||
"#,
|
||||
user
|
||||
)
|
||||
.fetch_all(&state.db)
|
||||
|
|
@ -552,6 +563,7 @@ async fn home(
|
|||
let aliases: Vec<_> = aliases
|
||||
.into_iter()
|
||||
.map(|(mail, recipients)| Alias { mail, recipients })
|
||||
.sorted_by(|a, b| a.mail.cmp(&b.mail))
|
||||
.collect();
|
||||
|
||||
let mut context = tera::Context::new();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue